/* ═══════════════════════════════════════════════════════════════
   ClaudeClaw — Mobile PWA Stylesheet
   Design: Cinema Dark Mobile (ui-ux-pro-max)
   Breakpoint: ≤ 768px
   ═══════════════════════════════════════════════════════════════ */

/* ── BOTTOM NAV (hidden on desktop) ─────────────────────────── */
#mobile-nav {
    display: none;
}

/* ── MOBILE MORE SHEET (hidden by default) ───────────────────── */
#mobile-more-sheet {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 300;
    background: rgba(8, 8, 14, 0.97);
    border-top: 1px solid rgba(20, 184, 166, 0.2);
    border-radius: 24px 24px 0 0;
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    padding: 0 0 env(safe-area-inset-bottom);
    transform: translateY(100%);
    transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -20px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
}
#mobile-more-sheet.open {
    transform: translateY(0);
}
#mobile-more-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 299;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}
#mobile-more-overlay.open { display: block; }

@media (max-width: 768px) {

/* ── GLOBAL MOBILE RESETS ────────────────────────────────────── */
* { -webkit-tap-highlight-color: transparent; }
html, body { overflow: hidden; height: 100%; overscroll-behavior: none; }
body { touch-action: manipulation; }

/* ── HIDE DESKTOP SIDEBAR ────────────────────────────────────── */
.sidebar { display: none !important; }

/* ── STAGE: full screen, account for bottom nav ─────────────── */
.stage {
    margin: 0 !important;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ── STAGE HEADER: compact mobile header ─────────────────────── */
.stage-header {
    border-radius: 0 !important;
    padding: 12px 16px !important;
    padding-top: calc(12px + env(safe-area-inset-top)) !important;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}
.stage-header h1 { font-size: 13px !important; letter-spacing: 1px !important; }
.stage-header p { font-size: 10px !important; margin-top: 1px !important; }
.stage-actions { gap: 6px !important; }
.stage-actions select { display: none; } /* hide provider selector on mobile */

/* ── STAGE BODY ───────────────────────────────────────────────── */
.stage-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0 !important;
    padding: 14px !important;
    overscroll-behavior: contain;
}

/* ── GRID COLLAPSE ────────────────────────────────────────────── */
.grid-4  { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
.grid-12 { grid-template-columns: 1fr !important; gap: 12px !important; }
.grid-3  { grid-template-columns: 1fr !important; gap: 10px !important; }
.grid-2  { grid-template-columns: 1fr !important; gap: 10px !important; }

/* ── CARDS: Cinema Dark mobile style ─────────────────────────── */
.card {
    border-radius: 16px !important;
    padding: 16px !important;
    background: rgba(255,255,255,0.04) !important;
    border-color: rgba(255,255,255,0.08) !important;
}
.card:hover { transform: none !important; } /* disable hover lift on touch */
.stat-card { padding: 14px !important; border-radius: 14px !important; }

/* ── TOUCH TARGETS: min 44×44px ──────────────────────────────── */
.btn { min-height: 44px; min-width: 44px; padding: 10px 16px !important; touch-action: manipulation; }
button { min-height: 44px; touch-action: manipulation; }
.nav-item { min-height: 44px; }

/* Tap press feedback */
.btn:active, button:active { transform: scale(0.97) !important; opacity: 0.85; transition: transform 0.1s, opacity 0.1s; }

/* ── COMMAND CENTER SECTION ───────────────────────────────────── */
.cmd-layout { display: flex; flex-direction: column; height: 100%; }
.cmd-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px !important;
}

/* Command input: fixed above bottom nav */
.cmd-input-area {
    position: fixed !important;
    bottom: calc(64px + env(safe-area-inset-bottom)) !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.08) !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    background: rgba(5, 5, 10, 0.92) !important;
    padding: 10px 12px !important;
    z-index: 50 !important;
}

/* Agent selector: horizontal scroll chips */
.agent-selector {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 8px !important;
    padding: 4px 2px 8px !important;
    scrollbar-width: none !important;
}
.agent-selector::-webkit-scrollbar { display: none; }
.agent-card {
    flex-shrink: 0 !important;
    min-width: 100px !important;
    max-width: 120px !important;
    padding: 10px 12px !important;
}

/* Live feed: stays compact */
.live-feed { max-height: 180px !important; }
#live-feed-entries { max-height: 160px !important; }

