/* =================================================================
   MOBILE APP MODE — Drive365
   Native app-like experience on mobile devices
   Only active when mobile_app_mode setting is enabled
   ================================================================= */

/* ============================================================
   ROOT — App Mode Variables
   ============================================================ */
:root {
    --app-header-height: 56px;
    --app-topbar-height: 32px;
    --app-nav-height: 60px;
    --app-bg: #0B0F19;
    --app-surface: rgba(255, 255, 255, 0.04);
    --app-surface-hover: rgba(255, 255, 255, 0.08);
    --app-border: rgba(255, 255, 255, 0.06);
    --app-gold: #d4af37;
    --app-gold-light: #f5d060;
    --app-gold-glow: rgba(212, 175, 55, 0.15);
    --app-text: rgba(255, 255, 255, 0.85);
    --app-text-muted: rgba(255, 255, 255, 0.45);
    --app-radius: 16px;
    --app-radius-sm: 10px;
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================
   HIDE DESKTOP ELEMENTS — Always when app mode is on mobile
   These rules apply for ALL mobile sizes when body has the class
   ============================================================ */
@media (max-width: 991px) {
    body.mobile-app-mode .topbar {
        display: none !important;
    }

    body.mobile-app-mode .navbar {
        display: none !important;
    }

    body.mobile-app-mode .footer {
        display: none !important;
    }

    body.mobile-app-mode .scroll-to-top {
        display: none !important;
    }

    body.mobile-app-mode .navbar-toggle {
        display: none !important;
    }

    body.mobile-app-mode .mobile-menu {
        display: none !important;
    }

    body.mobile-app-mode .mobile-menu-overlay {
        display: none !important;
    }
}

/* ============================================================
   APP MODE — Activates on mobile (<= 991px)
   ============================================================ */
@media (max-width: 991px) {

    body.mobile-app-mode {
        padding-top: calc(var(--app-topbar-height) + var(--app-header-height) + constant(safe-area-inset-top, 0px)) !important;
        padding-top: calc(var(--app-topbar-height) + var(--app-header-height) + env(safe-area-inset-top, 0px)) !important;
        padding-bottom: calc(var(--app-nav-height) + var(--app-safe-bottom)) !important;
        background: var(--app-bg);
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        overscroll-behavior-y: contain;
    }

    /* ── APP TOPBAR (Contact + Social) ── */
    .app-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: calc(var(--app-topbar-height) + constant(safe-area-inset-top, 0px));
        height: calc(var(--app-topbar-height) + env(safe-area-inset-top, 0px));
        padding-top: constant(safe-area-inset-top, 0px);
        padding-top: env(safe-area-inset-top, 0px);
        background: linear-gradient(135deg, #141a2a, #0d1120);
        border-bottom: 1px solid rgba(212, 175, 55, 0.15);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-left: 12px;
        padding-right: 12px;
        z-index: 9991;
        overflow: hidden;
    }

    .app-topbar-left {
        display: flex;
        align-items: center;
        gap: 12px;
        overflow-x: auto;
        flex: 1;
        min-width: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .app-topbar-left::-webkit-scrollbar {
        display: none;
    }

    .app-topbar-item {
        display: flex;
        align-items: center;
        gap: 5px;
        color: rgba(255, 255, 255, 0.55);
        text-decoration: none;
        font-size: 0.62rem;
        white-space: nowrap;
        transition: color 0.2s;
    }

    .app-topbar-item:hover,
    .app-topbar-item:active {
        color: #d4af37;
    }

    .app-topbar-item i {
        font-size: 0.55rem;
        color: rgba(212, 175, 55, 0.6);
    }

    .app-topbar-right {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
        margin-left: 8px;
    }

    .app-topbar-social {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: rgba(255, 255, 255, 0.4);
        font-size: 0.58rem;
        text-decoration: none;
        transition: all 0.2s;
    }

    .app-topbar-social:hover,
    .app-topbar-social:active {
        color: #d4af37;
        background: rgba(212, 175, 55, 0.1);
    }

    .app-topbar-social-wa:hover,
    .app-topbar-social-wa:active {
        color: #25d366;
        background: rgba(37, 211, 102, 0.1);
    }

    /* ── APP HEADER ── */
    .app-header {
        position: fixed;
        top: calc(var(--app-topbar-height) + constant(safe-area-inset-top, 0px));
        top: calc(var(--app-topbar-height) + env(safe-area-inset-top, 0px));
        left: 0;
        right: 0;
        height: var(--app-header-height);
        background: #0B0F19;
        border-bottom: 1px solid rgba(212, 175, 55, 0.08);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        z-index: 9990;
    }

    .app-header-left {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .app-header-logo {
        height: 28px;
        width: auto;
        object-fit: contain;
    }

    .app-header-title {
        font-size: 1.05rem;
        font-weight: 700;
        color: #fff;
        letter-spacing: -0.3px;
    }

    .app-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .app-header-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.7);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        text-decoration: none;
        position: relative;
        font-size: 1rem;
    }

    .app-header-btn:hover,
    .app-header-btn:active {
        background: var(--app-surface-hover);
        color: #fff;
    }

    .app-header-badge {
        position: absolute;
        top: 2px;
        right: 0px;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        background: #ef4444;
        color: #fff;
        font-size: 0.58rem;
        font-weight: 800;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        border: 2px solid var(--app-bg);
        line-height: 1;
    }

    .app-header-badge:not(:empty) {
        animation: badgePulse 2s ease-in-out infinite;
    }

    @keyframes badgePulse {

        0%,
        100% {
            box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
        }

        50% {
            box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
        }
    }

    /* ══════════════════════════════════════════════
       BOTTOM NAVIGATION — Premium iOS/Android Style
       ══════════════════════════════════════════════ */
    .app-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--app-nav-height) + var(--app-safe-bottom));
        padding-bottom: var(--app-safe-bottom);
        background: rgba(11, 15, 25, 0.97);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-top: 1px solid rgba(212, 175, 55, 0.08);
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        z-index: 9990;
        padding-left: 4px;
        padding-right: 4px;
    }

    .app-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        flex: 1;
        padding: 6px 0;
        color: rgba(255, 255, 255, 0.35);
        text-decoration: none;
        font-size: 0.6rem;
        font-weight: 500;
        letter-spacing: 0.2px;
        transition: color 0.2s;
        cursor: pointer;
        border: none;
        background: none;
        position: relative;
        -webkit-tap-highlight-color: transparent;
        font-family: inherit;
    }

    .app-nav-item i {
        font-size: 1.2rem;
        line-height: 1;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .app-nav-item span {
        transition: all 0.25s;
        line-height: 1;
        margin-top: 1px;
    }

    /* Active state — gold with glow dot */
    .app-nav-item.active {
        color: var(--app-gold);
    }

    .app-nav-item.active i {
        transform: scale(1.1);
        filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
    }

    .app-nav-item.active span {
        font-weight: 700;
    }

    /* Active dot indicator */
    .app-nav-item.active::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--app-gold);
        box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
    }

    /* Touch feedback */
    .app-nav-item:active {
        transform: scale(0.9);
        transition: transform 0.1s;
    }

    /* Badge on nav items */
    .app-nav-badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 18px);
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        background: #ef4444;
        color: #fff;
        font-size: 0.55rem;
        font-weight: 800;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        line-height: 1;
        border: 1.5px solid var(--app-bg);
    }

    /* ── APP CONTENT ADJUSTMENTS ── */
    body.mobile-app-mode main {
        min-height: calc(100vh - var(--app-header-height) - var(--app-nav-height));
        animation: appPageIn 0.25s ease;
    }

    @keyframes appPageIn {
        from {
            opacity: 0;
            transform: translateY(6px);
        }

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

    body.mobile-app-mode .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* ── HERO SECTION ── */
    body.mobile-app-mode .hero-dw {
        min-height: auto;
        padding: 8px 0 16px;
    }

    body.mobile-app-mode .hero-dw-container {
        padding-top: 0;
    }

    body.mobile-app-mode .hero-dw-gold-bg {
        opacity: 0.5;
    }

    /* ── DASHBOARD — App Cards ── */
    body.mobile-app-mode .dash-container {
        padding: 16px;
    }

    body.mobile-app-mode .dash-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    body.mobile-app-mode .dash-sidebar {
        position: static;
        display: none;
    }

    body.mobile-app-mode .dash-content {
        padding: 0;
    }

    body.mobile-app-mode .dash-page-title {
        font-size: 1.3rem;
        margin-bottom: 16px;
    }

    body.mobile-app-mode .dash-card {
        border-radius: var(--app-radius);
        border-color: var(--app-border);
    }

    body.mobile-app-mode .dash-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    body.mobile-app-mode .dash-stat-card {
        border-radius: var(--app-radius);
        padding: 14px;
    }

    body.mobile-app-mode .dash-welcome {
        border-radius: var(--app-radius);
        padding: 20px;
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    body.mobile-app-mode .dash-welcome-avatar {
        width: 60px;
        height: 60px;
        font-size: 1.4rem;
    }

    /* ── BOOKING / PROFILE CARDS ── */
    body.mobile-app-mode .booking-card,
    body.mobile-app-mode .dash-booking-card,
    body.mobile-app-mode .profile-card,
    body.mobile-app-mode .invoice-card,
    body.mobile-app-mode .payment-card,
    body.mobile-app-mode .contract-card,
    body.mobile-app-mode .notification-card {
        border-radius: var(--app-radius);
        overflow: hidden;
    }

    body.mobile-app-mode .dw-slider-card,
    body.mobile-app-mode .vehicle-card {
        border-radius: var(--app-radius);
    }

    /* ── FLOATING ELEMENTS — Above bottom nav ── */
    body.mobile-app-mode .floating-cart-widget {
        bottom: calc(var(--app-nav-height) + var(--app-safe-bottom) + 16px) !important;
    }

    body.mobile-app-mode .cart-reminder-toast {
        bottom: calc(var(--app-nav-height) + var(--app-safe-bottom) + 80px) !important;
    }

    body.mobile-app-mode .whatsapp-float {
        bottom: calc(var(--app-nav-height) + var(--app-safe-bottom) + 16px) !important;
    }

    /* ── MODAL — App-style slide up ── */
    body.mobile-app-mode .support-modal-overlay {
        align-items: flex-end;
    }

    body.mobile-app-mode .support-modal,
    body.mobile-app-mode .support-modal-lg,
    body.mobile-app-mode .support-modal-sm {
        width: 100vw;
        max-width: 100vw;
        max-height: calc(100vh - var(--app-header-height));
        border-radius: var(--app-radius) var(--app-radius) 0 0;
        margin: 0;
        animation: appSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }

    @keyframes appSlideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    /* ── SECTIONS — Tighter spacing ── */
    body.mobile-app-mode section {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    body.mobile-app-mode .dw-section {
        padding: 24px 0;
    }

    /* ── DASHBOARD SECTION — No extra navbar padding ── */
    body.mobile-app-mode .dash-section {
        padding: 16px 0 24px !important;
    }

    body.mobile-app-mode .auth-section {
        padding: 16px 0 40px !important;
    }

    /* ── VEHICLE DETAIL — App padding ── */
    body.mobile-app-mode .vehicle-detail-section {
        padding-top: 16px !important;
    }

    /* ── FORMS — Full width ── */
    body.mobile-app-mode .search-box,
    body.mobile-app-mode .dw-search-box {
        border-radius: var(--app-radius);
        margin: 0 0 16px;
    }

    body.mobile-app-mode .dash-form-grid {
        grid-template-columns: 1fr;
    }

    /* ── TABLES — Responsive ── */
    body.mobile-app-mode .dash-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--app-radius);
    }

    /* ── SMOOTH SCROLL ── */
    body.mobile-app-mode {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Touch feedback ── */
    .app-header-btn:active {
        transform: scale(0.88);
        transition: transform 0.1s;
    }

}

/* end @media (max-width: 991px) */


/* ============================================================
   SMALL PHONES — Extra tight (<= 375px)
   ============================================================ */
@media (max-width: 375px) {
    .app-nav-item {
        font-size: 0.55rem;
    }

    .app-nav-item i {
        font-size: 1.05rem;
    }

    .app-header-title {
        font-size: 0.92rem;
    }

    .app-header-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
}

/* ============================================================
   DESKTOP — Hide app components entirely
   ============================================================ */
@media (min-width: 992px) {

    .app-header,
    .app-topbar,
    .app-bottom-nav,
    .app-lang-menu,
    #appLoadingBar {
        display: none !important;
    }
}