/* CSS Variables & Theming */
:root {
    --primary-color: #0a84ff;
    --primary-hover: #007aff;
    --bg-dark: #000000;
    --sidebar-bg: rgba(22, 27, 34, 0.45);
    --card-bg: rgba(22, 27, 34, 0.45);
    --text-main: #ffffff;
    --text-muted: rgba(235, 235, 245, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.04);
    --glass-shadow: inset 0 1px 1px rgba(255,255,255,0.12), inset 0 -1px 1px rgba(255,255,255,0.02), 0 8px 32px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background-color: #0d1117;
    
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Animated Background Blobs */
.blob { display: none !important; 
    position: fixed;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 10s infinite ease-in-out alternate;
}
.blob-1 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(0,122,255,0.2), transparent); top: -100px; left: -100px; border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
.blob-2 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(0,122,255,0.1), transparent); bottom: -150px; right: -100px; border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; animation-delay: -5s; }
.blob-3 { width: 300px; height: 300px; background: radial-gradient(circle, rgba(52,199,89,0.1), transparent); bottom: 20%; left: 15%; border-radius: 50%; animation-duration: 12s; opacity: 0.4; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    100% { transform: translate(30px, 50px) scale(1.1) rotate(10deg); }
}

h1, h2, h3, h4, h5, h6 { font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif; }
h1#page-title, #login-screen h2 {
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.app-container { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background-color: var(--sidebar-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-right: 1px solid var(--border-color); padding: 2rem 0; display: flex; flex-direction: column; z-index: 10; }
.logo { display: flex; align-items: center; gap: 0.75rem; padding: 0 2rem; margin-bottom: 2.5rem; color: var(--primary-color); font-size: 1.25rem; }
.nav-links { list-style: none; }
.nav-links li { padding: 1rem 2rem; display: flex; align-items: center; gap: 1rem; color: var(--text-muted); cursor: pointer; transition: all 0.3s ease; border-left: 3px solid transparent; }
.nav-links li:hover, .nav-links li.active { color: var(--text-main); background-color: rgba(59, 130, 246, 0.1); border-left-color: var(--primary-color); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow-x: auto; }
.topbar { height: 80px; padding: 0 3rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); backdrop-filter: blur(10px); }
.user-profile { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-color); display: flex; align-items: center; justify-content: center; }
.content-wrapper { padding: 3rem; flex: 1; }
.page-section { display: none; animation: fadeIn 0.4s ease; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Stats & Tables */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-bottom: 3rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 16px; padding: 1.5rem; display: flex; align-items: center; gap: 1.5rem; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: var(--glass-shadow); }
.stat-icon { width: 60px; height: 60px; border-radius: 12px; background: rgba(59, 130, 246, 0.2); color: var(--primary-color); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.stat-info h3 { font-size: 0.875rem; color: var(--text-muted); }
.stat-info p { font-size: 1.75rem; font-weight: 700; }

.form-card, .card { background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 24px; padding: 2.5rem; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: var(--glass-shadow); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-size: 0.875rem; color: var(--text-muted); }
input, select { background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border-color); color: var(--text-main); padding: 0.75rem 1rem; border-radius: 0.5rem; }
.calc-preview { margin-top: 2rem; padding: 1.5rem; background: rgba(59, 130, 246, 0.1); border-radius: 0.75rem; display: flex; justify-content: space-around; }
.form-actions { margin-top: 2rem; display: flex; gap: 1rem; justify-content: flex-end; }
button { padding: 0.75rem 1.5rem; border-radius: 0.5rem; font-weight: 600; cursor: pointer; border: none; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-secondary { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 0.4rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap; }

.invoice-controls { display: flex; gap: 1rem; margin-bottom: 2rem; align-items: flex-end; background: var(--card-bg); padding: 1.5rem; border-radius: 16px; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: var(--glass-shadow); }

/* 
===============================================
    PDF INVOICE SPECIFIC STYLING 
===============================================
*/
.invoice-pdf-layout {
    background: white;
    overflow-x: auto;
    color: black;
    padding: 2rem 3rem;
    font-family: Arial, Helvetica, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    font-size: 10px;
    line-height: 1.15;
}

.pdf-grid-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid black;
    margin: 0;
    color: black;
    font-size: 10px;
    font-family: Arial, Helvetica, sans-serif;
}
.pdf-grid-table th, .pdf-grid-table td {
    border: 1px solid black;
    padding: 3px 4px;
}
.pdf-grid-table th {
    font-weight: normal;
}

