:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --error: #ef4444;
}

.hidden {
    display: none !important;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-color);
    background-image: linear-gradient(rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.9)), url('bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Glassmorphism Classes */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
    width: 100%;
}

/* Overlay & Passcode */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(20px);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.login-card {
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.icon-header {
    width: 80px;
    height: 80px;
    background: rgba(79, 70, 229, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 24px;
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.lock-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.login-card h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: white;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.input-group {
    display: flex;
    flex-direction: column; /* Stacking for cleaner mobile look */
    gap: 16px;
    width: 100%;
}

#passcodeInput {
    width: 100%;
    background: rgba(255, 255, 255, 0.08); /* Darker, more glass-like */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    color: white;
    font-size: 1.2rem;
    letter-spacing: 4px;
    outline: none;
    text-align: center;
    transition: all 0.3s ease;
}

#passcodeInput:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

#unlockButton {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#unlockButton:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.feedback {
    margin-top: 16px;
    font-size: 0.85rem;
    min-height: 1.2rem;
}

.feedback.error {
    color: var(--error);
}

.feedback.success {
    color: var(--secondary);
}

.input-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.input-group-vertical input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 20px;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.input-group-vertical input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.12);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal-actions button {
    flex: 1;
}

/* Main App Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container.hidden {
    display: none;
}

.app-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 80px;
    animation: fadeInDown 0.8s ease;
}

@keyframes fadeInDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-area h1 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    letter-spacing: 2px;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-area h1 span {
    font-weight: 300;
    color: var(--accent);
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* App Content Area */
.app-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

/* Search Section - Centered Focus */
.search-section {
    width: 100%;
    max-width: 800px;
    animation: scaleUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.search-card {
    padding: 48px;
    text-align: center;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.search-title {
    margin-bottom: 32px;
}

.search-title h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    margin-bottom: 10px;
}

.search-title h2 span {
    color: var(--accent);
}

.search-title p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 16px;
    padding: 6px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.15);
}

.search-icon {
    margin-left: 20px;
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

#searchInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 1.1rem;
    padding: 18px 20px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    padding: 0 32px;
    height: 54px;
    border-radius: 12px;
}

.btn-secondary {
    display: flex; /* Ensure it can show */
    margin: 20px auto 0;
    width: fit-content;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary);
    border: 1px solid var(--secondary);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover:not(.hidden) {
    background: var(--secondary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.2);
}

.btn-secondary i {
    width: 20px;
    height: 20px;
}

/* Results Content */
.results-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.customer-info {
    text-align: center;
    background: rgba(56, 189, 248, 0.05);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-top: 10px;
}

.customer-info h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    color: var(--accent);
    letter-spacing: 2px;
    margin: 0;
}

/* Modern Table Styles - Responsive Fit */
.table-wrapper {
    width: 100%;
    margin-top: 20px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    overflow-x: auto; /* Enable horizontal scroll for mobile */
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem; /* Slightly smaller for better fit */
    margin: 0;
}

th {
    background: rgba(30, 41, 59, 0.9);
    padding: 16px 12px;
    text-align: left;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

td {
    padding: 14px 12px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    line-height: 1.4;
}

/* Specific Column Control */
td:nth-child(2), td:nth-child(9) { /* Associate & Plan Columns */
    font-size: 0.8rem;
    max-width: 200px;
    word-break: break-word;
}

tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

tbody tr:hover {
    background: rgba(56, 189, 248, 0.06);
}

.table-customer-header th {
    background: linear-gradient(to right, rgba(56, 189, 248, 0.1), transparent);
    color: white;
    font-size: 1.3rem;
    padding: 24px;
    text-align: center;
    letter-spacing: 4px;
}

.totals-row td {
    background: rgba(30, 41, 59, 0.5);
    font-weight: 700;
    color: var(--accent);
    border-top: 2px solid rgba(255, 255, 255, 0.08);
}

.balance-box-row td {
    background: linear-gradient(to right, transparent, rgba(16, 185, 129, 0.1)) !important;
    text-align: right;
    padding: 30px 50px;
}

.balance-text {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--secondary);
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.results-section {
    animation: fadeInUp 0.8s ease backwards;
}

.no-records {
    padding: 80px;
    text-align: center;
    color: var(--text-secondary);
}

.no-records i {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Print Overrides */
/* --- FINAL PRINT STYLES --- */
@media print {
    /* Prevent browser from showing URLs after links */
    a[href]::after {
        content: none !important;
    }
    
    /* Hide everything EXCEPT the data container */
    .overlay, .app-header, .search-section, .header-actions, .app-footer-web, .btn-primary, .btn-ghost, .btn-secondary, #settingsButton, #printButton, .modal, #noResults, .no-records, .copyright, .footer-content, footer {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .container {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .results-section {
        display: block !important;
        width: 100% !important;
    }

    .table-wrapper {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        background: white !important;
        overflow: visible !important;
        width: 100% !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    th, td {
        border: 1px solid #000 !important;
        color: black !important;
        padding: 6px !important;
        font-size: 9pt !important;
    }

    .print-only-footer {
        display: block !important;
        text-align: center;
        margin-top: 30px;
        padding-top: 5px;
        border-top: 1px solid #ddd;
        font-weight: 400;
        font-size: 8pt !important;
        color: #777 !important;
    }
}

.print-only-footer {
    display: none;
}

/* Tablet & Mobile Table Support */
@media (max-width: 1024px) {
    .container {
        padding: 40px 15px;
    }
    
    .table-wrapper {
        overflow-x: auto; /* Essential for keeping table layout on small screens */
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    table {
        min-width: 1000px; /* Force table to maintain width for scrolling */
    }
}

@media (max-width: 768px) {
    .app-header {
        margin-bottom: 40px;
    }

    .logo-area h1 {
        font-size: 1.4rem;
    }

    /* Keep Search Responsive but Clean */
    .search-input-wrapper {
        flex-direction: column;
        background: transparent;
        border: none;
        box-shadow: none;
        gap: 12px;
    }

    #searchInput {
        background: rgba(30, 41, 59, 1);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        width: 100%;
        padding: 16px;
    }

    .btn-primary {
        width: 100%;
        height: 54px;
    }
}
