/**
 * JZ PANEL - Mobile-First Responsive Breakpoint Refinements & 3D Tactile Elements
 * Native Mobile App Feel on Tablets and Smartphones
 */

/* ========================================================
   Mobile & Tablet Breakpoint (under 992px)
   ======================================================== */
@media (max-width: 992px) {
    /* Layout & Mobile Drawer Sidebar */
    .app-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 280px !important;
        max-width: 85vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        background: rgba(11, 16, 28, 0.96) !important;
        transform: translateX(-100%) !important;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.85);
        z-index: 2000 !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        display: flex !important;
        flex-direction: column !important;
        visibility: visible !important;
    }

    .app-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.95) !important;
    }

    .sidebar-backdrop {
        z-index: 1990 !important;
    }

    #sidebar-close-btn {
        display: inline-flex !important;
    }

    .app-main {
        margin-left: 0 !important;
        padding-bottom: 96px; /* Safe space for bottom nav dock */
        min-height: 100vh;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Mobile Top App Header */
    .app-header {
        padding: 0 14px;
        height: 60px;
        position: sticky;
        top: 0;
        z-index: 1000;
        background: rgba(11, 16, 28, 0.88);
        backdrop-filter: blur(24px) saturate(180%);
        -webkit-backdrop-filter: blur(24px) saturate(180%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    }

    .header-user-wallet {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .header-user-wallet .balance-pill {
        display: none; /* Prominently displayed in hero card */
    }

    .header-user-wallet .icon-btn {
        width: 38px;
        height: 38px;
        font-size: 14px;
        border-radius: 12px;
    }

    .user-avatar-btn {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: var(--primary-gradient-3d);
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 800;
        font-size: 13px;
        color: #ffffff;
        border: 1.5px solid rgba(255, 255, 255, 0.25);
        box-shadow: 0 3px 0 #3730a3, 0 4px 12px rgba(99, 102, 241, 0.4);
        cursor: pointer;
        text-decoration: none;
        transition: transform 0.12s ease;
    }

    .user-avatar-btn:active {
        transform: translateY(2px);
    }

    /* Mobile Content Padding */
    .app-content {
        padding: 14px 12px 100px 12px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* 3D Glass Hero Wallet Card on Mobile */
    .wallet-hero-card {
        padding: 20px 16px;
        border-radius: 20px;
        margin-bottom: 16px;
        background: linear-gradient(135deg, rgba(30, 20, 60, 0.88) 0%, rgba(18, 12, 38, 0.94) 100%);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-top: 1px solid rgba(255, 255, 255, 0.25);
        position: relative;
        overflow: hidden;
        box-shadow: 0 14px 38px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

    .wallet-hero-card::before {
        content: '';
        position: absolute;
        top: -40px;
        right: -30px;
        width: 140px;
        height: 140px;
        background: radial-gradient(circle, rgba(99, 102, 241, 0.4) 0%, transparent 70%);
        border-radius: 50%;
        pointer-events: none;
    }

    .wallet-balance-amount {
        font-size: 28px !important;
        font-weight: 900;
        letter-spacing: -0.5px;
        margin: 4px 0 14px;
        line-height: 1.1;
    }

    .hero-btn-row {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .hero-btn-row .btn {
        padding: 9px 16px;
        font-size: 12px;
        font-weight: 700;
        border-radius: 9999px;
    }

    /* Native 4-Column Quick Action Bar with 3D Tactility */
    .quick-actions-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 18px !important;
    }

    .quick-action-item {
        padding: 12px 4px !important;
        border-radius: 16px !important;
        min-width: 0 !important;
        background: rgba(255, 255, 255, 0.045) !important;
        border: 1px solid rgba(255, 255, 255, 0.09) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
        box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.25) !important;
        transition: transform 0.12s ease, background 0.12s ease !important;
    }

    .quick-action-item:active {
        transform: translateY(2px) !important;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3) !important;
        background: rgba(255, 255, 255, 0.08) !important;
    }

    .quick-action-icon {
        width: 40px !important;
        height: 40px !important;
        border-radius: 13px !important;
        font-size: 17px !important;
        margin-bottom: 2px !important;
    }

    .quick-action-label {
        font-size: 10.5px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        letter-spacing: -0.2px !important;
    }

    /* 2x2 Compact Metric Stat Cards */
    .stat-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin-bottom: 18px !important;
    }

    .stat-card {
        padding: 12px 14px !important;
        gap: 10px !important;
        border-radius: 16px !important;
        background: rgba(255, 255, 255, 0.035) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.18) !important;
        box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3) !important;
    }

    .stat-icon {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
        border-radius: 11px !important;
    }

    .stat-value {
        font-size: 18px !important;
        font-weight: 900 !important;
        line-height: 1.1 !important;
    }

    .stat-label {
        font-size: 11px !important;
        color: var(--text-dim) !important;
        margin-top: 2px !important;
    }

    /* Category Chips Slider with 3D Tactile Feel */
    .category-chips-wrapper {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 8px;
        margin-bottom: 18px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .category-chips-wrapper::-webkit-scrollbar {
        display: none;
    }

    .category-chip {
        padding: 8px 14px !important;
        font-size: 12px !important;
        border-radius: 9999px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.22) !important;
        box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3) !important;
        scroll-snap-align: start;
        flex-shrink: 0;
    }

    .category-chip:active {
        transform: translateY(2px) !important;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3) !important;
    }

    .category-chip .cat-name {
        max-width: 130px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
    }

    .category-chip .cat-count {
        font-size: 10px !important;
        padding: 1px 6px !important;
        border-radius: 999px !important;
        background: rgba(255, 255, 255, 0.12) !important;
    }

    /* Trending Services Grid on Mobile */
    .card-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .service-card {
        padding: 16px 16px !important;
        border-radius: 18px !important;
        background: rgba(255, 255, 255, 0.035) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.18) !important;
        box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), var(--shadow-glass) !important;
    }

    .service-card .service-title {
        font-size: 13.5px !important;
        line-height: 1.4 !important;
    }

    .service-card .service-price-tag {
        font-size: 18px !important;
        margin: 6px 0 10px !important;
    }

    /* Mobile Orders List: Native App Cards with 3D Touch Feel */
    .mobile-orders-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mobile-order-card {
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.09);
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 16px;
        padding: 14px 16px;
        box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
        transition: transform 0.12s ease;
    }

    .mobile-order-card:active {
        transform: translateY(2px);
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    }

    .mobile-order-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }

    .mobile-order-id {
        font-size: 13px;
        font-weight: 800;
        color: #38bdf8;
        text-decoration: none;
    }

    .mobile-order-name {
        font-size: 12.5px;
        font-weight: 700;
        color: #ffffff;
        margin-bottom: 10px;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mobile-order-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 8px;
        border-top: 1px dashed rgba(255, 255, 255, 0.07);
        font-size: 11.5px;
        color: var(--text-dim);
    }

    .mobile-order-charge {
        font-weight: 800;
        color: #34d399;
        font-size: 13px;
    }

    /* Hide desktop table on mobile */
    .desktop-only-table {
        display: none !important;
    }

    /* Show mobile order list on mobile */
    .mobile-only-orders {
        display: block !important;
    }

    /* Mobile Empty State Card */
    .mobile-empty-state {
        padding: 30px 16px !important;
        border-radius: 20px !important;
        text-align: center;
    }

    /* Native Bottom Navigation Dock with 3D Specular Glass */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: rgba(11, 16, 28, 0.94);
        backdrop-filter: blur(28px) saturate(200%);
        -webkit-backdrop-filter: blur(28px) saturate(200%);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 1500;
        justify-content: space-around;
        align-items: center;
        padding: 0 6px max(4px, env(safe-area-inset-bottom)) 6px;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    }

    body.modal-open .bottom-nav {
        display: none !important;
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-dim);
        text-decoration: none;
        font-size: 10.5px;
        font-weight: 700;
        transition: all 0.2s;
        flex: 1;
        padding: 6px 0;
        position: relative;
    }

    .bottom-nav-item i {
        font-size: 18px;
        transition: transform 0.2s;
    }

    .bottom-nav-item.active {
        color: #ffffff;
    }

    .bottom-nav-item.active i {
        color: var(--primary-light);
        transform: translateY(-2px);
    }

    .bottom-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: 2px;
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: var(--primary-light);
        box-shadow: 0 0 8px var(--primary-light);
    }

    /* Floating Center 3D Add/Order Button */
    .floating-order-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: var(--primary-gradient-3d);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        text-decoration: none;
        box-shadow: 0 4px 0 #3730a3, 0 10px 24px rgba(99, 102, 241, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.4);
        margin-top: -24px;
        border: 3px solid #0b101c;
        transition: transform 0.12s ease, box-shadow 0.12s ease;
        flex-shrink: 0;
    }

    .floating-order-btn:active {
        transform: translateY(2px) scale(0.92) !important;
        box-shadow: 0 1px 0 #3730a3, 0 4px 10px rgba(99, 102, 241, 0.4) !important;
    }

    /* Modal Bottom Sheet */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
        z-index: 2500;
    }

    .modal-dialog {
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 88vh;
        border-bottom: none;
        transform: translateY(100%);
    }

    .modal-overlay.active .modal-dialog {
        transform: translateY(0);
    }
}

