:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.05);

    /* Sidebar Theme */
    --sidebar-bg: #000080;
    --sidebar-text: #ffffff;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-muted: rgba(255, 255, 255, 0.6);
    --sidebar-active-bg: rgba(255, 255, 255, 0.15);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.1);
}

/* Theme: Dark */
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --accent: #38bdf8;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    
    --sidebar-bg: #0f172a;
    --sidebar-text: #e2e8f0;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: #334155;
    --sidebar-border: #334155;
}

/* Theme: Blue (Corporate) */
[data-theme="blue"] {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --sidebar-bg: #1e3a8a;
}

/* Theme: Green (Nature) */
[data-theme="green"] {
    --primary: #10b981;
    --primary-hover: #059669;
    --sidebar-bg: #064e3b;
}

/* Theme: Purple (Creative) */
[data-theme="purple"] {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --sidebar-bg: #4c1d95;
}

/* Theme: Red (Bold) */
[data-theme="red"] {
    --primary: #ef4444;
    --primary-hover: #dc2626;
    --sidebar-bg: #7f1d1d;
}

/* Theme: Orange (Warm) */
[data-theme="orange"] {
    --primary: #f97316;
    --primary-hover: #ea580c;
    --sidebar-bg: #7c2d12;
}

/* Theme: Teal (Calm) */
[data-theme="teal"] {
    --primary: #14b8a6;
    --primary-hover: #0d9488;
    --sidebar-bg: #134e4a;
}

body.app-body {
    background: 
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.05), transparent 40%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.05), transparent 40%),
        var(--bg);
    color: var(--text);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

/* Dark mode specific adjustments */
[data-theme="dark"] body.app-body {
    background: var(--bg); /* Simplify background for dark mode */
}

[data-theme="dark"] .navbar {
    background: rgba(30, 41, 59, 0.85) !important;
    border-bottom: 1px solid var(--border) !important;
}

[data-theme="dark"] .navbar-brand {
    color: var(--text) !important;
}

[data-theme="dark"] .navbar-light .navbar-nav .nav-link {
    color: var(--muted);
}

[data-theme="dark"] .navbar-light .navbar-nav .nav-link.active,
[data-theme="dark"] .navbar-light .navbar-nav .nav-link:hover {
    color: var(--text);
}

[data-theme="dark"] .bg-white {
    background-color: var(--surface) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text) !important;
}

[data-theme="dark"] .text-muted {
    color: var(--muted) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #0f172a;
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #1e293b;
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--border);
}

.navbar {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.85) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.navbar-brand {
    letter-spacing: 0.02em;
    color: var(--primary) !important;
    font-weight: 700;
}

.card,
.panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden; /* Ensure headers/footers are clipped */
}

/* New Panel Header Style */
.panel-heading,
.card-header {
    background-color: var(--sidebar-bg);
    color: #ffffff;
    padding: 16px 24px;
    border-bottom: 1px solid var(--sidebar-border);
    font-weight: 600;
    font-size: 1.1rem;
}

.hero-section {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hero-img-container {
    height: 100%;
    min-height: 400px;
    background-size: cover;
    background-position: center;
    border-radius: 20px;
}

.hero-content {
    padding: 60px 40px;
    z-index: 2;
}

.motivation-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(59, 130, 246, 0.2);
}

.motivation-box h3 {
    font-weight: 700;
    margin-bottom: 0;
}

.feature-icon {
    width: 60px;
    height: 60px;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .fs-4 {
    color: var(--primary);
    font-weight: 700;
}

.badge-status,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 600;
    border: 1px solid transparent;
}

.badge-status.posted,
.badge.posted {
    background: #f1f5f9;
    color: #475569;
}

.badge-status.offered,
.badge.offered {
    background: #e0f2fe;
    color: #0284c7;
}

.badge-status.confirmed,
.badge.confirmed {
    background: #dcfce7;
    color: #16a34a;
}

.badge-status.in_transit,
.badge.in_transit {
    background: #fef3c7;
    color: #d97706;
}

.badge-status.delivered,
.badge.delivered {
    background: #f3e8ff;
    color: #9333ea;
}

/* Update Table Headers to match Sidebar */
.table thead th {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text);
    background-color: var(--sidebar-bg);
    border-bottom: 2px solid var(--sidebar-border);
    padding: 14px 16px; /* Increased padding */
    vertical-align: middle;
}
/* Ensure first and last th have rounded corners if table is isolated? 
   Bootstrap tables usually handle this, but with custom bg we might need to be careful. */
.table thead th:first-child {
    border-top-left-radius: 8px;
}
.table thead th:last-child {
    border-top-right-radius: 8px;
}

/* Fix text-muted in table headers */
.table thead th .text-muted {
    color: var(--sidebar-muted) !important;
}

.table tbody td {
    vertical-align: middle;
    padding: 16px 8px;
    border-bottom: 1px solid #f8fafc;
}

[data-theme="dark"] .table tbody td {
    border-bottom-color: var(--border);
}

.table tbody tr:hover {
    background: #f8fafc;
}

[data-theme="dark"] .table tbody tr:hover {
    background: #334155;
    color: #fff;
}

