/* Main Stylesheet for Delivery Management System */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Cairo:wght@400;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Refined Color Palette */
    --primary: #C9A35F;
    --primary-light: #D9BC84;
    --primary-dark: #A88445;
    --secondary: #011A41;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;

    /* Neutrals */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #020617;
    --text-muted: #334155;
    --border-color: #e8ddca;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 10px -1px rgb(0 0 0 / 0.15), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.2), 0 8px 10px -6px rgb(0 0 0 / 0.2);
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Sidebar */
    --sidebar-w: 280px;
    --sidebar-bg: #0a0a0b;
    --topbar-h: 70px;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Logged-in shell: page fills viewport; sidebar & main each scroll on its own (no one scroll for both) */
html:has(.app-wrapper) {
    height: 100%;
}
body:has(.app-wrapper) {
    min-height: 100dvh;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin: 0;
    overflow: hidden;
}
body:has(.app-wrapper) > footer {
    flex-shrink: 0;
}

[dir="rtl"] .app-wrapper {
    flex-direction: row-reverse;
}

/* Sidebar Layout */
.app-wrapper {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    align-items: stretch;
    width: 100%;
}

.sidebar {
    --sidebar-tint: rgba(201, 163, 95, 0.07);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background:
        linear-gradient(170deg, rgba(201, 163, 95, 0.09) 0%, transparent 38%),
        linear-gradient(180deg, #101012 0%, #0a0a0b 50%, #0c0b09 100%);
    color: #e3d4bc;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    flex-shrink: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    border: none;
    border-inline-end: 1px solid rgba(201, 163, 95, 0.24);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.2);
    border-radius: 0 18px 18px 0;
    z-index: 2;
    position: relative;
}

[dir="rtl"] .sidebar {
    border-radius: 18px 0 0 18px;
    box-shadow: -6px 0 28px rgba(0, 0, 0, 0.2);
}

.sidebar > .sidebar-menu {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(201, 163, 95, 0.35) transparent;
}
.sidebar > .sidebar-menu::-webkit-scrollbar {
    width: 5px;
}
.sidebar > .sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(201, 163, 95, 0.35);
    border-radius: 4px;
}

/* Inside main: dim content when the drawer is open. Below top bar; above .content-body. */
.sidebar-scrim {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: rgba(5, 4, 2, 0.48);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s;
}
@media (max-width: 991px) {
    .sidebar-scrim {
        display: block;
    }
    .sidebar-scrim.is-visible {
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
    }
}
@media (min-width: 992px) {
    .sidebar-scrim {
        display: none !important;
    }
}

.sidebar-header {
    padding: 1.25rem 1rem 1.1rem;
    text-align: center;
    border-bottom: 1px solid rgba(201, 163, 95, 0.18);
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(201, 163, 95, 0.06) 0%, transparent 100%);
}

