/* ==========================================================
   admin-mobile.css  –  HappyBox Admin Mobile Optimization
   DESKTOP (≥769px): completely unchanged
   MOBILE  (≤768px): responsive cards, sticky header, thumb buttons
   ========================================================== */

/* ──────────────────────────────────────────────────────────
   SHARED VARIABLES (inherited from parent pages)
   ────────────────────────────────────────────────────────── */
:root {
    --mob-primary:    #059669;
    --mob-primary-dk: #064e3b;
    --mob-border:     #e2e8f0;
    --mob-text:       #0f172a;
    --mob-muted:      #64748b;
    --mob-radius:     14px;
}

/* ──────────────────────────────────────────────────────────
   ALWAYS-ON: Prevent horizontal word-breaks in badges/phones
   ────────────────────────────────────────────────────────── */
.status-pill,
.status-badge,
[style*="white-space:nowrap"],
a[href^="tel:"],
.mob-card-value a[href^="tel:"] {
    white-space: nowrap !important;
}

/* ──────────────────────────────────────────────────────────
   DESKTOP – hide mobile-only elements
   ────────────────────────────────────────────────────────── */
@media (min-width: 769px) {
    .mobile-row        { display: none !important; }
    #mobile-menu-btn   { display: none !important; }
    .mobile-only       { display: none !important; }
    .mob-sticky-header { display: none !important; }
    .mob-summary-cards { display: none !important; }
}