[data-theme="dark"] .table {
    color: var(--text);
}

.form-control,
.form-select {
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px 16px;
    background: #f8fafc;
}

.form-control:focus,
.form-select:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-label {
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

[data-theme="dark"] .form-label {
    color: var(--text);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 10px 20px;
    transition: all 0.2s ease;
}

.btn-outline-dark {
    border-color: var(--border);
    color: #334155;
}

.btn-outline-dark:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

[data-theme="dark"] .btn-outline-dark {
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .btn-outline-dark:hover {
    background-color: var(--border);
    color: #fff;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.muted {
    color: var(--muted);
}

.alert {
    border-radius: 12px;
}

/* Sidebar Styles Updated */
.admin-sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: sticky;
    top: 76px;
    height: calc(100vh - 76px);
    overflow-y: auto;
    border-radius: 0;
    /* Ensure it covers the parent's white bg */
    margin-right: -1px; /* Overlap border if needed */
}

/* Fix text-muted in sidebar (must be light on dark bg) */
.admin-sidebar .text-muted {
    color: var(--sidebar-muted) !important;
}

/* Sidebar Headings */
.admin-sidebar h2 {
    color: #ffffff !important; /* Force white for headings */
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 12px;
    margin-bottom: 20px;
    font-size: 1.1rem;
}
.admin-sidebar h2 i {
    color: var(--sidebar-active-bg) !important;
}

/* Sidebar Links */
.admin-nav-link {
    display: block;
    padding: 12px 16px;
    border-radius: 8px; /* Slightly smaller radius for tighter list */
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.admin-nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text-hover);
}

.admin-nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Collapsible Toggles in Sidebar */
.admin-sidebar .nav-link {
    color: var(--sidebar-text) !important;
}
.admin-sidebar .nav-link:hover {
    color: var(--sidebar-text-hover) !important;
    background: rgba(255, 255, 255, 0.05);
}

/* Sub-menus borders */
.admin-sidebar .border-start {
    border-color: var(--sidebar-border) !important;
}

/* Logout button in sidebar */
.admin-sidebar .btn-outline-danger {
    border-color: #ef4444;
    color: #ef4444;
}
.admin-sidebar .btn-outline-danger:hover {
    background: #ef4444;
    color: #ffffff;
}

[dir="rtl"] .navbar .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

[dir="rtl"] .text-start {
    text-align: right !important;
}

@media (max-width: 991px) {
    .hero-content {
        padding: 30px 20px;
    }
    
    .hero-img-container {
        min-height: 250px;
        margin-top: 20px;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        overflow-y: visible;
        background-color: var(--sidebar-bg); /* Keep dark on mobile too */
    }
}

/* Sidebar Column Wrapper */
.sidebar-col {
    width: 100%;
}
@media (min-width: 768px) {
    .sidebar-col {
        width: 220px;
        flex-shrink: 0;
        min-height: 100vh;
    }
}

/* Global Print Styles */
@media print {
    /* Hide browser-added headers/footers (title, date, URL) */
    @page {
        margin-top: 1cm;
        margin-bottom: 1cm;
        size: auto;
    }

    /* Kill standard href expansion */
    a[href]:after {
        content: none !important;
    }

    body, [data-theme="dark"] body.app-body {
        background: #ffffff !important;
        color: #000000 !important;
        /* Padding to emulate margin if @page fails */
        margin: 0 !important; 
    }
    
    /* Hide Sidebar, Nav, and Standard Footer */
    .admin-sidebar, 
    .navbar, 
    .btn, 
    form, 
    .no-print,
    footer { 
        display: none !important; 
    }

    /* Expand main content */
    .col-md-10, .col-lg-10, .col-xl-10 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Reset Panels/Cards for print */
    .panel, .card {
        border: none !important;
        box-shadow: none !important;
        background: #ffffff !important;
    }

    /* Table Adjustments */
    .table {
        width: 100% !important;
        color: #000000 !important;
    }
    
    .table thead th {
        background-color: #f8f9fa !important;
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
        text-shadow: none !important;
    }
    
    /* Ensure muted text in headers is visible (dark gray/black) */
    .table thead th .text-muted {
        color: #333333 !important;
    }
    
    .table tbody td {
        border-bottom: 1px solid #dee2e6 !important;
        color: #000000 !important;
    }
    
    /* Typography Overrides */
    h1, h2, h3, h4, h5, h6, p, span, div, td, th {
        color: #000000 !important;
    }
    
    .text-muted {
        color: #555555 !important;
    }
    
    .text-white {
        color: #000000 !important;
    }

    /* Badges to outlines */
    .badge {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
    }
    
    a {
        text-decoration: none !important;
        color: #000 !important;
    }
    
    /* Ensure visibility utilities work in print */
    .d-print-block {
        display: block !important;
    }
    .d-print-none {
        display: none !important;
    }
    .print-no-shadow {
        box-shadow: none !important;
        border: none !important;
    }

    /* Sticky Footer */
    .print-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background: white;
        padding: 10px 0;
        border-top: 1px solid #000 !important;
        z-index: 999;
    }
}