.pdf-header {
    position: relative;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
}
.pdf-logo {
    width: 200px;
}
.pdf-title-area {
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
}
.pdf-date-box {
    text-align: right;
    margin-bottom: 5px;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    display: inline-block;
    float: right;
}
.pdf-title {
    clear: both;
    text-decoration: underline;
    font-size: 18px;
    font-weight: bold;
    margin: 5px 0;
}
.pdf-inv-no {
    text-align: right;
    font-size: 11px;
}

.pdf-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 11px;
}
.meta-table td {
    padding: 1px 5px;
}

/* Main Table */
.pdf-main-table, .pdf-bottom-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 5px;
}
.pdf-main-table th, .pdf-main-table td, 
.pdf-bottom-table th, .pdf-bottom-table td {
    border: 1px solid black;
    padding: 4px;
    text-align: center;
    font-size: 10px;
}
.pdf-main-table th { font-weight: normal; }

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.no-border { border: none !important; }
.no-border-btm { border-bottom: none !important; }
.no-border-top { border-top: none !important; }

/* Signatures */
.pdf-signatures {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 11px;
}
.sig-box {
    width: 30%;
}
.sig-space {
    height: 60px;
}
.sig-name-highlight {
    background: #e2e8f0;
    display: inline-block;
    padding: 2px 20px;
}

/* Remarks Fuel Box */
.pdf-remarks-title {
    font-weight: bold;
    text-decoration: underline;
    font-style: italic;
    border: 1px solid black;
    border-bottom: none;
    padding: 2px 4px;
    display: inline-block;
    width: 100%;
}
.pdf-remarks-container {
    border: 1px solid black;
    display: flex;
    margin-bottom: 10px;
}
.fuel-remark-section {
    flex: 1;
    display: flex;
}
.fuel-remark-side-left {
    width: 120px;
    border-right: 1px solid black;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    text-align: center;
}
.fuel-remark-side-right {
    flex: 1;
    padding: 0;
}
.fuel-row {
    display: flex;
    border-bottom: 1px solid black;
}
.fuel-row:last-child {
    border-bottom: none;
}
.fuel-col {
    padding: 2px 4px;
    font-size: 10px;
    display: flex;
    align-items: center;
}
.fc-label { width: 110px; text-align: right; font-weight: bold; }
.fc-val { width: 60px; text-align: center; font-weight: bold; }
.fc-unit { width: 30px; font-weight: bold; }
.fc-sep { width: 10px; text-align: center; }
.fc-label2 { width: 70px; font-weight: bold; }

.fuel-total-row {
    border-top: 1px solid black;
    padding: 4px;
    font-weight: bold;
}

/* Manifest & Delay check boxes */
.delay-checkboxes {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-weight: normal;
}
.box {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid black;
    vertical-align: middle;
    margin-right: 4px;
}
.pdf-footer-note {
    font-size: 10px;
    margin-top: 10px;
}


/* Print Mode */
@media print {
    @page {
    size: A4 portrait;
    margin-top: 0.4in;
    margin-bottom: 0.4in;
    margin-left: 0.6in;
    margin-right: 0.6in;
}
    
    .no-print { display: none !important; }
    body, .app-container, .main-content, .content-wrapper { background: white !important; color: black !important; margin: 0 !important; padding: 0 !important; }
    .page-section { display: block !important; }
    #dashboard, #add-flight, #flight-log, #fuel-recap, #report-tool, #mvt-generator { display: none !important; }
    .invoice-pdf-layout { padding: 0 !important; width: 99.6% !important; max-width: 99.6% !important; margin: 0 !important; box-sizing: border-box; }
    .pdf-grid-table { width: 99.6% !important; max-width: 99.6% !important; }
    .pdf-grid-table th, .pdf-grid-table td { padding: 2px !important; box-sizing: border-box; }
    * { -webkit-print-color-adjust: exact !important; color-adjust: exact !important; }
}

.pdf-rem-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.pdf-rem-table td { padding: 3px 5px; }
.fw-bold { font-weight: bold; }
.rem-border-btm { border-bottom: 2px solid black; }
.rem-border-btm-thin { border-bottom: 1px solid black; }


.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}
.modal-content {
    background: #1e293b; /* Solid background so it's not transparent */
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
}



/* =========================================================
   RESPONSIVE TABLET & PHONE OVERRIDES (SCREEN ONLY)
   Desktop (>1180px) & @media print preserved 100%
   ========================================================= */
