/* ============================================================
   EMIRAL HUB — Mobile-First Adaptive Styles
   Desktop (≥1025px): sidebar, tables, dense layout
   Mobile  (≤768px) : bottom nav, cards, app-like UX
   ============================================================ */

/* ------- Reset viewport for mobile rendering ------- */

/* ------- MOBILE BOTTOM NAV (≤768px) ------- */
#mobileBottomNav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #162a22;
    border-top: 1px solid #234839;
    z-index: 9999;
    align-items: center;
    justify-content: space-around;
    padding: 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #94a3b8;
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.2s, transform 0.15s;
    gap: 2px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

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

.bottom-nav-item span.material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
}

/* FAB-style primary action button in bottom nav */
.bottom-nav-item.nav-fab {
    background: #11d483;
    color: #0a1a12;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    flex: 0 0 52px;
    margin-top: -24px;
    box-shadow: 0 4px 14px rgba(17, 212, 131, 0.4);
    font-size: 0;
}

.bottom-nav-item.nav-fab span.material-symbols-outlined {
    font-size: 26px;
    color: #0a1a12;
    font-variation-settings: 'FILL' 1;
}

.bottom-nav-item.nav-fab:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(17, 212, 131, 0.3);
}

/* ------- MOBILE GENERAL (≤768px) ------- */
@media screen and (max-width: 768px) {

    /* ----- Show mobile nav, add bottom padding ----- */
    #mobileBottomNav {
        display: flex;
    }

    body {
        padding-bottom: 72px !important;
        overflow-x: hidden;
    }

    /* ----- Hide desktop sidebar completely ----- */
    #sidebar,
    #sidebarOverlay,
    #sidebarToggle {
        display: none !important;
    }

    /* ----- Header: compact on mobile ----- */
    header {
        height: 56px !important;
        padding: 0 1rem !important;
    }

    header span.font-bold {
        font-size: 1rem !important;
    }

    /* ----- Main content: full-width, no left margin ----- */
    #mainContent {
        margin-left: 0 !important;
        padding: 1rem !important;
        min-height: calc(100vh - 56px - 64px);
    }

    /* Container flex-height fix */
    .flex.h-\[calc\(100vh-4rem\)\] {
        height: auto !important;
        min-height: calc(100vh - 56px);
    }

    /* ----- Page headings: scaled down ----- */
    h1.text-3xl {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
    }

    /* ----- Stat cards: 2-column grid on mobile ----- */
    .grid.grid-cols-1.md\:grid-cols-3,
    .grid.grid-cols-1.md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .grid.grid-cols-1.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* ----- Stat card: tighter padding on mobile ----- */
    .bg-surface-dark.rounded-xl.p-6,
    .bg-\[#162a22\].rounded-xl.p-6 {
        padding: 1rem !important;
    }

    .text-3xl.font-bold,
    .text-4xl.font-bold {
        font-size: 1.75rem !important;
    }

    /* ----- RECEIPTS TABLE → CARDS ----- */
    .receipts-table-wrapper {
        display: none !important;
    }

    .receipts-card-list {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* ----- USERS TABLE → CARDS ----- */
    .users-table-wrapper {
        display: none !important;
    }

    .users-card-list {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* ----- FINANCES TABLE → CARDS ----- */
    .finances-table-wrapper {
        display: none !important;
    }

    .finances-card-list {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* ----- WITHDRAWALS TABLE → CARDS (Transactions page) ----- */
    .withdrawals-table-wrapper {
        display: none !important;
    }

    .withdrawals-card-list {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* ----- Ensure bottom nav never covers page content ----- */
    #mainContent {
        padding-bottom: 7rem !important;
        /* 64px nav + 48px breathing room */
    }

    /* ----- Generic mobile card ----- */
    .mobile-card {
        background: #162a22;
        border: 1px solid #234839;
        border-radius: 16px;
        padding: 1rem;
        position: relative;
        overflow: hidden;
    }

    .mobile-card-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .mobile-card-title {
        font-size: 1rem;
        font-weight: 700;
        color: #fff;
    }

    .mobile-card-subtitle {
        font-size: 0.75rem;
        color: #94a3b8;
        margin-top: 2px;
    }

    .mobile-card-amount {
        font-size: 1.25rem;
        font-weight: 800;
        color: #11d483;
    }

    .mobile-card-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.375rem 0;
        border-top: 1px solid rgba(35, 72, 57, 0.5);
        font-size: 0.8125rem;
    }

    .mobile-card-label {
        color: #94a3b8;
        font-weight: 500;
    }

    .mobile-card-value {
        color: #e2e8f0;
        font-weight: 600;
        text-align: right;
    }

    .mobile-card-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.875rem;
        padding-top: 0.875rem;
        border-top: 1px solid rgba(35, 72, 57, 0.5);
    }

    .mobile-card-btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        height: 44px;
        border-radius: 10px;
        font-size: 0.8125rem;
        font-weight: 600;
        text-decoration: none;
        border: none;
        cursor: pointer;
        transition: opacity 0.15s, transform 0.1s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-card-btn:active {
        opacity: 0.8;
        transform: scale(0.97);
    }

    .mobile-card-btn.btn-view {
        background: rgba(148, 163, 184, 0.15);
        color: #e2e8f0;
    }

    .mobile-card-btn.btn-approve {
        background: rgba(34, 197, 94, 0.2);
        color: #4ade80;
    }

    .mobile-card-btn.btn-reject {
        background: rgba(239, 68, 68, 0.15);
        color: #f87171;
    }

    .mobile-card-btn.btn-delete {
        background: rgba(239, 68, 68, 0.1);
        color: #f87171;
        flex: 0 0 44px;
    }

    .mobile-card-btn.btn-primary {
        background: #11d483;
        color: #0a1a12;
    }

    /* ----- Primary action buttons: full-width, min 48px ----- */
    .mobile-action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        min-height: 52px;
        border-radius: 14px;
        font-size: 1rem;
        font-weight: 700;
        text-decoration: none;
        padding: 0.875rem 1.5rem;
        border: none;
        cursor: pointer;
        transition: opacity 0.15s, transform 0.1s;
        -webkit-tap-highlight-color: transparent;
        margin-bottom: 0.75rem;
    }

    .mobile-action-btn:active {
        opacity: 0.85;
        transform: scale(0.98);
    }

    .mobile-action-btn.primary {
        background: #11d483;
        color: #0a1a12;
    }

    .mobile-action-btn.secondary {
        background: rgba(17, 212, 131, 0.1);
        color: #11d483;
        border: 1px solid rgba(17, 212, 131, 0.3);
    }

    .mobile-action-btn.danger {
        background: rgba(239, 68, 68, 0.15);
        color: #f87171;
        border: 1px solid rgba(239, 68, 68, 0.3);
    }

    /* ----- Status tabs: scrollable strip ----- */
    .status-tabs-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        max-width: 100%;
        display: flex !important;
        padding-bottom: 2px;
    }

    .status-tabs-container::-webkit-scrollbar {
        display: none;
    }

    /* ----- Quick action grid for dashboards ----- */
    .mobile-quick-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }

    .mobile-quick-card {
        background: #162a22;
        border: 1px solid #234839;
        border-radius: 16px;
        padding: 1.125rem;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        min-height: 100px;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s, transform 0.1s;
    }

    .mobile-quick-card:active {
        background: #1c3329;
        transform: scale(0.97);
    }

    .mobile-quick-card .icon {
        font-size: 28px;
        line-height: 1;
    }

    .mobile-quick-card .label {
        font-size: 0.8rem;
        font-weight: 700;
        color: #e2e8f0;
    }

    .mobile-quick-card .sub {
        font-size: 0.7rem;
        color: #94a3b8;
    }

    /* ----- Stock/inventory tables: horizontal scroll allowed ----- */
    .stock-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ----- Form inputs: comfortable touch targets ----- */
    input,
    select,
    textarea {
        min-height: 48px;
        font-size: 16px !important;
        /* prevent iOS zoom */
        border-radius: 10px;
    }

    /* ----- Modal / bottom sheet  ----- */
    .mobile-bottom-sheet {
        position: fixed;
        bottom: 64px;
        left: 0;
        right: 0;
        background: #162a22;
        border-top: 1px solid #234839;
        border-radius: 20px 20px 0 0;
        padding: 1.5rem 1rem 1rem;
        z-index: 500;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.4);
    }

    .mobile-bottom-sheet.open {
        transform: translateY(0);
    }

    .bottom-sheet-handle {
        width: 36px;
        height: 4px;
        background: #234839;
        border-radius: 2px;
        margin: 0 auto 1.25rem;
    }

    .bottom-sheet-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 499;
        display: none;
        backdrop-filter: blur(2px);
    }

    .bottom-sheet-overlay.open {
        display: block;
    }

    /* ----- Adjust footer for mobile ----- */
    footer {
        margin-bottom: 0;
    }

    /* ----- Receipt review page header layout ----- */
    .flex.justify-between.items-center.mb-8 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }

    /* Page heading action buttons → full width on mobile */
    .flex.justify-between.items-center>a[class*="px-6 py-3"],
    .flex.justify-between.items-center>a[class*="bg-primary"] {
        width: 100% !important;
        justify-content: center;
        text-align: center;
    }

    /* Hide table wrapper that contains a <table> from desktop layout on pages that have mobile cards */
    .has-mobile-cards .overflow-x-auto {
        display: none !important;
    }

    .has-mobile-cards .desktop-table-section {
        display: none !important;
    }

    /* ----- No horizontal overflow anywhere ----- */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }

    img {
        height: auto;
    }

    /* prevent pre/code from blowing layout */
    pre,
    code {
        overflow-x: auto;
        white-space: pre-wrap;
        word-break: break-word;
    }
}

