/**
 * LPG Delivery System v2 - Custom Application Stylesheet
 * Integrates with Bootstrap 5.3.3 tokens and component architecture.
 */

:root {
    --app-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --app-primary: #0d9488;
    --app-primary-dark: #0f766e;
    --app-primary-light: #f0fdfa;
    --app-flame: #f97316;
    --app-flame-light: #fff7ed;
    --app-bg-body: #f8fafc;
    --app-surface: #ffffff;
    --app-border: #e2e8f0;
    --app-text-main: #1e293b;
    --app-text-muted: #64748b;
    --app-sidebar-width: 260px;
    --app-header-height: 60px;
}

/* =========================================================================
   Dark Mode Theme
   ========================================================================= */

[data-theme="dark"] {
    --app-primary: #14b8a6;
    --app-primary-dark: #0d9488;
    --app-primary-light: #042f2e;
    --app-flame: #fb923c;
    --app-flame-light: #1c1008;
    --app-bg-body: #0f172a;
    --app-surface: #1e293b;
    --app-border: #334155;
    --app-text-main: #f1f5f9;
    --app-text-muted: #94a3b8;
    --app-glass-bg: rgba(30, 41, 59, 0.85);
    --app-glass-border: rgba(255, 255, 255, 0.08);
    --app-gradient-primary: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
    --app-gradient-warm: linear-gradient(135deg, #fb923c 0%, #fbbf24 100%);
    --app-shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --app-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
    --app-shadow-glow-primary: 0 0 20px rgba(20, 184, 166, 0.3);
}

/* =========================================================================
   1. Base & Layout
   ========================================================================= */

body.app-body {
    font-family: var(--app-font-sans);
    background-color: #f0fdfa;
    background-image:
        radial-gradient(640px 320px at 8% -6%, rgba(13, 148, 136, 0.12), transparent 60%),
        radial-gradient(560px 300px at 92% -4%, rgba(45, 212, 191, 0.14), transparent 60%),
        radial-gradient(820px 460px at 50% 115%, rgba(13, 148, 136, 0.08), transparent 60%),
        linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 50%, #f0fdfa 100%);
    background-attachment: fixed;
    color: var(--app-text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle dot texture over the dashboard background (light) */
body.app-body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(15, 23, 42, 0.07) 1px, transparent 1px);
    background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 75%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 75%);
}

.extra-small {
    font-size: 0.75rem;
}

/* App Navbar */
.app-navbar {
    min-height: var(--app-header-height);
    background-color: #0f172a !important;
    z-index: 1030;
}

.app-logo-badge {
    width: 44px;
    height: 44px;
}