/* ──────────────────────────────────────────────────────────
   MOBILE – core layout resets
   ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Remove left padding from sidebar */
    body {
        padding-left: 0 !important;
        overflow-x: hidden;
    }

    /* Slide sidebar off-screen; toggled via .active */
    .sidebar-nav {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1010 !important;
        transform: translateX(-110%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto;
    }
    .sidebar-nav.active {
        transform: translateX(0) !important;
        box-shadow: 0 0 0 100vw rgba(0,0,0,0.45) !important;
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 1009;
    }
    .sidebar-overlay.active {
        display: block;
    }

    /* Shrink main padding on mobile */
    main, .dashboard-container, .container {
        padding: 72px 16px 24px !important;
        max-width: 100% !important;
    }

    /* ── STICKY MOBILE HEADER ── */
    .mob-sticky-header {
        display: flex !important;
        align-items: center;
        gap: 14px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1015 !important;
        background: white;
        border-bottom: 1px solid var(--mob-border);
        padding: 12px 16px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    .mob-sticky-header .mob-page-title {
        font-family: 'Plus Jakarta Sans', sans-serif;
        font-size: 1rem;
        font-weight: 800;
        color: var(--mob-text);
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mob-sticky-header .mob-live-dot {
        width: 8px; height: 8px;
        background: #22c55e;
        border-radius: 50%;
        animation: pulse 2s infinite;
        flex-shrink: 0;
    }

    /* Hamburger button */
    #mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        width: 44px;
        height: 44px;
        cursor: pointer;
        flex-shrink: 0;
        z-index: 1011;
        padding: 0;
        font-size: 24px;
        line-height: 1;
        color: var(--mob-text);
    }

    /* ── MOBILE SUMMARY CARDS (stats grid) ── */
    .mob-summary-cards {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }
    .mob-stat-card {
        background: white;
        border-radius: 14px;
        border: 1px solid var(--mob-border);
        padding: 14px 16px;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .mob-stat-label {
        font-size: 0.72rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--mob-muted);
    }
    .mob-stat-value {
        font-family: 'Fraunces', serif;
        font-size: 1.9rem;
        font-weight: 900;
        color: var(--mob-text);
        line-height: 1;
    }

    /* ── STACKING: desktop card grids → 2-column ── */
    .stats-grid,
    .kitchen-summary-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    /* Override any auto-fit minmax that's too wide for mobile */
    [style*="minmax(450px"] {
        grid-template-columns: 1fr !important;
    }
    [style*="minmax(240px"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* ── PARENT INSIGHTS: 6-column stat row → 2-column ── */
    .stats-grid-2 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    /* Override the inline 6-col style on the same element */
    .stats-grid-2[style] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ── HERO BANNER COMPACT ── */
    .hero-banner {
        padding: 20px 16px !important;
        border-radius: 16px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    .hero-banner h2 {
        font-size: 1.4rem !important;
        margin-bottom: 4px !important;
    }
    .hero-banner p  { font-size: 0.9rem !important; }
    .hero-banner > div:last-child { text-align: left !important; }

    /* ── DASH CARD PADDING ── */
    .dash-card,
    .panel-card { padding: 16px !important; border-radius: 16px !important; }

    /* ── TABLE: hide desktop, show mobile rows ── */
    .desktop-row { display: none !important; }
    .mobile-row  { display: block !important; }

    /* thead already hidden because all rows are mobile-row */
    .appt-table thead { display: none !important; }
    .appt-table,
    .appt-table tbody { display: block; width: 100%; }
    .appt-table tr.mobile-row { display: block; width: 100%; }
    .appt-table td.mobile-cell {
        display: block;
        width: 100%;
        padding: 0;
        border: none;
        margin-bottom: 12px;
    }

    /* ── table-scroll-wrap: visible by default (card view replaces table) ── */
    .table-scroll-wrap {
        overflow-x: visible !important;
        margin: -16px !important;
        padding: 16px !important;
    }

    /* ── SCHEDULE TABLE EXCEPTION: needs horizontal scroll on mobile ──
       Use .sched-scroll-wrap on the wrapping div in dashboard.php        */
    .sched-scroll-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 12px;
    }
    .sched-scroll-wrap table {
        min-width: 800px;
        white-space: nowrap;
    }
    .sched-scroll-wrap thead { display: table-header-group !important; }
    .sched-scroll-wrap .desktop-row { display: table-row !important; }
    .sched-scroll-wrap .mobile-row  { display: none !important; }
    .sched-scroll-wrap td,
    .sched-scroll-wrap th { white-space: nowrap; vertical-align: middle; }

    /* ── DAILY DASHBOARD: consolidatedTable scroll on mobile ──
       Use .daily-scroll-wrap on the wrapping div in daily_dashboard.php  */
    .daily-scroll-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 12px;
    }
    .daily-scroll-wrap table {
        min-width: 1400px;
    }
    .daily-scroll-wrap thead { display: table-header-group !important; }
    .daily-scroll-wrap .desktop-row { display: table-row !important; }
    .daily-scroll-wrap .mobile-row  { display: none !important; }
    .daily-scroll-wrap td,
    .daily-scroll-wrap th { white-space: nowrap; vertical-align: middle; }

    /* ── SEARCH BAR full-width ── */
    .table-controls    { flex-direction: column !important; align-items: stretch !important; }
    .search-box-wrap   { max-width: 100% !important; }
    .search-input      { font-size: 16px !important; }  /* prevent iOS zoom */

    /* ── TAB NAVIGATION: wrap tabs on small screens ── */
    #dashTabs {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    #dashTabs button {
        flex: 1 1 auto;
        min-width: 120px;
        font-size: 0.82rem !important;
        padding: 10px 14px !important;
    }

    /* ── NAV BREADCRUMB: stack buttons on mobile ── */
    [style*="gap: 12px; margin-bottom: 24px"] {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* ── BUTTONS – thumb-friendly (min 48px touch target) ── */
    button, .link-btn, .btn {
        min-height: 44px;
    }

    /* ── PHONE NUMBERS: never wrap ── */
    a[href^="tel:"] {
        white-space: nowrap !important;
        display: inline-block;
    }

    /* ── BADGES: never wrap ── */
    .status-pill,
    .status-badge,
    [style*="Pending"],
    [style*="Delivered"] {
        white-space: nowrap !important;
        display: inline-block;
    }

    /* ── PANEL TITLE: allow wrapping on small screens ── */
    .panel-title-wrap {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    .panel-title-wrap h3 {
        font-size: 1.2rem !important;
    }

    /* ── FONT SCALING ── */
    body { font-size: 15px; }
    h2   { font-size: 1.5rem !important; }
    h3   { font-size: 1.2rem !important; }

    /* ── STAT CARD value text ── */
    .stat-card .stat-value,
    .stat-item [style*="font-size: 2.2rem"],
    .stat-item [style*="font-size:2.2rem"] {
        font-size: 1.8rem !important;
    }

    /* ── DASHBOARD GRID (parent insights): single column ── */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* ── PANEL CARD: consistent padding ── */
    .panel-card {
        padding: 16px !important;
        border-radius: 16px !important;
        margin-bottom: 16px !important;
    }

    /* ── DATA TABLE: allow horizontal scroll ── */
    .table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: -16px !important;
        padding: 0 16px 16px !important;
    }
    .data-table {
        min-width: 900px !important;
    }
    .data-table td,
    .data-table th {
        white-space: nowrap !important;
        padding: 10px 12px !important;
    }

    /* ── BUTTON GROUPS: wrap action buttons ── */
    .mob-card-actions {
        flex-direction: column;
        gap: 8px;
    }

    /* ── HERO BANNER: reduce stat sub text on mobile ── */
    .stat-sub { font-size: 0.72rem !important; }
    .stat-label { font-size: 0.68rem !important; }
}

/* ── Extra-small screens (≤480px) ── */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    .stats-grid-2,
    .stats-grid-2[style] {
        grid-template-columns: 1fr !important;
    }
    .mob-summary-cards {
        grid-template-columns: 1fr 1fr !important;
    }
    .hero-banner h2 {
        font-size: 1.2rem !important;
    }
    .stat-card .stat-value {
        font-size: 1.6rem !important;
    }
}