/* ------- TABLET (769px – 1024px) —keep desktop sidebar, tweak spacing ------- */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    #mobileBottomNav {
        display: none !important;
    }
}

/* ------- DESKTOP (≥1025px) —original layout fully restored ------- */
@media screen and (min-width: 1025px) {
    #mobileBottomNav {
        display: none !important;
    }

    /* Ensure desktop cards display properly */
    .receipts-card-list,
    .users-card-list,
    .finances-card-list,
    .withdrawals-card-list {
        display: none !important;
    }

    .receipts-table-wrapper,
    .users-table-wrapper,
    .finances-table-wrapper,
    .withdrawals-table-wrapper {
        display: block !important;
    }
}

/* ============================================================
   MORE TAB — BOTTOM SHEET OVERFLOW MENU
   ============================================================ */

/* Backdrop overlay */
#moreSheetOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9990;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

#moreSheetOverlay.open {
    display: block;
}

/* Bottom sheet panel */
#moreBottomSheet {
    position: fixed;
    bottom: 64px;
    /* sits just above the nav bar height */
    left: 0;
    right: 0;
    background: #162a22;
    border-top: 1px solid #234839;
    border-radius: 20px 20px 0 0;
    z-index: 9991;
    padding: 0 0 env(safe-area-inset-bottom, 0);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
    max-height: 60vh;
    overflow-y: auto;
    /* hide on desktop, controlled via JS + media */
}