/* User Avatar Initial Circle */
.user-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--app-primary);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Larger avatar inside the top navigation bar */
.app-navbar .user-avatar-circle {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

/* Uploaded photo version of the navbar avatar */
.navbar-avatar-img {
    width: 44px;
    height: 44px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

/* Perfect-circle guards: fixed-size round elements must never stretch */
.user-avatar-circle,
.stat-icon-wrapper {
    flex-shrink: 0;
}
/* Initial-letter fallback avatar at profile size (beats the 36px base rule) */
.user-avatar-circle.profile-avatar-lg {
    width: 130px;
    height: 130px;
    aspect-ratio: 1 / 1;
}
@media (max-width: 575.98px) {
    .user-avatar-circle.profile-avatar-lg {
        width: 110px;
        height: 110px;
    }
}
img.rounded-circle {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
div.rounded-circle.d-flex,
div.rounded-circle.d-inline-flex {
    flex-shrink: 0;
}

/* Large profile picture on profile pages.
   Fixed square box: any uploaded image is center-cropped into a perfect
   circle without ever changing the layout height/width. */
.profile-avatar-lg {
    display: block;
    width: 130px;
    height: 130px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: center;
    margin-inline: auto;
    flex-shrink: 0;
    max-width: none;
}

/* Responsive adjustments for small screens */
@media (max-width: 575.98px) {
    .profile-avatar-lg {
        width: 110px;
        height: 110px;
    }

    .app-logo-badge {
        width: 34px;
        height: 34px;
    }

    .app-navbar .user-avatar-circle {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .navbar-avatar-img {
        width: 36px;
        height: 36px;
    }
}

/* Layout Split */
.app-layout {
    min-height: calc(100vh - var(--app-header-height));
    position: relative;
}

.app-main-wrapper {
    min-width: 0;
    background: transparent;
}

.app-main {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    /* NOTE: position WITHOUT z-index on purpose. Adding z-index here creates
       a stacking context that traps page-level Bootstrap modals (rendered
       inside <main>) UNDER the modal-backdrop, making them uneditable. */
    position: relative;
}

/* =========================================================================
   2. Sidebar Navigation
   ========================================================================= */

.app-sidebar {
    position: sticky;
    top: var(--app-header-height);
    bottom: 0;
    width: var(--app-sidebar-width);
    flex-shrink: 0;
    background-color: var(--app-surface);
    border-right: 1px solid var(--app-border);
    z-index: 1025;
    height: calc(100vh - var(--app-header-height));
}

.app-sidebar-inner {
    position: sticky;
    top: var(--app-header-height);
    height: calc(100vh - var(--app-header-height));
}

.app-sidebar .nav-link {
    color: var(--app-text-muted);
    font-weight: 500;
    font-size: 0.925rem;
    border-radius: 0.5rem;
    padding: 0.65rem 0.9rem;
    transition: all 0.15s ease-in-out;
    border-left: 3px solid transparent;
}

.app-sidebar .nav-link:hover {
    color: var(--app-text-main);
    background-color: #f1f5f9;
}

.app-sidebar .nav-link.active {
    color: var(--app-primary);
    background-color: var(--app-primary-light);
    font-weight: 600;
    border-left: 3px solid var(--app-primary);
}

.app-sidebar .nav-link i {
    width: 24px;
    text-align: center;
}

/* Mobile Sidebar Drawer — transform-based slide (GPU-accelerated, no layout thrash) */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: var(--app-header-height);
        left: 0;
        bottom: 0;
        width: var(--app-sidebar-width);
        height: auto;
        box-shadow: none;
        transform: translateX(-105%);
        transition: transform 0.25s ease-out;
        will-change: transform;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    }

    /* Lock background scroll while drawer is open (prevents jank) */
    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar-backdrop {
        position: fixed;
        top: var(--app-header-height);
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(15, 23, 42, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease-out;
        will-change: opacity;
        z-index: 1020;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Responsive Map Heights */
@media (max-width: 575.98px) {
    .order-live-map { height: 220px !important; }
    .order-detail-map { height: 250px !important; }
    .admin-live-map { height: 260px !important; }
    .address-preview-map { height: 180px !important; }
    .app-product-img-wrapper { height: 150px; }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .order-live-map { height: 250px !important; }
    .order-detail-map { height: 280px !important; }
    .admin-live-map { height: 300px !important; }
}

/* Responsive page header buttons */
@media (max-width: 575.98px) {
    .page-header-actions { flex-wrap: wrap; }
    .page-header-actions .btn { flex: 1 1 auto; min-width: 0; }
}

/* =========================================================================
   3. Status Badges
   ========================================================================= */

.app-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.4em 0.75em;
    border-radius: 9999px;
    text-transform: uppercase;
}

.badge-status-pending_payment {
    background-color: #fef9c3 !important;
    color: #a16207 !important;
    border: 1px solid #fef08a;
}

.badge-status-pending {
    background-color: #fef3c7 !important;
    color: #92400e !important;
    border: 1px solid #fde68a;
}

.badge-status-approved {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
    border: 1px solid #bae6fd;
}

.badge-status-ready_for_delivery {
    background-color: #ccfbf1 !important;
    color: #115e59 !important;
    border: 1px solid #99f6e4;
}

.badge-status-picked_up {
    background-color: #ede9fe !important;
    color: #5b21b6 !important;
    border: 1px solid #ddd6fe;
}

.badge-status-out_for_delivery {
    background-color: #ffedd5 !important;
    color: #9a3412 !important;
    border: 1px solid #fed7aa;
}

.badge-status-delivered {
    background-color: #dcfce7 !important;
    color: #166534 !important;
    border: 1px solid #bbf7d0;
}

.badge-status-cancelled {
    background-color: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #fecaca;
}

/* =========================================================================
   4. Stat Cards & Dashboards
   ========================================================================= */

.app-stat-card {
    background-color: var(--app-surface);
    border-radius: 0.75rem;
    border: 1px solid var(--app-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.app-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.05);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* =========================================================================
   5. Product Catalog Cards
   ========================================================================= */

.app-product-card {
    border-radius: 0.75rem;
    border: 1px solid var(--app-border);
    background-color: var(--app-surface);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.app-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
}

.app-product-img-wrapper {
    height: 180px;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.app-product-img-wrapper img {
    max-height: 140px;
    max-width: 80%;
    object-fit: contain;
}

.app-product-card .card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 1.8em;
}

/* =========================================================================
   6. Order Cards & Timelines
   ========================================================================= */

.app-order-card {
    border-radius: 0.75rem;
    border: 1px solid var(--app-border);
    background-color: var(--app-surface);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-clickable-card {
    cursor: pointer;
    text-decoration: none !important;
    color: inherit !important;
    display: block;
}

.app-clickable-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.app-clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.app-clickable-row:hover > td {
    background-color: #f1f5f9 !important;
}

.app-product-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Stepper / Timeline */
.app-order-timeline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin: 1.5rem 0;
}

.app-order-timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    height: 3px;
    background-color: var(--app-border);
    transform: translateY(-50%);
    z-index: 1;
}

.timeline-step {
    position: relative;
    z-index: 2;
    background: var(--app-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 0.5rem;
}

.timeline-step-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--app-surface);
    border: 2px solid var(--app-border);
    color: var(--app-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.timeline-step.completed .timeline-step-icon {
    background-color: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

.timeline-step.active .timeline-step-icon {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.2);
}

.timeline-step-label {
    font-size: 0.75rem;
    color: var(--app-text-muted);
    margin-top: 0.35rem;
    font-weight: 500;
}

.timeline-step.active .timeline-step-label {
    color: var(--app-primary);
    font-weight: 600;
}

/* Mobile Compact Horizontal Timeline — stays in ONE row on phones so the
   6-step tracker takes ~90px of height instead of ~400px stacked vertically.
   Icons + labels shrink, labels wrap to max 2 lines centered under the dot. */
@media (max-width: 767.98px) {
    .app-order-timeline {
        flex-direction: row;
        align-items: flex-start;
        gap: 0;
        margin: 1.75rem 0 0.75rem;
        overflow: visible;
    }

    .app-order-timeline::before {
        top: 15px;
        bottom: auto;
        left: 18px;
        right: 18px;
        width: auto;
        height: 3px;
        transform: none;
    }

    .timeline-step {
        flex: 1 1 0;
        min-width: 0;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0 2px;
        width: auto;
        background: transparent;
    }

    .timeline-step-icon {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .timeline-step-label {
        margin-top: 0.3rem;
        margin-left: 0;
        font-size: 0.6rem;
        line-height: 1.25;
        word-break: break-word;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    /* Dim upcoming steps so progress reads at a glance */
    .timeline-step:not(.completed):not(.active) {
        opacity: 0.65;
    }
}

/* Ultra-narrow phones (≤380px) — squeeze a little more */
@media (max-width: 380px) {
    .app-order-timeline::before {
        left: 14px;
        right: 14px;
    }
    .timeline-step-icon {
        width: 27px;
        height: 27px;
        font-size: 0.72rem;
    }
    .timeline-step-label {
        font-size: 0.56rem;
    }
}

/* =========================================================================
   Order Journey — illustrated rider progress (Placed → Delivered)
   A small rider marker rides the track to the current stage.
   ========================================================================= */

/* Traveled-portion fill over the gray track (progress set via --p: 0..1) */
.app-order-timeline .timeline-progress-fill {
    position: absolute;
    top: 50%;
    left: 20px;
    height: 3px;
    width: calc((100% - 40px) * var(--p, 0));
    max-width: calc(100% - 40px);
    background: linear-gradient(90deg, #0d9488, #14b8a6);
    border-radius: 2px;
    transform: translateY(-50%);
    z-index: 1;
    transition: width 0.5s ease;
}

/* Stage glyphs instead of plain numbers */
.timeline-step-icon {
    font-size: 1rem;
}

/* Riding marker bobbing above the current stage */
.timeline-rider {
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    border: 2px solid #ffffff;
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.45);
    z-index: 3;
    pointer-events: none;
    animation: riderBob 1.6s ease-in-out infinite;
}

@keyframes riderBob {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50%      { transform: translateX(-50%) translateY(-5px); }
}

/* Mobile compact horizontal timeline: track fill + rider stay horizontal,
   sized for the smaller 30px dots (track centered at 15px). */
@media (max-width: 767.98px) {
    .app-order-timeline .timeline-progress-fill {
        top: 15px;
        bottom: auto;
        left: 18px;
        right: auto;
        width: calc((100% - 36px) * var(--p, 0));
        max-width: calc(100% - 36px);
        height: 3px;
        max-height: none;
        transform: none;
    }

    .timeline-rider {
        top: -27px;
        left: 50%;
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
        transform: translateX(-50%);
        animation: riderBob 1.6s ease-in-out infinite;
    }
}

@media (max-width: 380px) {
    .app-order-timeline .timeline-progress-fill {
        left: 14px;
        width: calc((100% - 28px) * var(--p, 0));
        max-width: calc(100% - 28px);
    }
}

/* =========================================================================
   7. Form Controls, Tables & Utilities
   ========================================================================= */

.form-control:focus, .form-select:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 0.25rem rgba(13, 148, 136, 0.15);
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--app-text-muted);
    background-color: #f8fafc;
}

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

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
}

/* =========================================================================
   8. Live Delivery Tracking Map & Confirmation Modal
   ========================================================================= */

.order-live-map, .order-detail-map {
    height: 280px;
    width: 100%;
    border-radius: 0.75rem;
    border: 1px solid var(--app-border);
    z-index: 10;
}

.order-detail-map {
    height: 320px;
}

.live-pulse-dot {
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: livePulse 1.8s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes livePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.rider-marker-icon, .customer-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.rider-marker-icon {
    background-color: #0d9488;
    color: #ffffff;
    border: 2px solid #ffffff;
    font-size: 1.25rem;
}

.customer-marker-icon {
    background-color: #ef4444;
    color: #ffffff;
    border: 2px solid #ffffff;
    font-size: 1.25rem;
}

/* Confirmation Modal Center Icon Styling */
.modal-confirm-icon-box {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.85rem;
    margin-bottom: 1rem;
}

/* =========================================================================
   9. Live Camera Capture for ID Verification
   ========================================================================= */

.id-camera-container {
    min-height: 120px;
}

#cameraVideo {
    background-color: #000;
    border-radius: 0.5rem 0.5rem 0 0;
}

.nav-pills .nav-link {
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
    color: var(--app-text-muted);
    padding: 0.5rem 1rem;
    background-color: var(--app-surface);
    transition: all 0.2s ease;
}

.nav-pills .nav-link.active {
    background-color: var(--app-primary);
    color: #ffffff;
    border-color: var(--app-primary);
}

.nav-pills .nav-link:hover:not(.active) {
    background-color: #f1f5f9;
    color: var(--app-text-main);
}

#capturedImage {
    max-width: 100%;
    background-color: #f8fafc;
}

#cameraContainer .badge {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
}

/* =========================================================================
   10. Delivery Address Pin Location Map
   ========================================================================= */

.pin-location-map {
    height: 180px;
    width: 100%;
    border-radius: 0.5rem;
    z-index: 10;
}

@media (max-width: 575.98px) {
    .pin-location-map {
        height: 160px;
    }
}

/* Checkout address pin preview map */
.address-preview-map {
    height: 220px;
    width: 100%;
    z-index: 10;
}

/* Admin live rider tracking map */
.admin-live-map {
    height: 340px;
    width: 100%;
    border-radius: 0.75rem;
    border: 1px solid var(--app-border);
    z-index: 10;
}

/* =========================================================================
   11. Rider-Customer Chat Panel
   ========================================================================= */

.chat-offcanvas {
    width: 380px;
}

@media (max-width: 575.98px) {
    .chat-offcanvas {
        width: 100%;
    }
}

.chat-header {
    background: #fff;
}

.chat-messages {
    overflow-y: auto;
    background: #f8f9fa;
    min-height: 0;
    max-height: calc(100vh - 180px);
    scroll-behavior: smooth;
}

.chat-bubble {
    max-width: 80%;
    padding: 0.6rem 0.9rem;
    border-radius: 1rem;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9rem;
    position: relative;
}

.chat-bubble-sent {
    background: #0d9488;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.chat-bubble-received {
    background: #fff;
    color: #212529;
    border: 1px solid #dee2e6;
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
}

.chat-bubble-meta {
    font-size: 0.68rem;
    opacity: 0.7;
    margin-top: 0.2rem;
    text-align: right;
}

.chat-bubble-received .chat-bubble-meta {
    text-align: left;
}

.chat-sender-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.15rem;
    display: block;
}

.chat-bubble-sent .chat-sender-label {
    color: rgba(255, 255, 255, 0.8);
}

.chat-bubble-received .chat-sender-label {
    color: #0d9488;
}

.chat-input-area {
    background: #fff;
}

.chat-input-area .form-control {
    border-radius: 1.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.chat-input-area .btn {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-system-msg {
    text-align: center;
    color: #6c757d;
    font-size: 0.75rem;
    padding: 0.4rem 0;
}

.chat-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
}

.chat-empty-state i {
    font-size: 2.5rem;
    opacity: 0.4;
    display: block;
    margin-bottom: 0.75rem;
}

#chatUnreadBadge {
    font-size: 0.65rem;
    transform: translate(-50%, -50%) !important;
}

/* =========================================================================
   12. Customer Shop Page — sticky Order & Delivery Details (desktop).
   Products grid scrolls naturally; checkout card sticks in view so the
   customer never loses the Place Order button while browsing.
   ========================================================================= */

@media (min-width: 992px) {
    .shop-products-scroll {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }

    .shop-checkout-col {
        position: sticky;
        top: calc(var(--app-header-height) + 1rem);
        align-self: flex-start;
        z-index: 10;
    }

    .shop-checkout-card {
        max-height: calc(100vh - var(--app-header-height) - 2rem);
        display: flex;
        flex-direction: column;
    }

    .shop-checkout-card > .card-header {
        flex-shrink: 0;
    }

    .shop-checkout-card > .card-body {
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    /* Thin, subtle scrollbars for both panels */
    .shop-products-scroll::-webkit-scrollbar,
    .shop-checkout-card > .card-body::-webkit-scrollbar {
        width: 6px;
    }

    .shop-products-scroll::-webkit-scrollbar-thumb,
    .shop-checkout-card > .card-body::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.18);
        border-radius: 3px;
    }
}

/* Pulse highlight when a product is selected — works on mobile + desktop */
.shop-checkout-flash {
    animation: shopCheckoutFlash 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes shopCheckoutFlash {
    0%   { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.5); }
    35%  { box-shadow: 0 0 0 10px rgba(13, 148, 136, 0.25); }
    100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

/* =========================================================================
   13. Modern Design System — Gradients, Glass Morphism, Animations
   ========================================================================= */

:root {
    --app-gradient-primary: linear-gradient(135deg, #0d9488 0%, #06b6d4 100%);
    --app-gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --app-gradient-warm: linear-gradient(135deg, #f97316 0%, #f59e0b 100%);
    --app-gradient-success: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --app-gradient-danger: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    --app-gradient-info: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    --app-glass-bg: rgba(255, 255, 255, 0.72);
    --app-glass-border: rgba(255, 255, 255, 0.2);
    --app-glass-blur: blur(16px);
    --app-shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
    --app-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.12);
    --app-shadow-glow-primary: 0 0 20px rgba(13, 148, 136, 0.25);
    --app-transition-smooth: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* =========================================================================
   14. Page Load Fade-In Transition
   ========================================================================= */

.app-main {
    animation: fadeInMain 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* =========================================================================
   Post-Login Splash Screen
   ========================================================================= */
.app-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 50%, #14b8a6 100%);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.app-splash.fade-out {
    opacity: 0;
    visibility: hidden;
}

.app-splash-content {
    text-align: center;
}

.app-splash-logo {
    width: 88px;
    height: 88px;
    margin: 0 auto 1.25rem;
    background: rgba(255,255,255,0.15);
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: splashScaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               splashPulse 1.8s ease-in-out 0.6s infinite;
    opacity: 0;
    transform: scale(0.5);
}

.app-splash-logo i {
    font-size: 2.75rem;
    color: #fbbf24;
    filter: drop-shadow(0 2px 8px rgba(251, 191, 36, 0.4));
}

.app-splash-text {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    opacity: 0;
    transform: translateY(10px);
    animation: splashTextIn 0.5s ease 0.3s forwards;
}

.app-splash-bar {
    width: 120px;
    height: 3px;
    margin: 1.5rem auto 0;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

.app-splash-bar-fill {
    width: 0%;
    height: 100%;
    background: #fbbf24;
    border-radius: 3px;
    animation: splashBarFill 1.5s ease 0.4s forwards;
}

@keyframes splashScaleIn {
    to { opacity: 1; transform: scale(1); }
}

@keyframes splashPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.35); }
    50%      { box-shadow: 0 0 0 14px rgba(251, 191, 36, 0); }
}

@keyframes splashTextIn {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes splashBarFill {
    to { width: 100%; }
}

/* Hide main content animation while splash is active */
.app-splash ~ .app-layout .app-main {
    animation: none;
}

/* =========================================================================
   15. Enhanced Stat Cards — Glass Morphism & Hover
   ========================================================================= */

.app-stat-card {
    background: var(--app-glass-bg);
    backdrop-filter: var(--app-glass-blur);
    -webkit-backdrop-filter: var(--app-glass-blur);
    border: 1px solid var(--app-glass-border);
    border-radius: 1rem;
    transition: var(--app-transition-smooth);
    position: relative;
    overflow: hidden;
}

.app-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--app-gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--app-shadow-hover);
    border-color: rgba(13, 148, 136, 0.15);
}