/* ──────────────────────────────────────────────────────────
   MOBILE CARD COMPONENT (shared)
   ────────────────────────────────────────────────────────── */
.mob-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--mob-border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.mob-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--mob-border);
    padding-bottom: 10px;
    gap: 8px;
}
.mob-card-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--mob-primary);
    line-height: 1.2;
}
.mob-card-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 0.9rem;
    gap: 2px;
}
.mob-card-label {
    font-weight: 700;
    color: var(--mob-muted);
    font-size: 0.78rem;
    flex-shrink: 0;
}
.mob-card-value {
    font-weight: 600;
    color: var(--mob-text);
    text-align: left;
    font-size: 0.95rem;
    white-space: normal;
}
.mob-card-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}
.mob-btn-delivered {
    width: auto;
    max-width: 220px;
    min-height: 44px;
    padding: 0 20px;
    background: #059669;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.mob-btn-delivered:hover    { background: #047857; }
.mob-btn-delivered:disabled { background: #94a3b8; cursor: not-allowed; }
.mob-btn-delivered-done {
    width: auto;
    max-width: 220px;
    min-height: 44px;
    padding: 0 20px;
    background: #dcfce7;
    color: #16a34a;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: default;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}
.mob-btn-secondary {
    width: auto;
    max-width: 220px;
    min-height: 44px;
    padding: 0 20px;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.mob-btn-schedule {
    width: auto;
    max-width: 220px;
    min-height: 44px;
    padding: 0 20px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ──────────────────────────────────────────────────────────
   DELIVERY CONFIRMATION MODAL
   ────────────────────────────────────────────────────────── */
#hb-delivery-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 9990;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#hb-delivery-modal.open {
    display: flex;
}
.hb-modal-sheet {
    background: white;
    padding: 28px 24px;
    border-radius: 20px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: fadeInScale 0.2s ease-out;
}
@keyframes fadeInScale {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}
.hb-modal-handle {
    display: none;
}
.hb-modal-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 8px;
}
.hb-modal-title {
    font-family: 'Fraunces', serif;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    color: var(--mob-text);
    margin-bottom: 6px;
}
.hb-modal-subtitle {
    font-size: 0.9rem;
    color: var(--mob-muted);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
}
#hb-modal-student-name {
    font-weight: 800;
    color: var(--mob-primary-dk);
}
.hb-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.hb-modal-confirm {
    width: auto;
    min-height: 44px;
    padding: 0 24px;
    background: #059669;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}
.hb-modal-confirm:disabled { background: #94a3b8; cursor: not-allowed; }
.hb-modal-cancel {
    width: auto;
    min-height: 44px;
    padding: 0 24px;
    background: #f8fafc;
    color: var(--mob-muted);
    border: 1px solid var(--mob-border);
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ──────────────────────────────────────────────────────────
   TYPOGRAPHY MIN SIZES (mobile)
   ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    body { font-size: 15px; }
    .mob-card-value, .mob-card-label { font-size: 14px; }
}

/* ──────────────────────────────────────────────────────────
   PULSE ANIMATION (reused from parent)
   ────────────────────────────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(0.85); }
}

/* ── Custom overrides as requested ── */
@media (max-width: 575px) {
    /* Stack breadcrumb / nav-back strip vertically */
    [style*="gap: 12px; margin-bottom: 24px"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    [style*="gap: 12px; margin-bottom: 24px"] a,
    [style*="gap: 12px; margin-bottom: 24px"] button {
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    /* Allow horizontal scroll if sched-allow-scroll class is present */
    .table-scroll-wrap.sched-allow-scroll,
    .sched-scroll-wrap.sched-allow-scroll {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

@media (max-width: 360px) {
    /* Improve font scaling on very small screens */
    .hero-banner h2 {
        font-size: 1.05rem !important;
    }
    .hero-banner p {
        font-size: 0.8rem !important;
    }
    .stat-card .stat-value {
        font-size: 1.4rem !important;
    }
}