.sidebar-brand {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Decorative square only for text-based brand (no logo image) */
.sidebar-brand:not(.sidebar-brand--image)::before {
    content: '';
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 8px;
    display: inline-block;
}

.sidebar-brand--image::before {
    content: none;
    display: none;
}

.sidebar-brand--image {
    display: block;
    line-height: 0;
    padding: 0.2rem 0.25rem;
    border-radius: 12px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar-brand--image:hover {
    background: rgba(201, 163, 95, 0.1);
}

.sidebar-brand--image .sidebar-brand__logo {
    max-height: 52px;
    width: auto;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px 24px;
    margin: 0;
}

.sidebar-menu li {
    margin-bottom: 3px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px 11px 12px;
    color: rgba(245, 230, 205, 0.88);
    text-decoration: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 12px;
    border: 1px solid transparent;
}

/* Notification count (always visible, including 0) */
.sidebar-menu a .sidebar-badge {
    margin-inline-start: auto;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 6px;
    border-radius: 999px;
    background: #ffffff;
    color: #111111;
    font-size: 0.65rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-menu a:hover {
    background-color: rgba(201, 163, 95, 0.14);
    color: #fff;
    border-color: rgba(201, 163, 95, 0.2);
}

.sidebar-menu li.active > a {
    background: linear-gradient(135deg, #d9b876 0%, var(--primary) 45%, #a88445 100%);
    color: #111;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 6px 18px rgba(201, 163, 95, 0.28);
}

.sidebar-menu a .menu-arrow {
    margin-inline-start: auto;
    flex-shrink: 0;
    font-size: 0.7rem;
    opacity: 0.75;
}

.sidebar-menu i {
    width: 22px;
    flex-shrink: 0;
    font-size: 1.05rem;
    text-align: center;
    opacity: 0.8;
    color: var(--primary-light);
}

.sidebar-menu a:hover i {
    color: #fff;
    opacity: 1;
}

.sidebar-menu li.active > a i {
    color: #111;
    opacity: 1;
}

/* Sub-menu Styles */
.has-submenu > .submenu {
    display: none;
    list-style: none;
    margin: 6px 0 8px;
    padding: 4px 0 4px 10px;
    border-inline-start: 2px solid rgba(201, 163, 95, 0.35);
}

.has-submenu.open > .submenu {
    display: block;
}

.submenu a {
    padding: 7px 12px 7px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.92;
    color: rgba(220, 200, 165, 0.85);
    border: none;
}

.submenu a:hover {
    opacity: 1;
    background: rgba(201, 163, 95, 0.1);
    color: #fff;
}

/* Content Area */
.main-wrapper {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
    z-index: 0;
    background: var(--bg-main);
}

.top-navbar {
    height: 70px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
}

.content-body {
    position: relative;
    z-index: 1;
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Main UI Components */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 24px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 0.875rem;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary,
.btn:not(.btn-outline):not(.btn-danger) {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover,
.btn:not(.btn-outline):not(.btn-danger):hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(53, 94, 252, 0.2);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-main);
    border-color: var(--secondary);
    color: var(--primary-dark);
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background-color: #fff;
    color: var(--text-main);
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.938rem;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(53, 94, 252, 0.12);
}

/* Alerts */
.alert {
    padding: 16px 20px;
    margin-bottom: 24px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-danger {
    color: #991b1b;
    background-color: #fef2f2;
    border-color: #fee2e2;
}

.alert-success {
    color: #065f46;
    background-color: #ecfdf5;
    border-color: #d1fae5;
}

/* Action Utilities & Badges */
.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Custom Grid */
.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

[class*="col-"] {
    grid-column: span 12;
}

@media (min-width: 768px) {
    .col-md-3 {
        grid-column: span 3;
    }

    .col-md-4 {
        grid-column: span 4;
    }

    .col-md-6 {
        grid-column: span 6;
    }

    .col-md-8 {
        grid-column: span 8;
    }

    .col-md-12 {
        grid-column: span 12;
    }
}

/* Stats Dashboard Enhancements */
.stat-card {
    padding: 32px;
    border-radius: var(--radius-lg);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.stat-icon {
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 5rem;
    opacity: 0.25;
    transform: rotate(-15deg);
    color: #fff;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 4px;
    color: #fff;
}

.stat-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.813rem;
    opacity: 0.95;
    color: #fff;
}

/* Dashboard Action Tiles */
.dashboard-tile {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px 24px;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    color: #fff !important;
    min-height: 200px !important;
    width: 100%;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1;
}

.dashboard-tile:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.dashboard-tile i {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 1;
    display: block;
}

.dashboard-tile span {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    display: block;
    margin-bottom: 8px;
    line-height: 1.2;
}

.dashboard-tile small {
    display: block;
    font-size: 0.875rem;
    opacity: 0.8;
    font-weight: 500;
}

/* Login Page Revamp */
.login-body {
    /* Match public site palette while keeping white page background */
    --login-primary: #355EFC;
    --login-primary-dark: #2348d8;
    --login-light: #DFE4FD;
    --login-dark: #011A41;
    --login-muted: #555555;
    --login-border: #d9e1ff;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid var(--login-border);
}

.login-header {
    padding: 48px 40px 32px;
    text-align: center;
}

.login-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -1px;
}

.login-content {
    padding: 0 40px 48px;
}

.login-body .text-muted {
    color: var(--login-muted) !important;
}

.login-body .form-group label {
    color: var(--login-dark);
}

.login-body .form-control {
    border-color: var(--login-border);
}

.login-body .form-control:focus {
    border-color: var(--login-primary);
    box-shadow: 0 0 0 4px rgba(53, 94, 252, 0.14);
}

.login-body .btn-primary,
.login-body .btn:not(.btn-outline):not(.btn-danger) {
    background-color: var(--login-primary);
    color: #fff;
}

.login-body .btn-primary:hover,
.login-body .btn:not(.btn-outline):not(.btn-danger):hover {
    background-color: var(--login-primary-dark);
    box-shadow: 0 6px 16px rgba(53, 94, 252, 0.28);
}

/* Utils */
.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mb-5 {
    margin-bottom: 3rem !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mt-5 {
    margin-top: 3rem !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.welcome-section {
    padding-bottom: 24px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
}

.h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.h5 {
    font-size: 1.25rem;
    font-weight: 600;
}

.text-sm {
    font-size: 0.875rem;
}

.text-gray-500 {
    color: #9ca3af !important;
}

.g-4 {
    margin-right: -1rem;
    margin-left: -1rem;
}

.g-4>[class*="col-"] {
    padding-right: 1rem;
    padding-left: 1rem;
}

/* Action Buttons & Utilities */
.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #4b5563;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 100px;
    padding: 16px;
    border-radius: 12px;
}

.action-btn:hover {
    background: white;
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    color: var(--primary-color);
}

.action-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: white;
    font-size: 1.25rem;
}

.bg-primary {
    background-color: #4361ee !important;
}

.bg-success {
    background-color: #4cc9f0 !important;
}

.bg-info {
    background-color: #4895ef !important;
}

.bg-warning {
    background-color: #ff9f1c !important;
}

.bg-secondary {
    background-color: #3f37c9 !important;
}

.text-dark {
    color: #1f2937 !important;
}

/* Responsive: narrow content */
@media (max-width: 768px) {
    .content-body {
        padding: 20px;
    }
}

/* Mobile / tablet: off-canvas drawer, RTL from the correct edge */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        z-index: 1000;
        max-height: 100dvh;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    html:not([dir="rtl"]) .sidebar {
        left: calc(-1 * (var(--sidebar-w) + 1px));
        right: auto;
    }
    [dir="rtl"] .sidebar {
        right: calc(-1 * (var(--sidebar-w) + 1px));
        left: auto;
    }

    html:not([dir="rtl"]) .sidebar.open {
        left: 0;
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
    }
    [dir="rtl"] .sidebar.open {
        right: 0;
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
    }

    .sidebar-toggle {
        display: block;
    }

    .navbar {
        padding: 0 15px;
    }

    .nav-links {
        gap: 15px;
    }
}

/* RTL Support */
[dir="rtl"] {
    font-family: 'Cairo', 'Tajawal', sans-serif;
}
[dir="rtl"] .has-submenu > .submenu {
    padding: 4px 10px 4px 0;
}
[dir="rtl"] .ms-2 {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}
[dir="rtl"] .me-2 {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}
[dir="rtl"] .text-end {
    text-align: left !important;
}

/* Language Dropdown */
.lang-dropdown {
    position: relative;
    display: inline-block;
}
.lang-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #fff;
    min-width: 120px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1);
    z-index: 1000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
[dir="rtl"] .lang-dropdown-content {
    right: auto;
    left: 0;
}
.lang-dropdown:hover .lang-dropdown-content {
    display: block;
}
.lang-dropdown-content a {
    color: var(--text-main);
    padding: 10px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.875rem;
    transition: background 0.2s;
}
.lang-dropdown-content a:hover, .lang-dropdown-content a.active {
    background-color: var(--bg-main);
    color: var(--primary);
}
.lang-btn {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Role badge (top bar) + page polish */
.role-pill {
    display: inline-block;
    font-size: 0.65rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
}
.role-pill-admin { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.role-pill-client { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; }
.role-pill-driver { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; }

.page-hero {
    margin-bottom: 1.75rem;
}
.page-hero h1, .page-hero .page-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.03em;
    margin: 0 0 6px 0;
}
.page-hero p, .page-hero .page-sub {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.content-body > .card:first-child {
    margin-top: 0;
}