/* ========================================================
   Smartphones under 480px / 400px
   ======================================================== */
@media (max-width: 480px) {
    .quick-actions-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }

    .quick-action-item {
        padding: 10px 3px !important;
    }

    .quick-action-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 15px !important;
    }

    .quick-action-label {
        font-size: 10px !important;
    }

    .wallet-balance-amount {
        font-size: 26px !important;
    }

    .hero-btn-row .btn {
        padding: 8px 14px !important;
        font-size: 11.5px !important;
    }

    .stat-card {
        padding: 10px 12px !important;
    }

    .stat-value {
        font-size: 16px !important;
    }

    .stat-icon {
        width: 34px !important;
        height: 34px !important;
        font-size: 14px !important;
    }
}

/* Universal Mobile App Cards with 3D Depth */
.mobile-app-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.12s ease, background 0.12s ease;
}

.mobile-app-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.06);
}

.mobile-app-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mobile-app-card-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.4;
    margin-bottom: 6px;
}

.mobile-app-card-meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
    line-height: 1.4;
}

.mobile-app-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 11.5px;
    color: var(--text-dim);
}

/* 3D Quantity & Amount Preset Pills */
.qty-presets-row {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.qty-presets-row::-webkit-scrollbar {
    display: none;
}

.qty-presets-row .btn, .qty-presets-row .amount-chip {
    flex-shrink: 0;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 14px;
    min-height: 34px;
}

/* Form Controls on Mobile */
.form-control, .form-select {
    min-height: 46px;
    font-size: 14.5px;
    border-radius: 14px;
}

/* Code Viewer Safeguards */
.code-viewer, pre {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    font-size: 12px;
    border-radius: 12px;
}

/* ========================================================
   Desktop Screens (993px+)
   ======================================================== */
@media (min-width: 993px) {
    .desktop-only-table {
        display: block !important;
    }

    .mobile-only-cards,
    .mobile-only-orders {
        display: none !important;
    }

    .bottom-nav {
        display: none !important;
    }
}

/* Extra Large Screens (1024px+) */
@media (min-width: 1024px) {
    .app-content {
        padding: 30px 36px;
    }

    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
