/* styles.css - Shared styles for OBD Key Service */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: #1e1e1e;
    color: #d4d4d4;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent body scroll that might interfere with popups */
}

/* Ensure PayPal overlays and popups are above everything */
.paypal-checkout-sandbox,
.paypal-checkout-overlay,
.paypal-overlay-context {
    z-index: 9999 !important;
}

/* Header */
.header {
    background: #2d2d2d;
    padding: 15px;
    border-bottom: 2px solid #3e3e3e;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons */
button {
    background: #0e639c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s;
}

button:hover:not(:disabled) {
    background: #1177bb;
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

button.submit-key {
    background: #16825d;
    font-size: 18px;
    padding: 15px 30px;
    width: 100%;
    margin-top: 10px;
}

button.submit-key:hover:not(:disabled) {
    background: #1a9e6f;
}

button.logout {
    background: #d13438;
}

button.logout:hover {
    background: #e13d41;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Terminal */
.terminal {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #1e1e1e;
    font-size: 13px;
    line-height: 1.6;
}

.terminal-line {
    margin: 3px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-line .timestamp {
    color: #858585;
    margin-right: 8px;
}

.sent { color: #4ec9b0; font-weight: bold; }
.received { color: #ce9178; }
.success { color: #4ec9b0; font-weight: bold; }
.error { color: #f48771; font-weight: bold; }
.info { color: #608b4e; }
.warning { color: #dcdcaa; }

/* Side Panel */
.side-panel {
    width: 500px;
    background: #252526;
    border-left: 2px solid #3e3e3e;
    padding: 20px;
    overflow-y: auto;
}

.panel-section {
    background: #2d2d2d;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 6px;
    border: 1px solid #3e3e3e;
}

.panel-section h3 {
    color: #4ec9b0;
    margin-bottom: 15px;
    font-size: 16px;
    text-transform: uppercase;
}

/* Inputs */
input, textarea, select {
    background: #3c3c3c;
    color: #d4d4d4;
    border: 1px solid #555;
    padding: 12px;
    border-radius: 4px;
    width: 100%;
    margin-bottom: 10px;
    font-family: inherit;
    font-size: 14px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #0e639c;
}

input[readonly] {
    background: #2d2d2d;
    cursor: not-allowed;
}

/* Key Display */
.key-display {
    background: #1e1e1e;
    color: #4ec9b0;
    padding: 20px;
    border-radius: 4px;
    font-size: 24px;
    letter-spacing: 3px;
    text-align: center;
    font-weight: bold;
    margin: 15px 0;
    border: 2px solid #4ec9b0;
    font-family: 'Courier New', monospace;
}

.key-ready {
    animation: glow 1.5s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px #4ec9b0; }
    50% { box-shadow: 0 0 20px #4ec9b0; }
}

/* Price Tag */
.price-tag {
    background: #0e639c;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    display: inline-block;
    font-weight: bold;
    margin: 10px 0;
    font-size: 18px;
}

/* Status Badge */
.status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    margin-left: 10px;
}

.status.connected { background: #0e639c; }
.status.disconnected { background: #666; }

/* Admin Link */
.admin-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: #444;
    padding: 8px 15px;
    border-radius: 4px;
    color: #aaa;
    text-decoration: none;
    font-size: 11px;
}

.admin-link:hover {
    background: #555;
    color: #fff;
}

/* Admin Login */
.login-box {
    background: #2d2d2d;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 400px;
    margin: 100px auto;
}

.login-box h2 {
    color: #4ec9b0;
    margin-bottom: 30px;
    text-align: center;
}

.login-box .error {
    color: #f48771;
    font-size: 13px;
    margin-top: 10px;
    display: none;
}

.back-link {
    text-align: center;
    margin-top: 20px;
}

.back-link a {
    color: #888;
    text-decoration: none;
    font-size: 13px;
}

.back-link a:hover {
    color: #aaa;
}

/* Dashboard */
.dashboard {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dashboard-header h1 {
    color: #4ec9b0;
    margin: 0;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #2d2d2d;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #3e3e3e;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #4ec9b0;
    margin: 10px 0;
}

.stat-label {
    color: #888;
    font-size: 14px;
}

/* Section */
.section {
    background: #2d2d2d;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #3e3e3e;
    margin-bottom: 20px;
}

.section h2 {
    color: #4ec9b0;
    margin-top: 0;
    margin-bottom: 15px;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #3e3e3e;
}

th {
    color: #4ec9b0;
    font-weight: bold;
}

tr:hover {
    background: #252526;
}

.status-completed { color: #4ec9b0; }
.status-pending { color: #dcdcaa; }
.status-failed { color: #f48771; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 16px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* PayPal Button Container */
#paypal-button-container {
    margin: 15px 0;
    min-height: 150px;
    position: relative;
    z-index: 1;
}

/* Ensure PayPal iframes and overlays are visible */
#paypal-button-container iframe {
    border: none !important;
}

/* PayPal Loading Message */
.paypal-loading {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-style: italic;
    border: 1px dashed #444;
    border-radius: 4px;
    background: #2a2a2a;
}

/* Manual PayPal Button */
.paypal-manual-btn {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    background: #FFC439;
    color: #003087;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    margin: 10px 0;
}

.paypal-manual-btn:hover:not(:disabled) {
    background: #FFD966;
}

.paypal-manual-btn:disabled {
    background: #CCC;
    color: #888;
    cursor: not-allowed;
}

/* Divider text */
.divider-text {
    text-align: center;
    margin: 20px 0;
    color: #888;
    font-size: 14px;
    position: relative;
}

.divider-text::before,
.divider-text::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #444;
}

.divider-text::before {
    left: 0;
}

.divider-text::after {
    right: 0;
}

/* Already have key section */
.already-have-key-section {
    margin-top: 15px;
}

.secondary-btn {
    background: #555;
    width: 100%;
}

.secondary-btn:hover:not(:disabled) {
    background: #666;
}

/* Key verification section */
#keyVerificationSection input {
    width: 100%;
    padding: 10px;
    border: 2px solid #444;
    background: #2d2d2d;
    color: #d4d4d4;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
}

#keyVerificationSection input:focus {
    outline: none;
    border-color: #0e639c;
}

#keyVerificationSection input.valid {
    border-color: #4ec9b0;
    background: #1e3a32;
}

#keyVerificationSection input.invalid {
    border-color: #f48771;
    background: #3a1e1e;
}

/* End Programming Button Styles */
button.submit-key.end-programming {
    background: #d13438;
}

button.submit-key.end-programming:hover:not(:disabled) {
    background: #e13d41;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .side-panel {
        width: 100%;
        border-left: none;
        border-top: 2px solid #3e3e3e;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Terms & Conditions Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #2d2d2d;
    margin: auto;
    padding: 0;
    border: 2px solid #4CAF50;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: linear-gradient(135deg, #0066cc 0%, #003d7a 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #d4d4d4;
}

.terms-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #3e3e3e;
}

.terms-section:last-of-type {
    border-bottom: none;
}

.terms-section h3 {
    color: #4CAF50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.terms-section h4 {
    color: #4ec9b0;
    margin: 15px 0 10px 0;
    font-size: 1rem;
}

.terms-section p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.terms-section ol {
    margin-left: 20px;
    line-height: 1.8;
}

.terms-section li {
    margin-bottom: 10px;
}

.terms-checkbox {
    background: #1e1e1e;
    border: 2px solid #4CAF50;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

.terms-checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.terms-checkbox input[type="checkbox"] {
    margin-top: 4px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.terms-checkbox span {
    color: #dcdcaa;
    line-height: 1.6;
}

.modal-footer {
    background: #1e1e1e;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
    border-top: 1px solid #3e3e3e;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.decline-btn {
    background: #d32f2f;
    color: white;
}

.decline-btn:hover {
    background: #b71c1c;
}

.accept-btn {
    background: #4CAF50;
    color: white;
}

.accept-btn:hover:not(:disabled) {
    background: #45a049;
}

.accept-btn:disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }
}