.inv-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.inv-mobile-menu-btn,
.inv-sidebar-close-btn,
.inv-sidebar-backdrop {
    display: none;
}

@media screen and (max-width: 1180px) {
    .topbar { padding: 0 1.5rem; }
    .content-wrapper { padding: 1.75rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 2rem; }
    .form-card, .card { padding: 1.75rem; }
}

@media screen and (max-width: 960px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 265px;
        height: 100dvh;
        background: rgba(13, 17, 23, 0.98);
        transform: translateX(-105%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1200;
        overflow-y: auto;
        padding: 1.5rem 0 2rem;
        box-shadow: 12px 0 36px rgba(0, 0, 0, 0.75);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .inv-sidebar-close-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 14px;
        right: 14px;
        width: 34px;
        height: 34px;
        padding: 0;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.14);
        color: #cbd5e1;
        font-size: 15px;
    }
    .inv-sidebar-backdrop.active {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 1150;
    }
    .inv-mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.14);
        color: #f8fafc;
        font-size: 16px;
        flex-shrink: 0;
    }
    .main-content { min-width: 0; width: 100%; }
    .topbar {
        height: auto;
        min-height: 64px;
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }
    h1#page-title {
        font-size: 1.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .content-wrapper { padding: 1.15rem; }
    .form-card, .card { padding: 1.25rem; border-radius: 16px; }
    .stat-card { padding: 1.1rem; gap: 1rem; }
    .stat-icon { width: 48px; height: 48px; font-size: 1.25rem; flex-shrink: 0; }
    .stat-info p { font-size: 1.35rem; }
    .inv-recent-header, .card-header { flex-wrap: wrap !important; gap: 10px !important; }
    .inv-export-bar { flex-wrap: wrap !important; gap: 8px !important; }
    .invoice-controls { flex-wrap: wrap; padding: 1.15rem; gap: 0.85rem; }
    .invoice-controls .control-group { display: flex; flex-direction: column; gap: 0.35rem; flex: 1 1 180px; }
    .invoice-controls .control-group input,
    .invoice-controls .control-group select { width: 100%; }
    .calc-preview { flex-wrap: wrap; gap: 10px 20px; justify-content: flex-start; padding: 1rem 1.25rem; }
    .table-container { -webkit-overflow-scrolling: touch; }
    .invoice-pdf-layout {
        padding: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }
    .invoice-pdf-layout .pdf-header,
    .invoice-pdf-layout .pdf-grid-table {
        min-width: 720px;
    }
    #report-tool, #mvt-generator {
        height: calc(100dvh - 96px) !important;
        min-height: 520px;
    }
}

@media screen and (max-width: 600px) {
    .topbar { padding: 10px 12px; }
    h1#page-title { font-size: 1.05rem; }
    .invoice-user-badge { padding: 4px 8px !important; font-size: 11px !important; gap: 5px !important; }
    .content-wrapper { padding: 0.85rem; }
    .stats-grid { grid-template-columns: 1fr; gap: 0.85rem; margin-bottom: 1.5rem; }
    .form-card, .card { padding: 1rem; border-radius: 14px; }
    .form-grid { grid-template-columns: 1fr; gap: 1rem; }
    .sector-block { padding: 1rem !important; margin-bottom: 1.25rem !important; }
    .inv-export-bar { width: 100%; }
    .inv-export-bar input[type="month"],
    .inv-export-bar button { flex: 1 1 auto; }
    .filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; }
    .filter-group input[type="month"] { flex: 1 1 160px; }
    .invoice-controls .control-group,
    .invoice-controls > button { flex: 1 1 100%; width: 100%; }
    .form-actions { flex-wrap: wrap; }
    .form-actions button,
    #btn-add-sector { width: 100%; }
    .login-card { width: min(420px, 92vw) !important; }
    .login-body { padding: 28px 20px 24px !important; }
    .radar-sweep { width: 520px !important; height: 520px !important; margin: -260px 0 0 -260px !important; }
    .modal-overlay { padding: 0.5rem; }
    .modal-content,
    #edit-modal .modal-content,
    #delete-modal .modal-content {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 1.15rem !important;
        max-height: 88dvh;
    }
    #workspace-modal > div {
        width: min(400px, 92vw) !important;
        padding: 24px 18px !important;
        box-sizing: border-box;
    }
    #change-password-modal > div,
    #admin-reset-modal > div {
        width: min(380px, 92vw) !important;
        padding: 20px 16px !important;
        box-sizing: border-box;
    }
}
