/* ============================================================================
   Nirṇaya-Sārathī — phone layout (v2.14, zonal installs only; 2026-10-16)
   Loaded by _zc_sidebar.html and index.html inside {% if zonal_enabled %}, so
   a 2.13 site's pages are untouched (scripts/zc/gate_flag_off.sh).

   What a phone showed before: the module menu was translated off-screen by
   features.css with NOTHING to open it; page headers squeezed the title into
   a narrow column beside their buttons; the planner kept two panels side by
   side; the sign-on filters had 220 px minimum widths; the map page was laid
   out 720 px wide by its stat row. Everything here is inside one breakpoint.
   ============================================================================ */
.zc-appbar, .zc-scrim { display: none; }

@media (max-width: 768px) {
    html, body { max-width: 100%; overflow-x: hidden; }

    /* ── top bar + slide-out menu (feature pages) ─────────────────────────── */
    body.zc-has-appbar { padding-top: 52px; }
    .zc-appbar {
        display: flex; position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 190;
        align-items: center; gap: 4px; padding: 0 6px;
        background: rgba(15, 23, 42, 0.97); border-bottom: 1px solid rgba(148, 163, 184, 0.14);
        backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    }
    .zc-appbar button, .zc-appbar a {
        flex: 0 0 auto; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
        background: none; border: 0; border-radius: 10px; color: #cbd5e1; font-size: 18px; text-decoration: none;
    }
    .zc-appbar button:active, .zc-appbar a:active { background: rgba(148, 163, 184, 0.15); }
    .zc-appbar .zc-ab-title {
        flex: 1; min-width: 0; font-size: 15px; font-weight: 700; color: #e2e8f0;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .zc-appbar .zc-ab-title i { color: #38bdf8; margin-right: 6px; }
    .feature-sidebar { width: min(84vw, 300px) !important; z-index: 200 !important;
                       top: 0 !important; height: 100dvh !important; }
    .feature-sidebar.mobile-open { box-shadow: 12px 0 40px rgba(0, 0, 0, 0.55); }
    /* any other page menu made a drawer by zc_mobile.js (Admin's own sidebar) */
    .zc-drawer { position: fixed !important; top: 0 !important; left: 0; height: 100dvh !important;
                 width: min(84vw, 300px) !important; z-index: 200 !important;
                 transform: translateX(-100%); transition: transform 0.3s ease; }
    .zc-drawer.mobile-open { transform: none; box-shadow: 12px 0 40px rgba(0, 0, 0, 0.55); }
    .zc-scrim.show { display: block; position: fixed; inset: 0; z-index: 199; background: rgba(2, 6, 23, 0.6); }
    body.zc-drawer-open { overflow: hidden; }

    /* ── every feature page ───────────────────────────────────────────────── */
    .feature-main { margin-left: 0 !important; padding: 12px 12px 28px !important; min-width: 0; max-width: 100vw; }
    .page-header {
        flex-direction: column !important; align-items: stretch !important; gap: 10px;
        margin-bottom: 12px !important; padding-bottom: 10px !important;
    }
    .page-header > * { min-width: 0; max-width: 100%; }
    .page-title { font-size: 20px !important; line-height: 1.25 !important; }
    body.zc-has-appbar .page-title { display: none; }   /* the top bar names the page */
    .page-title i { font-size: 17px; }
    .page-subtitle {
        font-size: 12px !important; line-height: 1.4;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    }
    .header-actions { display: flex !important; flex-wrap: wrap; gap: 8px; justify-content: flex-start !important; }
    .page-header .btn, .header-actions .btn { padding: 8px 12px; font-size: 12px; }
    .btn { min-height: 38px; }
    .panel { padding: 12px !important; border-radius: 12px; }
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    /* 16 px stops iOS zooming into a field on focus */
    select, textarea,
    input[type="text"], input[type="search"], input[type="date"], input[type="number"],
    input[type="datetime-local"], input[type="time"], input[type="password"] {
        max-width: 100%; min-width: 0; box-sizing: border-box; font-size: 16px; }
    .modal-card { width: 96vw !important; max-width: none !important; }

    /* ── Crew Board / Relief / Summary ────────────────────────────────────── */
    #zcAsOf .zc-muted { display: none; }          /* the raw batch key */
    .zc-tiles, .cs-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
    .zc-tile { padding: 10px 12px !important; }
    .zc-tile .v { font-size: 24px !important; }
    .zc-tile .l { font-size: 9px; letter-spacing: 0.6px; }
    .zc-tile .asof { position: static; display: block; margin-bottom: 2px; }

    /* ── Crew Planner ─────────────────────────────────────────────────────── */
    #alertStrip { padding: 8px 12px !important; }
    .planner-panels { grid-template-columns: minmax(0, 1fr) !important; height: auto !important; }
    .planner-panel { max-height: 72vh; }
    .page-tabs { overflow-x: auto; scrollbar-width: none; }
    .crew-panel-tabs { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; gap: 6px; }
    .crew-panel-tabs .p-tab { flex: 0 0 auto; white-space: nowrap; }
    .page-tabs::-webkit-scrollbar, .crew-panel-tabs::-webkit-scrollbar { display: none; }
    .assign-fab { bottom: 18px !important; max-width: calc(100vw - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* ── Crew Sign-On ─────────────────────────────────────────────────────── */
    .mf-row { flex-direction: column; align-items: stretch !important; gap: 10px !important; }
    .mf-group { width: 100%; }
    .mf-select, .file-input, #filterSearch { min-width: 0 !important; width: 100% !important; }
    .summary-card { min-width: calc(50% - 6px) !important; padding: 10px 12px !important; }

    /* ── Admin and Reports (their own layouts) ────────────────────────────── */
    .admin-container .main-content { margin-left: 0 !important; padding: 12px !important; min-width: 0; max-width: 100vw; }
    .admin-container .main-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-container .main-content .page-title { display: block; font-size: 18px !important; }
    body > .container { padding: 12px !important; max-width: 100vw; }
    .filter-panel { padding: 12px !important; }

    /* ── Live map (index.html) ────────────────────────────────────────────── */
    .dashboard-container { grid-template-columns: minmax(0, 1fr) !important; }
    .dashboard-container .header { flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px !important; }
    .dashboard-container .header .logo-text span { display: none; }
    .dashboard-container .header .logo-text h1 { font-size: 15px; }
    .header-stats {
        order: 3; flex: 1 0 100%; max-width: 100%; flex-wrap: nowrap !important;
        overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 6px !important;
    }
    .header-stats::-webkit-scrollbar { display: none; }
    .header-stats .stat-item { flex: 0 0 auto; padding: 6px 10px !important; min-width: 0 !important; }
    .map-container { height: calc(100dvh - 118px) !important; min-height: 360px; }
    #notifDrawer { width: 100vw !important; }
    /* legend: folded to its title on a phone, a tap opens it */
    .map-legend { max-width: calc(100vw - 24px); max-height: 60vh; overflow-y: auto; }
    .map-legend .legend-title { cursor: pointer; margin-bottom: 0 !important; }
    .map-legend .legend-title::after { content: ' \25B4'; color: #64748b; }
    .map-legend:not(.zc-legend-open) .legend-title::after { content: ' \25BE'; }
    .map-legend:not(.zc-legend-open) > :not(.legend-title) { display: none !important; }
    .map-legend:not(.zc-legend-open) { padding: 8px 12px !important; }
}