.app-stat-card:hover::before {
    opacity: 1;
}

.stat-icon-wrapper {
    transition: var(--app-transition-smooth);
}

.app-stat-card:hover .stat-icon-wrapper {
    transform: scale(1.1);
}

/* =========================================================================
   16. Skeleton Loading Shimmer
   ========================================================================= */

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 0.5rem;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-text-sm {
    height: 10px;
    margin-bottom: 6px;
    width: 60%;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
    width: 50%;
}

.skeleton-rect {
    height: 120px;
    width: 100%;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

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

/* =========================================================================
   17. Animated Stat Counters
   ========================================================================= */

.stat-counter-value {
    display: inline-block;
    transition: opacity 0.3s ease;
}

.stat-counter-value.counting {
    opacity: 0.7;
}

/* =========================================================================
   18. Enhanced Product Cards
   ========================================================================= */

.app-product-card {
    border-radius: 1rem;
    border: 1px solid var(--app-border);
    background: var(--app-glass-bg);
    backdrop-filter: var(--app-glass-blur);
    -webkit-backdrop-filter: var(--app-glass-blur);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.app-product-card .card-body {
    transition: background-color 0.2s ease;
}

.app-product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--app-shadow-hover);
    border-color: rgba(13, 148, 136, 0.2);
}

.app-product-card:hover .app-product-img-wrapper img {
    transform: scale(1.06);
}

[data-theme="dark"] .app-product-card:hover {
    background-color: var(--app-surface) !important;
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.6), 0 0 16px 2px rgba(13, 148, 136, 0.2);
    border-color: rgba(13, 148, 136, 0.6);
}

[data-theme="dark"] .app-product-card:hover .app-product-img-wrapper {
    background-color: rgba(13, 148, 136, 0.06);
}

.app-product-selected {
    border-color: rgba(13, 148, 136, 0.35) !important;
    background-color: rgba(13, 148, 136, 0.06) !important;
}

[data-theme="dark"] .app-product-selected {
    background-color: rgba(13, 148, 136, 0.12) !important;
    border-color: rgba(13, 148, 136, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.4), 0 4px 16px rgba(13, 148, 136, 0.3) !important;
}

.app-product-img-wrapper {
    overflow: hidden;
    position: relative;
}

.app-product-img-wrapper img {
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-product-img-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.04) 100%);
    pointer-events: none;
}

/* =========================================================================
   19. Enhanced Order Cards & Clickable Cards
   ========================================================================= */

.app-order-card {
    border-radius: 1rem;
    border: 1px solid var(--app-border);
    background: var(--app-glass-bg);
    backdrop-filter: var(--app-glass-blur);
    -webkit-backdrop-filter: var(--app-glass-blur);
    transition: var(--app-transition-smooth);
}

.app-clickable-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--app-shadow-hover);
    border-color: rgba(13, 148, 136, 0.2);
}

/* =========================================================================
   20. Gradient Dashboard Banners
   ========================================================================= */

.app-banner-gradient {
    background: var(--app-gradient-primary) !important;
    position: relative;
    overflow: hidden;
    border: none;
}

.app-banner-gradient::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: floatBannerOrb 8s ease-in-out infinite;
}

.app-banner-dark {
    background: var(--app-gradient-dark) !important;
    position: relative;
    overflow: hidden;
    border: none;
}

.app-banner-dark::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: floatBannerOrb 10s ease-in-out infinite;
}

@keyframes floatBannerOrb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(-20px, 15px) scale(1.1); }
}

/* Banner info chips — glass pills that read as labels, NOT buttons */
.banner-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    border-radius: 50rem;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: default;
    user-select: none;
    white-space: nowrap;
}
.banner-chip i {
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0.95;
}
.banner-chip-success i { color: #a7f3d0; }
.banner-chip-primary i { color: #bae6fd; }

/* Compact page banner — slim single-row header (good size, not oversized) */
.banner-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.app-banner-compact .card-body { padding: 0.8rem 1rem !important; }
.app-banner-compact h5 { font-size: 1.05rem; }
.app-banner-compact .banner-sub { font-size: 0.78rem; }
.app-banner-compact.app-banner-gradient::after {
    width: 220px;
    height: 220px;
    top: -70%;
    right: -5%;
}
.app-banner-compact.app-banner-dark::after {
    width: 220px;
    height: 220px;
    top: -70%;
    right: -5%;
}

/* =========================================================================
   21. Enhanced Buttons — Gradient, Scale, Ripple
   ========================================================================= */

.btn {
    transition: var(--app-transition-smooth);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--app-gradient-primary);
    border: none;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0f766e 0%, #0891b2 100%);
    box-shadow: 0 4px 16px rgba(13, 148, 136, 0.4);
    transform: translateY(-1px);
}

.btn-primary:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 148, 136, 0.35), 0 4px 16px rgba(13, 148, 136, 0.3);
}

.btn-success {
    background: var(--app-gradient-success);
    border: none;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.4);
    transform: translateY(-1px);
}

.btn-warning {
    background: var(--app-gradient-warm);
    border: none;
    color: #fff;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.btn-warning:hover {
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-danger {
    background: var(--app-gradient-danger);
    border: none;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
    transform: translateY(-1px);
}

.btn-loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading .btn-text {
    opacity: 0;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

/* =========================================================================
   22. Enhanced Form Controls — Floating Labels & Focus
   ========================================================================= */

.form-control, .form-select {
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    border-radius: 0.5rem;
}

.form-control:focus, .form-select:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.input-group .form-control:focus {
    z-index: 3;
}

.input-group-text {
    transition: background-color 0.25s ease, color 0.25s ease;
    border-radius: 0.5rem;
}

.form-control:focus ~ .input-group-text,
.form-control:focus + .input-group-text {
    color: var(--app-primary);
}

/* Validation shake animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

.form-shake {
    animation: shake 0.4s ease;
}

.is-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

/* Success validation checkmark */
.form-check-success {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12) !important;
}

/* =========================================================================
   23. Sidebar Enhanced — Gradient Active & Hover
   ========================================================================= */

.app-sidebar .nav-link {
    position: relative;
    border-radius: 0.625rem;
    border-left: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--app-gradient-primary);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar .nav-link:hover {
    background-color: rgba(13, 148, 136, 0.06);
    color: var(--app-primary);
    transform: translateX(4px);
}

.app-sidebar .nav-link.active {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(6, 182, 212, 0.06) 100%);
    color: var(--app-primary);
    font-weight: 600;
    border-left: none;
}

.app-sidebar .nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.app-sidebar .nav-link.active .bi {
    animation: iconPulse 0.4s ease;
}

@keyframes iconPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* =========================================================================
   24. Enhanced Toast Notifications
   ========================================================================= */

