:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    /* Layout */
    --sidebar-width: 240px;
    --header-height: 60px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Default Theme Tokens (Dark Mode) */
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-surface: #1e293b;
    --sidebar-bg: #020617;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --nav-active-bg: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --input-bg: rgba(15, 23, 42, 0.6);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-surface: #ffffff;
    --sidebar-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --glass-bg: rgba(0, 0, 0, 0.02);
    --glass-border: rgba(0, 0, 0, 0.08);
    --nav-active-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --input-bg: #ffffff;
}

/* Theme Icon Display Logic */
[data-theme="dark"] .theme-icon-light { display: none !important; }
[data-theme="dark"] .theme-icon-dark { display: block !important; }
[data-theme="light"] .theme-icon-light { display: block !important; }
[data-theme="light"] .theme-icon-dark { display: none !important; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    font-size: 0.85rem;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    height: 100vh;
    position: fixed;
    padding: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.logo-img {
    width: 100%;
    height: auto;
    max-height: 80px;
    object-fit: contain;
}

.nav-section {
    padding: 0 0.5rem;
    margin-bottom: 1.5rem;
}

.nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 1rem 1rem 0.5rem;
    display: block;
    opacity: 0.7;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    margin: 0.2rem 0.8rem;
    font-weight: 500;
}

.nav-link i {
    width: 18px;
    height: 18px;
}

.nav-link:hover {
    background: var(--glass-bg);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-link.active {
    background: var(--nav-active-bg);
    color: white !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    padding: 0 1.25rem;
    align-items: center;
    justify-content: space-between;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 1.5rem;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0.5rem 1rem 0 0; /* Add padding to push items in slightly */
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Table Section */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-container {
    position: relative;
    width: 300px;
}

.search-input {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    color: var(--text-main);
    outline: none;
    font-size: 0.8rem;
}

.search-input:focus {
    border-color: var(--primary);
}

.table-container {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-unpaid { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-paid { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-cancelled { background: rgba(100, 116, 139, 0.12); color: var(--text-muted); }

.btn {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-icon {
    padding: 0.4rem;
    border-radius: 6px;
    color: var(--text-muted);
    background: var(--glass-bg);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--text-main);
    background: var(--glass-border);
}

.btn-danger {
    color: var(--danger);
}

/* Forms */
.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.form-grid, .form-grid-3, .form-grid-4 {
    display: grid;
    gap: 0.6rem;
}

.form-grid {
    grid-template-columns: repeat(2, 1fr);
}

.form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.form-control {
    width: 100%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.875rem;
}

.form-control:focus {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.04);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input, select, textarea {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
    font-size: 0.75rem;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

input[readonly] {
    background: rgba(255, 255, 255, 0.02);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--glass-border);
    color: var(--text-main);
}

.btn-success {
    background: #0ea5e9; /* Cyan for "Add Form" */
    color: white;
}

.footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

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

.main-content {
    animation: fadeIn 0.5s ease-out;
}

/* HTMX Loading Indicator (Global Top Bar) */
#global-loader.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s ease-in;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--primary), transparent);
    background-size: 200% 100%;
    z-index: 9999;
    pointer-events: none;
    display: block; /* Override default hidden if using id */
}

.htmx-request #global-loader.htmx-indicator {
    opacity: 1;
    animation: htmxProgress 1.5s infinite linear;
}


/* Local indicators (inline icons) */
.htmx-indicator {
    display: none;
    opacity: 1;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

@keyframes htmxProgress {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}


@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Local indicator for buttons */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}


/* Responsive Design */
@media (max-width: 1024px) {
    :root { --sidebar-width: 220px; }
    .main-content { padding: 1rem; }
    .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 100%; }
    
    body { flex-direction: column; }
    
    .mobile-header { display: flex; }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        width: 100%;
        position: fixed;
        border-right: none;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
        margin-top: var(--header-height);
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .form-grid, .form-grid-3, .form-grid-4 {
        grid-template-columns: 1fr !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .search-container {
        width: 100%;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .footer-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn { width: 100%; justify-content: center; }
}

/* Page Break Logic for long passenger lists */
thead { display: table-header-group; }
tr { page-break-inside: avoid; }

/* Hide print-only elements on screen */
.print-only { display: none; }
input[type="checkbox"] { accent-color: var(--primary); transform: scale(1.1); cursor: pointer; }

/* User Management Classes */
.row-self {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.avatar-master {
    background: rgba(139,92,246,0.2);
    color: #8b5cf6;
}

.avatar-admin {
    background: rgba(59,130,246,0.2);
    color: #3b82f6;
}

.btn-toggle-active {
    background: rgba(251,146,60,0.2) !important;
    color: #fb923c !important;
}

.btn-toggle-inactive {
    background: rgba(16,185,129,0.2) !important;
    color: #10b981 !important;
}

.role-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.75rem;
}

.role-cards-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ==========================================================================
   PRINT MEDIA STYLES
   ========================================================================== */
@media print {
    @page { size: auto; margin: 5mm; }
    body { background: white !important; color: black !important; font-size: 8pt !important; display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .sidebar, .btn, .nav-section, .header, .form-grid, .no-print, .logo, .nav-label, hr, .footer-actions, .htmx-indicator, #theme-toggle, .mobile-header, .menu-toggle { display: none !important; }
    .print-layout, .print-only { display: block !important; width: 100% !important; visibility: visible !important; }
    .main-content { margin: 0 !important; padding: 0 !important; max-width: 100% !important; background: transparent !important; }
    .print-header { display: flex !important; justify-content: space-between; border-bottom: 2px solid black !important; padding-bottom: 0.1in !important; margin-bottom: 0.15in; }
    .company-name { font-size: 12pt; font-weight: bold; }
    .company-address { font-size: 7.5pt; line-height: 1.2; }
    .customer-info { font-size: 9pt; line-height: 1.4; text-align: right; }
    .print-table { width: 100% !important; border-collapse: collapse !important; margin-bottom: 0.2in !important; }
    .print-table th, .print-table td { border: 1px solid black; padding: 4pt; color: black; }
    .print-signatures { display: flex !important; justify-content: space-between; margin-top: 0.3in; }
    .sig-box { width: 2.5in; text-align: center; }
    .sig-space { height: 0.5in; }
    .sig-line { font-size: 10pt; font-weight: 600; }
    .print-footer-notes { font-size: 7pt; margin-top: 0.15in; padding-bottom: 5pt; }
}