/* ── RATE LIMIT BANNER: mobile-aware ─────────────────────────── */
#rl-banner {
    flex-wrap: wrap !important;
    padding: 8px 14px !important;
    gap: 6px !important;
}
#rl-banner > span:last-child { display: none !important; }

/* ── INTEL / RESEARCH CARDS ──────────────────────────────────── */
.intel-card { padding: 16px !important; }
.intel-card-actions { flex-wrap: wrap !important; gap: 6px !important; }

/* ── CHAIN OF COMMAND: vertical on mobile ────────────────────── */
.coc-tree { flex-direction: column !important; align-items: center !important; }
.coc-level { flex-direction: row !important; flex-wrap: wrap !important; justify-content: center !important; gap: 8px !important; }
.agent-node { width: 100% !important; max-width: 320px !important; }

/* ── OPERATIONS: full width timeline ────────────────────────────*/
.ops-timeline .ops-item { padding: 12px 14px !important; }

/* ── HIDE LESS IMPORTANT DESKTOP ELEMENTS ────────────────────── */
.cost-tracker .cost-feed { max-height: 100px; overflow: hidden; }
.stage-header .btn-ghost { display: none; } /* hide desktop refresh btn */

/* ════════════════════════════════════════════════════════════════
   BOTTOM TAB BAR
   ════════════════════════════════════════════════════════════════ */
#mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(5, 5, 10, 0.88);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    box-shadow: 0 -4px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
    align-items: stretch;
    justify-content: space-around;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    font-family: 'Rajdhani', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 8px 4px 4px;
    position: relative;
    transition: color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    touch-action: manipulation;
}
.tab-item ion-icon {
    font-size: 22px !important;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
}
.tab-item.active {
    color: #14b8a6;
}
.tab-item.active ion-icon {
    transform: scale(1.12);
    filter: drop-shadow(0 0 6px rgba(20, 184, 166, 0.55));
}
.tab-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 28px; height: 2px;
    background: #14b8a6;
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 8px rgba(20, 184, 166, 0.6);
}
.tab-item:active {
    transform: scale(0.93);
}
.tab-item .tab-badge {
    position: absolute;
    top: 6px; right: calc(50% - 18px);
    background: #ef4444;
    color: white;
    font-size: 8px;
    font-weight: 800;
    min-width: 14px; height: 14px;
    border-radius: 7px;
    padding: 0 3px;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid #050508;
}

/* ════════════════════════════════════════════════════════════════
   MOBILE MORE SHEET (shown)
   ════════════════════════════════════════════════════════════════ */
#mobile-more-sheet {
    display: block !important;
}
#mobile-more-sheet .sheet-handle {
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin: 12px auto 8px;
}
#mobile-more-sheet .sheet-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #64748b;
    padding: 4px 20px 12px;
    font-family: 'Orbitron', monospace;
}
.sheet-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: #cbd5e1;
    font-family: 'Rajdhani', sans-serif;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    min-height: 52px;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.sheet-nav-item:active { background: rgba(255,255,255,0.05); }
.sheet-nav-item ion-icon {
    font-size: 20px !important;
    color: #475569;
    width: 24px;
    flex-shrink: 0;
}
.sheet-nav-item.active { color: #14b8a6; }
.sheet-nav-item.active ion-icon { color: #14b8a6; }
.sheet-nav-item .sheet-badge {
    margin-left: auto;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 8px;
}

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

/* ── TABLET: 769px–1024px (sidebar collapses to icon strip) ──── */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 68px !important; }
    .sidebar-title, .sidebar-sub, .nav-section, .nav-item > *:not(.nav-icon), .nav-badge, .sidebar-footer .status-text, .sidebar-footer .status-port { display: none !important; }
    .sidebar-header { padding: 18px 12px !important; justify-content: center; }
    .sidebar-logo { margin: 0 auto; }
    .nav { padding: 8px !important; gap: 4px !important; }
    .nav-item { padding: 12px 0 !important; justify-content: center; border-radius: 10px !important; }
    .nav-icon { width: 32px !important; height: 32px !important; }
    .sidebar-footer { padding: 10px 12px !important; }
    .system-status { justify-content: center; padding: 8px !important; }
    .status-dot { margin: 0 !important; }
}
