:root {
    --bs-primary: #003650;
    --bs-primary-rgb: 0, 54, 80;
    --bs-link-color: #00618d;
    --bs-link-hover-color: #003650;
    --bs-border-radius: 8px;
    --bg: #f6fafc;
    --surface: #ffffff;
    --text: #0b2f44;
    --muted: #657989;
    --border: #d8e5ec;
    --primary: #003650;
    --primary-hover: #002a3f;
    --accent: #00aeef;
    --brand-mid: #00618d;
    --brand-soft: #e7f6fc;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow: 0 10px 30px rgba(0, 54, 80, 0.06);
    --shadow-strong: 0 22px 60px rgba(0, 54, 80, 0.14);

    /* Sidebar Theme */
    --sidebar-bg: #003650;
    --sidebar-text: #ffffff;
    --sidebar-text-hover: #d7f3ff;
    --sidebar-muted: rgba(255, 255, 255, 0.6);
    --sidebar-active-bg: rgba(0, 174, 239, 0.18);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.12);
}

/* 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(0, 174, 239, 0.07), transparent 38%),
        radial-gradient(circle at bottom right, rgba(0, 54, 80, 0.06), transparent 42%),
        var(--bg);
    color: var(--text);
    font-family: "Cairo", 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.92) !important;
    border-bottom: 1px solid rgba(0, 54, 80, 0.1) !important;
}

.navbar-brand {
    letter-spacing: 0;
    color: var(--text) !important;
    font-weight: 700;
}

.navbar-brand img {
    width: auto;
    max-width: 142px;
    object-fit: contain;
}

.app-main-nav {
    gap: 4px;
}

.app-main-nav .nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px !important;
    border-radius: 8px;
    color: #334e5f;
}

.app-main-nav .nav-link:hover,
.app-main-nav .nav-link.active {
    background: var(--brand-soft);
    color: var(--primary) !important;
}

.dropdown-menu {
    border-radius: 8px !important;
    border: 1px solid rgba(0, 54, 80, 0.08) !important;
}

.dropdown-item {
    border-radius: 6px;
    margin: 2px 6px;
    width: calc(100% - 12px);
    font-weight: 600;
}

.dropdown-item.active,
.dropdown-item:active,
.dropdown-item:hover {
    background: var(--brand-soft);
    color: var(--primary);
}

.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, var(--brand-soft) 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;
}

.landing-page {
    --landing-ink: var(--primary);
    --landing-soft: var(--brand-soft);
}

.landing-page .landing-hero {
    min-height: 540px;
    border: 0;
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(231, 246, 252, 0.95), rgba(255, 255, 255, 0.98)),
        var(--surface);
    box-shadow: var(--shadow-strong);
}

.landing-page .hero-content {
    padding: 72px 52px;
}

.landing-page .hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(0, 174, 239, 0.12);
    color: var(--primary);
    font-weight: 800;
    font-size: 0.92rem;
}

.landing-page .hero-title {
    max-width: 620px;
    color: var(--landing-ink);
    font-size: 3.1rem;
    line-height: 1.16;
    font-weight: 800;
}

.landing-page .hero-subtitle {
    max-width: 600px;
    font-size: 1.16rem;
    line-height: 1.85;
}

.landing-page .hero-actions .btn {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.landing-page .hero-proof {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.landing-page .hero-proof span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #334155;
    font-size: 0.92rem;
    font-weight: 700;
}

.landing-page .hero-proof i {
    color: var(--primary);
}

.landing-page .hero-img-container {
    position: relative;
    min-height: 540px;
    border-radius: 0;
    isolation: isolate;
}

.landing-page .hero-img-container::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.4)),
        linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 45%);
    pointer-events: none;
}

.landing-page .hero-metric-strip {
    position: absolute;
    inset-inline: 28px;
    bottom: 28px;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.landing-page .hero-metric-strip div {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    backdrop-filter: blur(12px);
}

.landing-page .hero-metric-strip strong {
    display: block;
    font-size: 1.6rem;
    line-height: 1;
    font-weight: 800;
}

.landing-page .hero-metric-strip span {
    display: block;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.9rem;
}

.landing-page .landing-stats .stat-card,
.landing-page section .panel {
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.07);
}

.landing-page .rounded-4 {
    border-radius: 8px !important;
}

.landing-page .landing-stats .stat-card {
    position: relative;
    min-height: 155px;
    padding: 26px 24px;
    overflow: hidden;
}

.landing-page .landing-stats .stat-card::after {
    content: "";
    position: absolute;
    inset-inline-end: -28px;
    top: -28px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(0, 174, 239, 0.12);
}

.landing-page .stat-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--landing-soft);
    color: var(--primary);
    font-size: 1.25rem;
}

.landing-page .feature-icon {
    border-radius: 8px;
    background: rgba(0, 174, 239, 0.12);
}

.landing-page .motivation-box {
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(0, 54, 80, 0.92), rgba(0, 97, 141, 0.88)),
        var(--primary);
    box-shadow: var(--shadow-strong);
}

.landing-page .table thead th {
    letter-spacing: 0;
}

.motivation-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--brand-mid) 100%);
    color: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 54, 80, 0.18);
}

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

.feature-icon {
    width: 60px;
    height: 60px;
    background: var(--brand-soft);
    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;
    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);
}

[data-theme="dark"] .landing-page {
    --landing-ink: var(--text);
    --landing-soft: rgba(96, 165, 250, 0.14);
}

[data-theme="dark"] .landing-page .landing-hero,
[data-theme="dark"] .landing-page .hero-proof span {
    background: rgba(30, 41, 59, 0.96);
}

[data-theme="dark"] .landing-page .hero-proof span {
    color: var(--text);
    border-color: var(--border);
}

.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(0, 174, 239, 0.13);
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--brand-mid));
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 54, 80, 0.22);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 54, 80, 0.28);
}

.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 */
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 14px;
}

.admin-brand img,
.admin-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
    flex: 0 0 auto;
}

.admin-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
}

.admin-brand strong,
.admin-brand span {
    display: block;
    line-height: 1.2;
}

.admin-brand strong {
    font-size: 1rem;
    letter-spacing: 0;
}

.admin-brand span {
    color: var(--sidebar-muted);
    font-size: 0.82rem;
    margin-top: 2px;
}

/* 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;
    }

    .landing-page .landing-hero {
        min-height: auto;
    }

    .landing-page .hero-content {
        padding: 36px 24px;
    }

    .landing-page .hero-title {
        font-size: 2.15rem;
        line-height: 1.25;
    }

    .landing-page .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-img-container {
        min-height: 250px;
        margin-top: 20px;
    }

    .landing-page .hero-img-container {
        min-height: 320px;
        margin-top: 0;
    }

    .landing-page .hero-metric-strip {
        inset-inline: 16px;
        bottom: 16px;
    }

    .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;
    }
}