.toast {
    border-radius: 0.75rem !important;
    overflow: hidden;
    animation: toastSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: none !important;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast .toast-header {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.toast-progress-bar {
    height: 3px;
    background: var(--app-gradient-primary);
    position: absolute;
    bottom: 0;
    left: 0;
    border-radius: 0 0 0.75rem 0.75rem;
    animation: toastProgress 4.5s linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

.toast-success { border-left: 4px solid #10b981 !important; }
.toast-danger  { border-left: 4px solid #ef4444 !important; }
.toast-warning { border-left: 4px solid #f59e0b !important; }
.toast-info    { border-left: 4px solid #0d9488 !important; }

/* =========================================================================
   25. Status Badge Glow Effects
   ========================================================================= */

.app-status-badge {
    position: relative;
    transition: var(--app-transition-smooth);
}

.badge-status-pending     { box-shadow: 0 0 8px rgba(245, 158, 11, 0.2); }
.badge-status-approved    { box-shadow: 0 0 8px rgba(3, 105, 161, 0.2); }
.badge-status-ready_for_delivery { box-shadow: 0 0 8px rgba(30, 64, 175, 0.2); }
.badge-status-picked_up   { box-shadow: 0 0 8px rgba(91, 33, 182, 0.2); }
.badge-status-out_for_delivery { box-shadow: 0 0 8px rgba(154, 52, 18, 0.2); }
.badge-status-delivered   { box-shadow: 0 0 8px rgba(22, 101, 52, 0.2); }
.badge-status-cancelled   { box-shadow: 0 0 8px rgba(153, 27, 27, 0.2); }

/* =========================================================================
   26. Timeline Stepper Pulse Animation
   ========================================================================= */

.timeline-step.active .timeline-step-icon {
    animation: timelinePulse 2s ease-in-out infinite;
}

@keyframes timelinePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(13, 148, 136, 0); }
}

.timeline-step.completed .timeline-step-icon {
    animation: timelineCheck 0.3s ease;
}

@keyframes timelineCheck {
    0%   { transform: scale(0.8); }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* =========================================================================
   27. Login Page — Full-Screen Gradient Background
   ========================================================================= */

.auth-login-page {
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--app-bg-body, #f8f9fa);
    position: relative;
    overflow: hidden;
    margin-top: auto;
}

.auth-login-page::before,
.auth-login-page::after {
    display: none;
}

.auth-login-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 440px;
}

.auth-brand-logo {
    width: 80px;
    height: 80px;
    background: var(--app-gradient-primary);
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 16px rgba(13, 148, 136, 0.3);
}


.auth-card {
    border-radius: 1.25rem;
    border: none;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    width: 100%;
    background: #fff;
    animation: authCardIn 0.5s ease-out;
}

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

.auth-card .form-control,
.auth-card .form-select {
    border-radius: 0.625rem;
    padding: 0.7rem 1rem;
    border-color: #e2e8f0;
}

.auth-card .form-control:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.auth-card .btn-primary {
    padding: 0.7rem;
    font-size: 1rem;
    border-radius: 0.625rem;
}

@media (max-width: 575.98px) {
    .auth-login-page {
        padding: 1rem 0.75rem;
        justify-content: flex-start;
        padding-top: 3rem;
    }
    .auth-brand-logo {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }
    .auth-card {
        border-radius: 1rem;
    }
}

/* =========================================================================
   28. Glass Card Utility
   ========================================================================= */

.glass-card {
    background: var(--app-glass-bg);
    backdrop-filter: var(--app-glass-blur);
    -webkit-backdrop-filter: var(--app-glass-blur);
    border: 1px solid var(--app-glass-border);
    border-radius: 1rem;
}

/* =========================================================================
   30. Navbar Enhancements
   ========================================================================= */

.app-navbar {
    background: var(--app-gradient-dark) !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.app-navbar .navbar-brand {
    transition: opacity 0.2s ease;
}

.app-navbar .navbar-brand:hover {
    opacity: 0.9;
}

.user-avatar-circle {
    transition: var(--app-transition-smooth);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.3);
}

.user-avatar-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.4);
}

/* =========================================================================
   31. Card Hover Lift Utilities
   ========================================================================= */

.hover-lift {
    transition: var(--app-transition-smooth);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--app-shadow-hover);
}

/* =========================================================================
   32. Quick Action Card Hover
   ========================================================================= */

.d-grid .btn {
    transition: var(--app-transition-smooth);
    border-radius: 0.75rem;
}

.d-grid .btn:hover {
    transform: translateX(4px);
}

/* =========================================================================
   33. Empty State Enhancements
   ========================================================================= */

.card .fs-1.opacity-50 {
    transition: var(--app-transition-smooth);
}

.card:hover .fs-1.opacity-50 {
    transform: scale(1.1);
    opacity: 0.7 !important;
}

/* =========================================================================
   34. Table Row Hover Enhancements
   ========================================================================= */

.table-hover tbody tr {
    transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 148, 136, 0.03) !important;
}

/* =========================================================================
   35. Scrollbar Custom Styling
   ========================================================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* =========================================================================
   36. AOS Custom Overrides
   ========================================================================= */

[data-aos] {
    pointer-events: auto !important;
}

.aos-init {
    opacity: 1 !important;
}

/* Mobile: no AOS scroll-wait — instead run fast CSS-only page-enter
   animations so Customer (Dashboard / Shop / Orders / Profile) and Admin
   (Dashboard / Order Management / Inventory / User Management) animate
   instantly on switch with zero stagger lag. */
@media (max-width: 991.98px) {
    [data-aos],
    [data-aos][data-aos-delay],
    .aos-animate {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        transition-delay: 0s !important;
    }

    .app-main {
        opacity: 1 !important;
        transition: none !important;
    }

    /* Lightweight GPU-only enter animations (opacity + translateY) */
    @keyframes appPageIn {
        from { opacity: 0; transform: translateY(8px); }
        to   { opacity: 1; transform: translateY(0); }
    }

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

    /* Page banner glides in first */
    .app-main .container-fluid > .card:first-child,
    .app-main .container-fluid > .alert:first-child {
        animation: appPageIn 0.28s ease-out backwards;
    }

    /* Content cards follow with a tiny capped stagger (max ~0.12s wait) */
    .app-main .card {
        animation: appCardIn 0.32s ease-out backwards;
    }

    .app-main .row > *:nth-child(2) .card { animation-delay: 0.04s; }
    .app-main .row > *:nth-child(3) .card { animation-delay: 0.08s; }
    .app-main .row > *:nth-child(4) .card { animation-delay: 0.12s; }
    .app-main .row > *:nth-child(n+5) .card { animation-delay: 0.12s; }

    /* Admin mobile order cards: stagger the first few, render the rest
       instantly so long lists stay smooth on low-end phones */
    .admin-orders-mobile-list > *:nth-child(2) { animation-delay: 0.03s; }
    .admin-orders-mobile-list > *:nth-child(3) { animation-delay: 0.06s; }
    .admin-orders-mobile-list > *:nth-child(4) { animation-delay: 0.09s; }
    .admin-orders-mobile-list > *:nth-child(5) { animation-delay: 0.12s; }
    .admin-orders-mobile-list > *:nth-child(6) { animation-delay: 0.12s; }
    .admin-orders-mobile-list > *:nth-child(n+7) { animation: none; }

    /* Momentum horizontal swipe for admin tables on touch */
    .app-main .table-responsive {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* Active sidebar item gets a subtle slide so the tap feels alive */
    .app-sidebar .nav-link.active {
        animation: appPageIn 0.25s ease-out backwards;
    }
}

/* =========================================================================
   37. Modal Enhancements
   ========================================================================= */

.modal-content {
    border-radius: 1rem;
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.modal-backdrop.show {
    backdrop-filter: blur(4px);
}

/* =========================================================================
   34. Dark Mode — Component Overrides
   ========================================================================= */

/* Body & base text */
[data-theme="dark"] body.app-body {
    background-color: #020617;
    background-image:
        radial-gradient(720px 360px at 6% -6%, rgba(20, 184, 166, 0.16), transparent 60%),
        radial-gradient(620px 340px at 94% -2%, rgba(251, 146, 60, 0.12), transparent 60%),
        radial-gradient(900px 520px at 50% 118%, rgba(6, 182, 212, 0.10), transparent 60%),
        linear-gradient(180deg, #0f172a 0%, #020617 100%);
    background-attachment: fixed;
    color: var(--app-text-main);
}
[data-theme="dark"] body.app-body::before {
    background-image: radial-gradient(rgba(148, 163, 184, 0.09) 1px, transparent 1px);
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 80%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 80%);
}
[data-theme="dark"] .text-dark { color: #e2e8f0 !important; }
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .text-black { color: #f1f5f9 !important; }

/* Navbar */
[data-theme="dark"] .app-navbar { background: linear-gradient(135deg, #020617 0%, #0f172a 100%) !important; }

/* Sidebar */
[data-theme="dark"] .app-sidebar { background-color: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .app-sidebar .nav-link { color: #cbd5e1; }
[data-theme="dark"] .app-sidebar .nav-link:hover { background-color: rgba(20, 184, 166, 0.1); color: #14b8a6; }
[data-theme="dark"] .app-sidebar .nav-link.active { background: linear-gradient(135deg, rgba(20, 184, 166, 0.12) 0%, rgba(6, 182, 212, 0.08) 100%); color: #14b8a6; }
[data-theme="dark"] .app-sidebar .nav-link.text-dark { color: #cbd5e1; }
[data-theme="dark"] .app-sidebar-footer { background-color: #0f172a !important; }

/* Sidebar backdrop */
[data-theme="dark"] .sidebar-backdrop { background: rgba(0, 0, 0, 0.6); }

/* Cards & surfaces */
[data-theme="dark"] .card,
[data-theme="dark"] .app-stat-card,
[data-theme="dark"] .app-product-card,
[data-theme="dark"] .app-order-card {
    background-color: var(--app-surface);
    border-color: var(--app-border);
    color: var(--app-text-main);
}

[data-theme="dark"] .bg-white { background-color: #1e293b !important; }
[data-theme="dark"] .bg-light { background-color: #1e293b !important; }
[data-theme="dark"] .bg-body-secondary { background-color: #1e293b !important; }
[data-theme="dark"] .bg-body-tertiary { background-color: #1e293b !important; }

/* Footer */
[data-theme="dark"] .app-footer { background-color: #0f172a !important; border-color: #334155 !important; color: #94a3b8 !important; }

/* Tables */
[data-theme="dark"] .table { color: #e2e8f0; }
[data-theme="dark"] .table th { color: #94a3b8; border-color: #334155; }
[data-theme="dark"] .table td { border-color: #334155; }
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background-color: rgba(255, 255, 255, 0.02); color: #e2e8f0; }
[data-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: rgba(20, 184, 166, 0.04); }

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .form-control::placeholder { color: #64748b; }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #0f172a;
    border-color: #14b8a6;
    color: #e2e8f0;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}
[data-theme="dark"] .input-group-text { background-color: #1e293b; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .form-check-input { background-color: #0f172a; border-color: #475569; }
[data-theme="dark"] .form-check-input:checked { background-color: #14b8a6; border-color: #14b8a6; }
[data-theme="dark"] .form-label { color: #e2e8f0; }
[data-theme="dark"] .form-text { color: #64748b; }

/* File inputs: native "Choose file" button stays readable in dark mode */
[data-theme="dark"] .form-control::file-selector-button,
[data-theme="dark"] .form-control::-webkit-file-upload-button {
    background-color: #1e293b;
    border-inline-end-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .form-control:hover::file-selector-button,
[data-theme="dark"] .form-control:hover::-webkit-file-upload-button {
    background-color: #334155;
    color: #ffffff;
}

/* Dropdowns */
[data-theme="dark"] .dropdown-menu { background-color: #1e293b; border-color: #334155; }
[data-theme="dark"] .dropdown-item { color: #cbd5e1; }
[data-theme="dark"] .dropdown-item:hover { background-color: rgba(20, 184, 166, 0.1); color: #14b8a6; }
[data-theme="dark"] .dropdown-item.text-danger:hover { background-color: rgba(239, 68, 68, 0.1); color: #f87171; }
[data-theme="dark"] .dropdown-divider { border-color: #334155; }

/* Badges */
[data-theme="dark"] .badge.bg-secondary { background-color: #475569 !important; color: #e2e8f0 !important; }
[data-theme="dark"] .badge.bg-primary { background-color: #0d9488 !important; }
[data-theme="dark"] .bg-primary-subtle { background-color: rgba(20, 184, 166, 0.15) !important; }
[data-theme="dark"] .bg-success-subtle { background-color: rgba(16, 185, 129, 0.15) !important; }
[data-theme="dark"] .bg-warning-subtle { background-color: rgba(245, 158, 11, 0.15) !important; }
[data-theme="dark"] .bg-danger-subtle { background-color: rgba(239, 68, 68, 0.15) !important; }
[data-theme="dark"] .bg-info-subtle { background-color: rgba(14, 165, 233, 0.15) !important; }

/* Alerts */
[data-theme="dark"] .alert-danger { background-color: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.25); color: #fca5a5; }
[data-theme="dark"] .alert-success { background-color: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.25); color: #6ee7b7; }
[data-theme="dark"] .alert-warning { background-color: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.25); color: #fcd34d; }
[data-theme="dark"] .alert-info { background-color: rgba(14, 165, 233, 0.1); border-color: rgba(14, 165, 233, 0.25); color: #7dd3fc; }

/* Modal */
[data-theme="dark"] .modal-content { background-color: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .modal-header { border-color: #334155; }
[data-theme="dark"] .modal-footer { border-color: #334155; }
[data-theme="dark"] .btn-close { filter: invert(1); }

/* Toast */
[data-theme="dark"] .toast { background-color: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .toast-header { background-color: #1e293b; color: #e2e8f0; border-color: #334155; }

/* Product image wrapper */
[data-theme="dark"] .app-product-img-wrapper { background-color: #0f172a; }

/* Chat */
[data-theme="dark"] .chat-bubble-received { background: #1e293b; color: #e2e8f0; border-color: #334155; }
[data-theme="dark"] .chat-input-area { background: #0f172a; }

/* Pagination */
[data-theme="dark"] .page-link { background-color: #1e293b; border-color: #334155; color: #14b8a6; }
[data-theme="dark"] .page-item.disabled .page-link { background-color: #0f172a; border-color: #334155; color: #475569; }

/* Breadcrumbs */
[data-theme="dark"] .breadcrumb { background-color: transparent; }
[data-theme="dark"] .breadcrumb-item a { color: #14b8a6; }
[data-theme="dark"] .breadcrumb-item.active { color: #64748b; }

/* Scrollbar dark */
[data-theme="dark"] ::-webkit-scrollbar { width: 8px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f172a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Skeleton */
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%); }

/* Status badge glows */
[data-theme="dark"] .badge-status-pending     { box-shadow: 0 0 8px rgba(245, 158, 11, 0.3); }
[data-theme="dark"] .badge-status-approved    { box-shadow: 0 0 8px rgba(14, 165, 233, 0.3); }
[data-theme="dark"] .badge-status-ready_for_delivery { box-shadow: 0 0 8px rgba(20, 184, 166, 0.3); }
[data-theme="dark"] .badge-status-picked_up   { box-shadow: 0 0 8px rgba(139, 92, 246, 0.3); }
[data-theme="dark"] .badge-status-out_for_delivery { box-shadow: 0 0 8px rgba(249, 115, 22, 0.3); }
[data-theme="dark"] .badge-status-delivered   { box-shadow: 0 0 8px rgba(16, 185, 129, 0.3); }
[data-theme="dark"] .badge-status-cancelled   { box-shadow: 0 0 8px rgba(239, 68, 68, 0.3); }

/* Nav pills & tabs */
[data-theme="dark"] .nav-tabs { border-color: #334155; }
[data-theme="dark"] .nav-tabs .nav-link { color: #94a3b8; }
[data-theme="dark"] .nav-tabs .nav-link.active { background-color: #1e293b; color: #14b8a6; border-color: #334155; }
[data-theme="dark"] .nav-pills .nav-link { color: #94a3b8; }

/* AOS fade overrides for visibility */
[data-theme="dark"] [data-aos] { color: #e2e8f0; }

/* Theme toggle button */
.theme-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #fbbf24;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    padding: 0;
}
.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(20deg);
    color: #fbbf24;
}
[data-theme="dark"] .theme-toggle-btn {
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

/* Extra dark mode fixes for remaining hardcoded colors */
[data-theme="dark"] .app-clickable-card:hover { border-color: #475569; }
[data-theme="dark"] .app-clickable-row:hover > td { background-color: rgba(20, 184, 166, 0.06) !important; color: #e2e8f0; }
[data-theme="dark"] .table th { background-color: #0f172a; color: #94a3b8; }
[data-theme="dark"] .app-product-icon { color: #14b8a6; }
[data-theme="dark"] .timeline-step-icon { background-color: #1e293b; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .timeline-step.completed .timeline-step-icon { background-color: #10b981; border-color: #10b981; }
[data-theme="dark"] .timeline-step-label { color: #94a3b8; }
[data-theme="dark"] .timeline-step.active .timeline-step-label { color: #14b8a6; }
[data-theme="dark"] .btn-outline-secondary { color: #94a3b8; border-color: #475569; }
[data-theme="dark"] .btn-outline-secondary:hover { background-color: #334155; color: #e2e8f0; border-color: #475569; }
[data-theme="dark"] .btn-secondary { background-color: #475569; border-color: #475569; color: #e2e8f0; }
[data-theme="dark"] .text-dark { color: #e2e8f0 !important; }
[data-theme="dark"] a.text-dark { color: #e2e8f0 !important; }
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 { color: #e2e8f0; }
[data-theme="dark"] .text-primary { color: #14b8a6 !important; }
[data-theme="dark"] .text-success { color: #34d399 !important; }
[data-theme="dark"] .text-danger { color: #f87171 !important; }
[data-theme="dark"] .text-warning { color: #fbbf24 !important; }
[data-theme="dark"] .text-info { color: #7dd3fc !important; }
[data-theme="dark"] .border-bottom { border-color: #334155 !important; }
[data-theme="dark"] .border-top { border-color: #334155 !important; }
[data-theme="dark"] .border { border-color: #334155 !important; }
[data-theme="dark"] .shadow-sm { box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important; }
[data-theme="dark"] .shadow { box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important; }
[data-theme="dark"] .bg-secondary-subtle { background-color: rgba(71, 85, 105, 0.3) !important; }
[data-theme="dark"] .bg-primary { background-color: #0d9488 !important; }
[data-theme="dark"] .bg-success-subtle { background-color: rgba(16, 185, 129, 0.15) !important; }
[data-theme="dark"] .bg-warning-subtle { background-color: rgba(245, 158, 11, 0.15) !important; }
[data-theme="dark"] .bg-danger-subtle { background-color: rgba(239, 68, 68, 0.15) !important; }
[data-theme="dark"] .bg-info-subtle { background-color: rgba(14, 165, 233, 0.15) !important; }
[data-theme="dark"] .bg-success { background-color: #10b981 !important; }
[data-theme="dark"] .bg-warning { background-color: #f59e0b !important; }
[data-theme="dark"] .bg-danger { background-color: #ef4444 !important; }
[data-theme="dark"] .bg-info { background-color: #0ea5e9 !important; }
[data-theme="dark"] .badge.bg-light { background-color: #334155 !important; color: #e2e8f0 !important; }
[data-theme="dark"] .list-group-item { background-color: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .list-group-item.active { background-color: #0d9488; border-color: #0d9488; color: #fff; }
[data-theme="dark"] .accordion-button { background-color: #1e293b; color: #e2e8f0; border-color: #334155; }
[data-theme="dark"] .accordion-button:not(.collapsed) { background-color: rgba(20,184,166,0.1); color: #14b8a6; }
[data-theme="dark"] .accordion-body { background-color: #1e293b; color: #e2e8f0; }
[data-theme="dark"] .card-header { background-color: #0f172a; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .card-footer { background-color: #0f172a; border-color: #334155; }
[data-theme="dark"] .placeholder-glow .placeholder { background-color: #334155; }
[data-theme="dark"] .img-thumbnail { border-color: #334155; }
[data-theme="dark"] hr { border-color: #334155; }
[data-theme="dark"] .app-sidebar .nav-link.active .bi { color: #14b8a6; }
[data-theme="dark"] .app-sidebar .nav-link .bi { color: #94a3b8; }
[data-theme="dark"] .app-sidebar .nav-link.active { color: #14b8a6; font-weight: 600; }
[data-theme="dark"] .app-sidebar .nav-link:hover .bi { color: #14b8a6; }
[data-theme="dark"] .user-avatar-circle { background-color: #0d9488; color: #fff; }
[data-theme="dark"] .navbar-avatar-img { border: 2px solid #334155; }
[data-theme="dark"] .app-footer { color: #94a3b8; }
[data-theme="dark"] .app-footer strong { color: #14b8a6; }
[data-theme="dark"] .btn-outline-danger:hover { background-color: rgba(239,68,68,0.15); color: #f87171; border-color: #ef4444; }
[data-theme="dark"] .btn-outline-primary { color: #14b8a6; border-color: #14b8a6; }
[data-theme="dark"] .btn-outline-primary:hover { background-color: #14b8a6; color: #fff; border-color: #14b8a6; }
[data-theme="dark"] .app-btn-gradient { box-shadow: 0 4px 16px rgba(20,184,166,0.3); }
[data-theme="dark"] .app-btn-gradient:hover { box-shadow: 0 6px 24px rgba(20,184,166,0.45); }

/* Dark mode: kill white table-light variant (customer order-detail Total Amount row + thead).
   Bootstrap's .table-light forces --bs-table-bg: #f8f9fa (white block in dark mode) and
   pairs it with dark text, which also makes .text-dark cells render white-on-white. */
[data-theme="dark"] .table-light {
    --bs-table-color: #e2e8f0;
    --bs-table-bg: #0f172a;
    --bs-table-border-color: #334155;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-striped-color: #e2e8f0;
    --bs-table-active-bg: rgba(20, 184, 166, 0.08);
    --bs-table-active-color: #e2e8f0;
    --bs-table-hover-bg: rgba(20, 184, 166, 0.08);
    --bs-table-hover-color: #e2e8f0;
    color: #e2e8f0;
    border-color: #334155;
}
[data-theme="dark"] thead.table-light th,
[data-theme="dark"] thead.table-light td,
[data-theme="dark"] tbody tr.table-light th,
[data-theme="dark"] tbody tr.table-light td,
[data-theme="dark"] tfoot tr.table-light th,
[data-theme="dark"] tfoot tr.table-light td,
[data-theme="dark"] tr.table-light > th,
[data-theme="dark"] tr.table-light > td {
    background-color: #0f172a !important;
    box-shadow: inset 0 0 0 9999px #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] thead.table-light th {
    color: #94a3b8 !important;
}

/* Dark mode: remove white hover flash (admin + rider tables, buttons, pagination, lists) */
[data-theme="dark"] .table,
[data-theme="dark"] .table-hover {
    --bs-table-hover-bg: rgba(20, 184, 166, 0.08);
    --bs-table-hover-color: #e2e8f0;
    --bs-table-accent-bg: transparent;
}
[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    --bs-table-color-state: #e2e8f0;
    --bs-table-bg-state: rgba(20, 184, 166, 0.08);
    background-color: rgba(20, 184, 166, 0.08) !important;
    box-shadow: inset 0 0 0 9999px rgba(20, 184, 166, 0.08) !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .btn-light {
    --bs-btn-bg: #334155;
    --bs-btn-border-color: #475569;
    --bs-btn-color: #e2e8f0;
    --bs-btn-hover-bg: #475569;
    --bs-btn-hover-border-color: #475569;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-active-bg: #475569;
    --bs-btn-active-border-color: #475569;
    --bs-btn-active-color: #ffffff;
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .btn-light:hover,
[data-theme="dark"] .btn-light:focus,
[data-theme="dark"] .btn-light:active {
    background-color: #475569 !important;
    border-color: #475569 !important;
    color: #ffffff !important;
}
[data-theme="dark"] .page-link:hover {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #5eead4 !important;
}
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
    background-color: rgba(20, 184, 166, 0.08) !important;
    color: #e2e8f0 !important;
}
[data-theme="dark"] .dropdown-menu {
    --bs-dropdown-bg: #1e293b;
    --bs-dropdown-border-color: #334155;
    --bs-dropdown-link-color: #cbd5e1;
    --bs-dropdown-link-hover-bg: rgba(20, 184, 166, 0.1);
    --bs-dropdown-link-hover-color: #14b8a6;
    --bs-dropdown-header-color: #94a3b8;
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background-color: rgba(20, 184, 166, 0.1) !important;
}
[data-theme="dark"] .dropdown-item.text-success:hover,
[data-theme="dark"] .dropdown-item.text-success:focus { color: #34d399 !important; }
[data-theme="dark"] .dropdown-item.text-secondary:hover,
[data-theme="dark"] .dropdown-item.text-secondary:focus { color: #94a3b8 !important; }
[data-theme="dark"] .dropdown-item.text-danger:hover,
[data-theme="dark"] .dropdown-item.text-danger:focus { background-color: rgba(239, 68, 68, 0.12) !important; color: #f87171 !important; }

/* Bootstrap variable bridge: kill white at the source */
[data-theme="dark"] {
    color-scheme: dark;
    --bs-body-bg: #0f172a;
    --bs-body-color: #e2e8f0;
    --bs-border-color: #334155;
    --bs-card-bg: #1e293b;
    --bs-modal-bg: #1e293b;
    --bs-offcanvas-bg: #1e293b;
    --bs-table-bg: transparent;
    --bs-table-color: #e2e8f0;
    --bs-list-group-bg: #1e293b;
    --bs-list-group-border-color: #334155;
    --bs-list-group-action-hover-bg: rgba(20, 184, 166, 0.08);
    --bs-list-group-action-hover-color: #e2e8f0;
    --bs-pagination-bg: #1e293b;
    --bs-pagination-border-color: #334155;
    --bs-pagination-hover-bg: #334155;
    --bs-pagination-hover-border-color: #475569;
    --bs-pagination-hover-color: #5eead4;
}

/* Sidebar hamburger (btn-outline-light) flashed white on hover */
[data-theme="dark"] .btn-outline-light:hover,
[data-theme="dark"] .btn-outline-light:focus,
[data-theme="dark"] .btn-outline-light:active {
    background-color: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* Nav pills / tabs hover flashed #f1f5f9 */
[data-theme="dark"] .nav-pills .nav-link:hover:not(.active),
[data-theme="dark"] .nav-tabs .nav-link:hover:not(.active) {
    background-color: rgba(20, 184, 166, 0.1) !important;
    color: #14b8a6 !important;
    border-color: #334155 !important;
}

/* Chat offcanvas panel stayed white */
[data-theme="dark"] .offcanvas,
[data-theme="dark"] .offcanvas-header,
[data-theme="dark"] .offcanvas-body {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .chat-header { background: #1e293b !important; color: #e2e8f0 !important; border-color: #334155 !important; }
[data-theme="dark"] .chat-messages { background: #0f172a !important; }
[data-theme="dark"] .chat-bubble-received { background: #334155 !important; color: #e2e8f0 !important; border-color: #475569 !important; }
[data-theme="dark"] .chat-input-area { background: #1e293b !important; border-color: #334155 !important; }

/* Dashboard UX: sticky filter bars stay visible while scrolling long lists */
.sticky-filterbar {
    position: sticky;
    top: calc(var(--app-header-height) + 0.75rem);
    z-index: 1015;
}

/* Dashboard UX: tabular numerals stop stat values jittering during count-up */
.app-stat-card h3 {
    font-variant-numeric: tabular-nums;
}

/* Dashboard UX: "open" hint revealed on clickable stat cards */
.app-stat-card .stat-open-hint {
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.app-stat-card:hover .stat-open-hint {
    opacity: 1;
    transform: translateX(0);
}

/* Dashboard UX: mini delivery-progress stepper (rider cards) */
.delivery-steps {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}
.delivery-steps li {
    flex: 1;
    position: relative;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 600;
    color: #94a3b8;
    padding-top: 1.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.delivery-steps li::before {
    content: '';
    position: absolute;
    top: 0.55rem;
    left: 0;
    right: 0;
    height: 2px;
    background: #e2e8f0;
}
.delivery-steps li::after {
    content: '';
    position: absolute;
    top: 0.2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #cbd5e1;
}
.delivery-steps li:first-child::before { left: 50%; }
.delivery-steps li:last-child::before { right: 50%; }
.delivery-steps li.done { color: #0d9488; }
.delivery-steps li.done::before { background: #14b8a6; }
.delivery-steps li.done::after {
    background: #14b8a6;
    border-color: #14b8a6;
}
.delivery-steps li.current { color: #0d9488; }
.delivery-steps li.current::after {
    border-color: #14b8a6;
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.2);
}
[data-theme="dark"] .delivery-steps li { color: #64748b; }
[data-theme="dark"] .delivery-steps li::before { background: #334155; }
[data-theme="dark"] .delivery-steps li::after { background: #1e293b; border-color: #475569; }
[data-theme="dark"] .delivery-steps li.done { color: #14b8a6; }
[data-theme="dark"] .delivery-steps li.done::before { background: #14b8a6; }
[data-theme="dark"] .delivery-steps li.done::after { background: #14b8a6; border-color: #14b8a6; }
[data-theme="dark"] .delivery-steps li.current { color: #5eead4; }
[data-theme="dark"] .delivery-steps li.current::after { border-color: #14b8a6; }

/* Dashboard UX: soft pulse ring for live/active indicators */
.pulse-ring {
    position: relative;
}
.pulse-ring::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    border: 2px solid rgba(20, 184, 166, 0.5);
    animation: pulseRing 1.8s ease-out infinite;
    pointer-events: none;
}
@keyframes pulseRing {
    0% { transform: scale(0.85); opacity: 1; }
    100% { transform: scale(1.15); opacity: 0; }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .app-sidebar { transition: none; }
}

/* =========================================================================
   38. Universal Responsive System — phones, tablets, laptops, Mac, desktop
   Complements Bootstrap 5.3 breakpoints:
     xs  <576px   (small phones, iPhone SE)
     sm  ≥576px   (large phones)
     md  ≥768px   (tablets / iPad)
     lg  ≥992px   (laptops / small desktop)
     xl  ≥1200px  (desktop / MacBook)
     xxl ≥1400px  (large desktop / iMac / 4K)
   ========================================================================= */

/* ── 38.1 Global fluid safeguards (all devices) ── */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}
body.app-body {
    overflow-x: clip;
    text-rendering: optimizeLegibility;
}
img, video, canvas, svg, iframe {
    max-width: 100%;
    height: auto;
}
img:not([width]):not([height]) { height: auto; }
pre, code, table { word-wrap: break-word; overflow-wrap: anywhere; }
a, button { -webkit-tap-highlight-color: transparent; }

/* Fluid type scale — same markup reads well on 320px phones and 27" iMacs */
h1, .h1 { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem); line-height: 1.15; }
h2, .h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.75rem); line-height: 1.2; }
h3, .h3 { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.4rem); line-height: 1.25; }
h4, .h4 { font-size: clamp(1rem, 0.95rem + 0.4vw, 1.2rem); }
.lead { font-size: clamp(0.95rem, 0.9rem + 0.4vw, 1.15rem); }

/* Main content rhythm per device class */
.app-main { padding-inline: clamp(0.75rem, 2vw, 1.5rem); }
.app-main-wrapper { min-width: 0; max-width: 100%; }

/* ── 38.2 Extra-small phones (<576px) — iPhone SE, small Android ── */
@media (max-width: 575.98px) {
    :root { --app-sidebar-width: 272px; }

    /* Prevent iOS auto-zoom on focus: inputs must be ≥16px */
    .form-control, .form-select, textarea.form-control, input[type="text"],
    input[type="email"], input[type="tel"], input[type="password"], input[type="number"] {
        font-size: 16px;
    }
    .input-group-text { font-size: 1rem; }

    /* 44px minimum touch targets */
    .btn, .nav-link, .page-link, .dropdown-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    .app-sidebar .nav-link, .dropdown-item, .list-group-item-action {
        min-height: 44px;
    }
    .btn-sm { min-height: 38px; }

    /* Navbar: keep brand visible but compact; logout becomes icon-only */
    .app-navbar .navbar-brand { font-size: 0.95rem; }
    .app-navbar .navbar-brand span:last-child {
        max-width: 38vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .app-navbar-actions { gap: 0.5rem !important; }
    .app-navbar .app-logout-btn {
        width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 1rem;
        flex-shrink: 0;
    }
    .app-navbar .app-logout-btn .app-logout-label { display: none !important; }
    .app-navbar .app-logout-btn i { margin: 0 !important; }

    /* Page headers stack: title over actions */
    .d-flex.justify-content-between.align-items-center,
    .d-flex.justify-content-between.align-items-start {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1 1 100%; justify-content: center; }

    /* Filter / search bars stack full-width */
    .sticky-filterbar { top: calc(var(--app-header-height) + 0.5rem); }
    .sticky-filterbar .row > [class*="col-"] { width: 100%; }
    .sticky-filterbar .input-group { width: 100%; }
    .sticky-filterbar .btn { width: 100%; justify-content: center; }

    /* Stat cards: 2-up stays readable, single column for tallest widgets */
    .app-stat-card { border-radius: 0.875rem; }
    .app-stat-card h3 { font-size: 1.35rem; }
    .stat-icon-wrapper { width: 42px; height: 42px; font-size: 1.25rem; }
    .app-stat-card .stat-open-hint { display: none; }

    /* Product catalog: single column, shorter image band */
    .app-product-img-wrapper { height: 150px; }
    .app-product-card .card-title { font-size: 0.95rem; }

    /* Tables: smooth momentum scroll, smaller type, sticky first col off */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        border-radius: 0.75rem;
    }
    .table { font-size: 0.82rem; }
    .table th, .table td { padding: 0.6rem 0.5rem; white-space: nowrap; }
    .table td .text-truncate { max-width: 40vw !important; }

    /* Cards & banners: tighter padding, no overflow */
    .card-body { padding: 1rem; }
    .app-banner-gradient .card-body, .app-banner-dark .card-body { padding: 1.1rem 1rem; }
    .app-banner-gradient h2, .app-banner-dark h2 { font-size: 1.25rem; }
    .app-banner-gradient p, .app-banner-dark p { font-size: 0.85rem; }

    /* Modals become near-fullscreen sheets */
    .modal-dialog { margin: 0.5rem; }
    .modal-dialog-scrollable .modal-body { max-height: calc(100dvh - 220px); }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 100%; justify-content: center; }

    /* Toasts span screen width */
    .toast-container { left: 0.75rem; right: 0.75rem; width: auto !important; }
    .toast { width: 100%; max-width: 100%; }

    /* Chat offcanvas full-width */
    .chat-offcanvas { width: 100vw; max-width: 100vw; }
    .chat-bubble { max-width: 88%; font-size: 0.85rem; }

    /* Footer wraps cleanly */
    .app-footer { font-size: 0.75rem; padding-inline: 0.75rem; }

    /* Delivery stepper already vertical — tighten type */
    .delivery-steps li { font-size: 0.6rem; }

    /* Auth pages */
    .auth-form-body .row.g-3 { --bs-gutter-y: 0.75rem; }
}

/* Very small devices (≤360px — Galaxy Fold, iPhone SE 1st gen) */
@media (max-width: 360px) {
    .app-main { padding: 0.75rem 0.6rem; }
    .card-body { padding: 0.85rem; }
    .app-stat-card h3 { font-size: 1.15rem; }
    .btn { font-size: 0.85rem; padding-inline: 0.75rem; }
    .table { font-size: 0.78rem; }
}

/* ── 38.3 Large phones / small tablets (576–767px) ── */
@media (min-width: 576px) and (max-width: 767.98px) {
    .form-control, .form-select { font-size: 16px; }
    .app-main { padding: 1rem 1.1rem; }
    .app-product-img-wrapper { height: 160px; }
    .page-header-actions { flex-wrap: wrap; gap: 0.5rem; }
    .modal-dialog { max-width: calc(100vw - 2rem); margin-inline: auto; }
    .chat-offcanvas { width: min(380px, 92vw); }
}

/* ── 38.4 Tablets (768–991px — iPad, Android tablets, small laptops) ── */
@media (min-width: 768px) and (max-width: 991.98px) {
    .app-main { max-width: 960px; }
    .app-product-img-wrapper { height: 170px; }
    .card-body { padding: 1.25rem; }

    /* Sidebar is a drawer in this range — widen touch area slightly */
    .app-sidebar { width: 280px; }

    /* Two-column stat grids breathe */
    .row.g-3 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }

    /* Filter bars: search full row, selects share second row */
    .sticky-filterbar .row > div:first-child { flex: 0 0 100%; max-width: 100%; }
}

/* ── 38.5 Laptops / desktops (992–1199px) ── */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-main { max-width: 1140px; }
    /* Sidebar is docked again — prevent content squeeze */
    .app-main-wrapper { overflow-x: hidden; }
}

/* ── 38.6 Mac / desktop (≥1200px — MacBook Pro/Air, Windows desktop) ── */
@media (min-width: 1200px) {
    .app-main { max-width: 1400px; }
    .table th, .table td { padding: 0.8rem 0.9rem; }
}

/* Hover-only affordances (no sticky hover on touch) */
@media (min-width: 1200px) and (hover: hover) and (pointer: fine) {
    .app-clickable-card:hover { transform: translateY(-4px); }
}

/* ── 38.7 Large desktop / iMac / ultrawide (≥1400px) ── */
@media (min-width: 1400px) {
    .app-main { max-width: 1480px; padding-inline: 2rem; }
    .app-product-img-wrapper { height: 200px; }
    .order-detail-map { height: 380px; }
    .admin-live-map { height: 420px; }
    .order-live-map { height: 340px; }
}

/* ── 38.8 Landscape phones (height-constrained) ── */
@media (max-height: 500px) and (orientation: landscape) {
    .app-splash-logo { width: 56px; height: 56px; }
    .auth-form-side { padding: 1rem; }
    .modal-dialog-scrollable .modal-body { max-height: calc(100dvh - 160px); }
    .chat-messages { max-height: calc(100dvh - 140px); }
    .app-sidebar-inner { height: calc(100dvh - var(--app-header-height)); }
}

/* ── 38.9 Device-capability refinements ── */
/* Coarse pointers (touch): larger hit areas, no translate hovers */
@media (pointer: coarse) {
    .btn, .nav-link, .page-link { min-height: 44px; }
    .app-product-card:hover, .app-clickable-card:hover { transform: none; }
    .d-grid .btn:hover { transform: none; }
}
/* Fine pointers (mouse/trackpad): keep lift effects */
@media (pointer: fine) {
    .table-responsive::-webkit-scrollbar { height: 6px; }
}
/* High-DPI (Retina Mac, flagship phones): crisper borders */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card, .app-stat-card, .app-product-card, .app-order-card { border-width: 0.5px; }
}
/* iPhone notch / Android gesture bar safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
    .app-footer { padding-bottom: calc(0.75rem + env(safe-area-inset-bottom)); }
    .toast-container { bottom: calc(0.75rem + env(safe-area-inset-bottom)); }
    .chat-input-area { padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)); }
    .app-sidebar-footer { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}
/* Foldables / split-screen narrow windows */
@media (max-width: 575.98px) {
    .container, .container-fluid { padding-inline: 0.75rem; }
    .row { --bs-gutter-x: 0.75rem; }
}

/* =========================================================================
   39. Fluid Dashboard System — dashboards must respond CONTINUOUSLY while
   resizing (dragging the browser frame), not just snap at breakpoints.
   Covers: admin / customer / rider stat cards, banners, filter bars,
   card headers, and generic flex-shrink fixes for card internals.
   ========================================================================= */

/* ── 39.1 Stat cards: text column may shrink, values scale fluidly ── */
.app-stat-card .d-flex.align-items-center.justify-content-between { gap: 0.75rem; }
.app-stat-card .d-flex.align-items-center.justify-content-between > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}
/* Fluid stat values — grow/shrink smoothly with the viewport at any width */
.app-stat-card h3 {
    font-size: clamp(1.05rem, 0.85rem + 1.1vw, 1.6rem);
    overflow-wrap: anywhere;
    line-height: 1.2;
}
.app-stat-card .small.text-uppercase,
.app-stat-card .extra-small.text-uppercase {
    overflow-wrap: break-word;
}
/* Slightly smaller icon below very-wide screens so 4–5 across never squeezes */
@media (max-width: 1599.98px) {
    .stat-icon-wrapper { width: 42px; height: 42px; font-size: 1.3rem; }
}

/* ── 39.2 Admin 5-stat row: reflow 5-across → 3+2 ONLY in the narrow
   desktop-window range where the docked sidebar truly crushes them.
   Typical laptops (≥1320px) keep the compact 5-across look. ── */
@media (min-width: 1200px) and (max-width: 1319.98px) {
    #adminDashboardContainer > .row.g-3.mb-4 > .col-sm-6.col-xl {
        flex: 0 0 auto;
        width: 33.33333333%;
    }
}

/* ── 39.2b Laptop density: banners + stat cards stay compact on
   13–16" laptop screens instead of feeling oversized ── */
@media (min-width: 992px) and (max-width: 1599.98px) {
    .app-banner-gradient .card-body,
    .app-banner-dark .card-body { padding: 1.5rem !important; }
    .app-banner-gradient h2, .app-banner-dark h2 { font-size: 1.4rem; }
    .app-banner-gradient .fs-6, .app-banner-dark .fs-6 { font-size: 0.9rem !important; }
    .app-stat-card { border-radius: 0.75rem; }
    .app-stat-card h3 { font-size: clamp(1rem, 0.8rem + 0.9vw, 1.3rem); }
}

/* ── 39.3 Generic card flex-shrink fixes (text wraps, buttons stay whole) ── */
.card .d-flex > div,
.card .d-flex > span,
.alert .d-flex > div { min-width: 0; }
.card .d-flex > .btn,
.card .d-flex > a.btn { flex-shrink: 0; }
.card-body .d-flex.gap-2 { flex-wrap: wrap; }
.card-header.d-flex { flex-wrap: wrap; gap: 0.5rem; }
/* Amount / total blocks keep one line while their label column wraps */
.card .d-flex > .text-end { flex-shrink: 0; }

/* ── 39.4 Dashboard banners: unbreakable text + full-width buttons on phones ── */
.app-banner-gradient h2, .app-banner-dark h2,
.app-banner-gradient h3, .app-banner-dark h3 { overflow-wrap: break-word; }
.app-banner-gradient .small span,
.app-banner-dark .small span { overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
    .app-banner-gradient .card-body > .d-flex.justify-content-between > div:last-child,
    .app-banner-gradient .card-body > .row > div:last-child,
    .app-banner-dark .card-body > .row > div:last-child { width: 100%; }
    .app-banner-gradient .card-body .btn,
    .app-banner-dark .card-body .btn { flex: 1 1 100%; justify-content: center; }
}

/* ── 39.5 Customer active-delivery alert: text takes space, button intact ── */
.alert[role="alert"] > .d-flex { flex: 1 1 260px; min-width: 0; }
.alert .btn { flex-shrink: 0; }
.alert .fw-bold { overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
    .alert[role="alert"] > .btn,
    .alert[role="alert"] > a.btn { flex: 1 1 100%; justify-content: center; }
}

/* ── 39.6 Rider filter bar: pills reflow, search shrinks instead of overflowing ── */
#riderDeliveriesContainer .sticky-filterbar .card-body > div:last-child {
    flex: 1 1 220px;
    min-width: 0;
    display: flex;
    justify-content: flex-end;
}
#riderDeliveriesContainer .sticky-filterbar .input-group {
    flex: 1 1 auto;
    width: 100%;
    max-width: 280px;
}
.sticky-filterbar .input-group { max-width: 100%; }
@media (max-width: 575.98px) {
    #riderDeliveriesContainer .sticky-filterbar .card-body > div:first-child { width: 100%; }
    #riderDeliveriesContainer .rider-filter-btn { flex: 1 1 45%; justify-content: center; }
    #riderDeliveriesContainer .sticky-filterbar .card-body > div:last-child { justify-content: stretch; }
    #riderDeliveriesContainer .sticky-filterbar .input-group { max-width: 100%; }
}

/* ── 39.7 Quick-action / Management-hub buttons: label wraps, chevron fixed ── */
.d-grid .btn > div:first-child { min-width: 0; flex: 1 1 auto; }
.d-grid .btn > i:last-child { flex-shrink: 0; }
.d-grid .btn small { overflow-wrap: anywhere; }

/* ── 39.8 Admin secondary metric cards: count text wraps, View pill fixed ── */
#adminDashboardContainer .col-md-4 .card .btn { flex-shrink: 0; }
#adminDashboardContainer .col-md-4 .fw-bold { overflow-wrap: anywhere; }
@media (max-width: 400px) {
    #adminDashboardContainer .col-md-4 .card .d-flex.align-items-center.gap-3 { flex-wrap: wrap; }
}

/* ── 39.9 Desktop de-zoom: the whole app is rem-based (Bootstrap 5), so a
   smaller root font-size scales text, spacing, buttons and cards down
   together — like zooming the app out without touching browser zoom.
   Phones/tablets keep 16px for readability and touch targets. ── */
@media (min-width: 992px) and (max-width: 1599.98px) {
    html { font-size: 13px; }
}
@media (min-width: 1600px) {
    html { font-size: 15px; }
}

/* ── 39.10 Laptop chrome compaction: the px-fixed frame (sidebar, navbar,
   logos, avatars, stat icons) does NOT shrink with the root font-size, so
   shrink it explicitly in the laptop range for a truly denser app. ── */
@media (min-width: 992px) and (max-width: 1599.98px) {
    :root {
        --app-sidebar-width: 228px;
        --app-header-height: 52px;
    }
    .app-logo-badge { width: 34px; height: 34px; }
    .app-navbar .navbar-brand { font-size: 1rem; }
    .app-navbar .user-avatar-circle,
    .navbar-avatar-img { width: 34px; height: 34px; font-size: 0.95rem; }
    .stat-icon-wrapper { width: 38px; height: 38px; font-size: 1.2rem; }
    .theme-toggle-btn { width: 32px; height: 32px; font-size: 1rem; }
}

/* =========================================================================
   40. Logout Transition Overlay — "Logging out..." loading screen shown
   briefly when the user clicks Logout, before the login page loads.
   ========================================================================= */
.logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 50%, #14b8a6 100%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.logout-overlay.show { opacity: 1; visibility: visible; }
.logout-overlay-content { text-align: center; color: #fff; padding: 1rem; }
.logout-overlay-logo {
    width: 76px;
    height: 76px;
    margin: 0 auto 1rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.25rem;
    color: #fbbf24;
    filter: drop-shadow(0 2px 8px rgba(251, 191, 36, 0.4));
    animation: logoutLogoPulse 1.4s ease-in-out infinite;
}
@keyframes logoutLogoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.logout-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 1rem;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fbbf24;
    border-radius: 50%;
    animation: logoutSpin 0.8s linear infinite;
}
@keyframes logoutSpin { to { transform: rotate(360deg); } }
.logout-overlay-text {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.logout-dots::after {
    content: '';
    display: inline-block;
    width: 1.5em;
    text-align: left;
    animation: logoutDots 1.2s steps(4) infinite;
}
@keyframes logoutDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}
.logout-overlay-content small { color: rgba(255, 255, 255, 0.75); }

/* =========================================================================
   41. Compact customer banners — stay slim on ALL devices.
   Overrides generic banner padding (39.2b) + full-width phone buttons (39.4)
   which otherwise make compact banners swallow vertical space.
   ========================================================================= */
.app-banner-gradient.app-banner-compact .card-body,
.app-banner-dark.app-banner-compact .card-body { padding: 0.8rem 1rem !important; }
.app-banner-gradient.app-banner-compact .card-body .btn,
.app-banner-dark.app-banner-compact .card-body .btn { flex: 0 0 auto; }

/* Phones: hide subtitle, shrink icon/chips, keep button inline */
@media (max-width: 575.98px) {
    .app-banner-gradient.app-banner-compact .card-body,
    .app-banner-dark.app-banner-compact .card-body { padding: 0.65rem 0.8rem !important; }
    .app-banner-compact .banner-icon { width: 32px; height: 32px; font-size: 1rem; border-radius: 10px; }
    .app-banner-compact h5 { font-size: 0.95rem; }
    .app-banner-compact .banner-sub { display: none !important; }
    .app-banner-compact .banner-chip { padding: 0.28rem 0.6rem; font-size: 0.68rem; }
    .app-banner-compact .banner-chip i { font-size: 0.75rem; }
    .app-banner-gradient.app-banner-compact .card-body .btn,
    .app-banner-dark.app-banner-compact .card-body .btn {
        flex: 0 0 auto !important;
        width: auto !important;
        min-height: 0 !important;
        font-size: 0.78rem;
        padding: 0.35rem 0.7rem;
    }
    .app-banner-compact > .card-body > .d-flex { gap: 0.65rem !important; }
}
/* Desktop: medium size — not tiny, not oversized */
@media (min-width: 992px) {
    .app-banner-gradient.app-banner-compact .card-body,
    .app-banner-dark.app-banner-compact .card-body { padding: 1rem 1.25rem !important; }
    .app-banner-compact h5 { font-size: 1.3rem; }
    .app-banner-compact .banner-sub { font-size: 0.83rem; }
    .app-banner-compact .banner-icon { width: 44px; height: 44px; font-size: 1.25rem; border-radius: 12px; }
    .app-banner-compact .banner-chip { padding: 0.4rem 0.85rem; font-size: 0.76rem; }
    .app-banner-compact.app-banner-gradient::after {
        width: 280px;
        height: 280px;
        top: -60%;
        right: -5%;
    }
    .app-banner-compact.app-banner-dark::after {
        width: 280px;
        height: 280px;
        top: -60%;
        right: -5%;
    }
}

/* =========================================================================
   42. Customer order filter pills — single-row scroll on phones/tablets
   so All / Pending / In Transit / Delivered / Cancelled never stack ugly.
   ========================================================================= */
.order-filter-bar { scrollbar-width: thin; }
.order-filter-bar .order-filter-btn { flex-shrink: 0; }

/* Customer welcome greeting — medium fluid size on all devices */
.welcome-greeting {
    font-size: clamp(1.45rem, 1.15rem + 1.4vw, 1.9rem);
    line-height: 1.25;
    overflow-wrap: break-word;
}
@media (max-width: 767.98px) {
    .order-filter-bar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.5rem !important;
        padding: 0.55rem 0.65rem !important;
    }
    .order-filter-bar::-webkit-scrollbar { display: none; }
    .order-filter-bar .order-filter-btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.75rem !important;
        min-height: 0 !important;
        line-height: 1.4;
    }
    .order-filter-bar .badge { font-size: 0.65rem; }
}

/* =========================================================================
   43. Admin Order Management — responsive filter tabs, banner & cards.
   All Orders / Pending / Approved / Ready / Picked Up / Out for Delivery /
   Delivered / Cancelled must stay usable on Android phones without squeezing
   the wide desktop table. Desktop keeps the table; <md uses stacked cards.
   ========================================================================= */
#adminOrdersContainer { min-width: 0; }

/* Filter pill bar: base (desktop wraps neatly) */
.admin-order-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem 0.75rem;
    scrollbar-width: thin;
}
.admin-order-filter-bar .admin-order-filter-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding-inline: 0.9rem;
    border-radius: 50rem;
}

/* User Management role tabs: same pill radius as Order Management filters */
.admin-user-filter-bar .admin-user-filter-btn {
    border-radius: 50rem;
}

/* Banner head: title grows, actions never overflow */
.admin-orders-banner-head { min-width: 0; }
.admin-orders-banner-title { min-width: 0; flex: 1 1 220px; }
.admin-orders-banner-actions {
    flex-wrap: wrap;
    margin-left: auto;
    row-gap: 0.4rem;
}
.admin-orders-banner-actions .btn { white-space: nowrap; }

/* Search count line centers on phones */
.admin-visible-count { min-width: 0; }

/* Mobile order card internals */
.admin-orders-mobile-list .admin-order-card { border-radius: 0.875rem; }
.admin-order-card-thumb {
    width: 44px;
    height: 44px;
    background: #f1f5f9;
}
.admin-order-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.admin-order-card-meta { min-width: 0; }
.admin-order-card .min-w-0 { min-width: 0; }
.admin-order-card-actions .btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Phones & small tablets: filter bar becomes one-row swipe strip */
@media (max-width: 991.98px) {
    .admin-filter-card { position: sticky; top: calc(var(--app-header-height) + 0.5rem); z-index: 1010; }
    .admin-order-filter-bar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.5rem !important;
        padding: 0.55rem 0.65rem !important;
    }
    .admin-order-filter-bar::-webkit-scrollbar { display: none; }
    .admin-order-filter-bar .admin-order-filter-btn {
        font-size: 0.75rem;
        padding: 0.35rem 0.8rem !important;
        min-height: 0 !important;
        line-height: 1.4;
    }
    .admin-order-filter-bar .badge { font-size: 0.65rem; }

    /* User Management role tabs: same one-row swipe strip on touch */
    .admin-user-filter-bar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .admin-user-filter-bar::-webkit-scrollbar { display: none; }
    .admin-user-filter-bar .admin-user-filter-btn {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 0.75rem;
        padding: 0.35rem 0.8rem !important;
        min-height: 0 !important;
        line-height: 1.4;
    }
    .admin-user-filter-bar .badge { font-size: 0.65rem; }
}

/* Phones: banner stacks, actions fill row as touch-friendly buttons */
@media (max-width: 575.98px) {
    .admin-orders-banner-title { flex: 1 1 100%; }
    .admin-orders-banner-actions { width: 100%; margin-left: 0; }
    .admin-orders-banner-actions .banner-chip {
        flex: 1 1 100%;
        justify-content: center;
    }
    .admin-orders-banner-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 38px;
    }
    .admin-visible-count { text-align: left !important; }
    .admin-orders-mobile-list { padding: 0.5rem !important; }
}

/* Dark mode: mobile thumb + card borders */
[data-theme="dark"] .admin-order-card-thumb { background: #0f172a; }

/* Global dark-mode fix: Bootstrap .alert-light / .alert-secondary stayed white */
[data-theme="dark"] .alert-light,
[data-theme="dark"] .alert-secondary {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}
[data-theme="dark"] .alert-light .text-muted,
[data-theme="dark"] .alert-secondary .text-muted { color: #94a3b8 !important; }
[data-theme="dark"] .alert-light strong,
[data-theme="dark"] .alert-secondary strong { color: #f1f5f9 !important; }

/* Theme-aware empty-filter state (replaces white alert-light box) — compact height, full width */
.empty-filter-state {
    text-align: center;
    padding: 1.1rem 1rem 1.25rem;
    margin: 0.75rem 0;
    border-radius: 0.75rem;
    border: 1px dashed var(--app-border);
    background-color: var(--app-surface);
    color: var(--app-text-main);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.empty-filter-state .fw-bold { font-size: 0.95rem; }
.empty-filter-state p {
    color: var(--app-text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    margin-bottom: 0.75rem !important;
    line-height: 1.45;
}
.empty-filter-icon {
    width: 38px;
    height: 38px;
    margin: 0 auto 0.5rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    background: rgba(13, 148, 136, 0.1);
    color: var(--app-primary);
    border: 1px solid rgba(13, 148, 136, 0.2);
}
[data-theme="dark"] .empty-filter-state {
    background-color: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .empty-filter-state p { color: #94a3b8; }
[data-theme="dark"] .empty-filter-icon {
    background: rgba(20, 184, 166, 0.12);
    border-color: rgba(20, 184, 166, 0.3);
    color: #5eead4;
}