#moreBottomSheet.open {
    transform: translateY(0);
}

/* Hide sheet entirely on desktop */
@media screen and (min-width: 769px) {

    #moreBottomSheet,
    #moreSheetOverlay {
        display: none !important;
    }
}

/* Drag handle */
.more-sheet-handle {
    width: 40px;
    height: 4px;
    background: #2d4d3d;
    border-radius: 2px;
    margin: 12px auto 4px;
    flex-shrink: 0;
}

/* Sheet header row */
.more-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 4px;
}

.more-sheet-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.more-sheet-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(148, 163, 184, 0.1);
    border: none;
    border-radius: 50%;
    color: #94a3b8;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.more-sheet-close:hover {
    background: rgba(148, 163, 184, 0.2);
}

/* Menu items list */
.more-sheet-items {
    padding: 8px 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.more-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    text-decoration: none;
    color: #e2e8f0;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.more-sheet-item:active {
    background: rgba(17, 212, 131, 0.08) !important;
    transform: scale(0.98);
}

.more-sheet-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.more-sheet-item.active-item {
    background: rgba(17, 212, 131, 0.1);
    color: #11d483;
}

.more-sheet-item .item-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}

.more-sheet-item .item-text {
    flex: 1;
}

.more-sheet-item .item-label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
}

.more-sheet-item .item-sublabel {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 1px;
}

/* "More" nav button active glow: when any overflow page is current */
.bottom-nav-item.more-active {
    color: #11d483 !important;
}

.bottom-nav-item.more-active span.material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}