/* ─────────────────────────────────────────────
   DCAA Mobile Styles
   Applied on screens ≤ 768px
   Desktop layout is completely untouched.
───────────────────────────────────────────── */

@media (max-width: 768px) {

  /* ── Hide desktop sidebar: slide off-screen so hamburger animation works ── */
  .sidebar {
    position: fixed !important;
    left: 0 !important; top: 0 !important; bottom: 0 !important;
    transform: translateX(-100%) !important;
    transition: transform .25s ease !important;
    z-index: 200 !important;
    display: flex !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }

  /* ── Main content: full width, bottom padding for tab bar ── */
  .main {
    margin-left: 0 !important;
    padding: 20px 16px 88px !important;
    max-width: 100% !important;
  }

  /* Encyclopedia / roster split layout: list col goes full width */
  .main:has(.list-col) {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
  }
  .list-col {
    width: 100% !important;
    border-right: none !important;
    min-height: auto !important;
    padding-bottom: 0 !important;
  }
  .list-head { padding: 20px 16px 12px !important; }
  .sub { padding: 0 16px 12px !important; }

  /* Detail panel: hidden by default on mobile, full-screen when open */
  .detail {
    display: none !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 500 !important;
    background: #0f0f0f !important;
    overflow-y: auto !important;
    padding: 56px 16px 88px !important;
  }
  .detail.m-open {
    display: block !important;
  }

  /* ── Typography ── */
  h1 { font-size: 18px !important; }
  h2 { font-size: 16px !important; }

  /* ── Two-column grids → single column ── */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .seg-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .voices-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .pulse-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Tables: horizontal scroll (opt-in via .mob-scroll) ── */
  /* Individual pages that need card layouts handle their own table CSS */
  .mob-scroll {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
  }

  /* ── Scripts upload box ── */
  .upload-box { padding: 20px 16px !important; }
  .upload-row { flex-direction: column !important; gap: 12px !important; }
  .upload-row .btn { width: 100% !important; }

  /* ── Coverage modal (scripts.html) ── */
  .overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .overlay .modal {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    padding: 28px 20px !important;
    margin: 0 !important;
  }
  .modal-actions { flex-wrap: wrap !important; gap: 8px !important; }
  .modal-actions a, .modal-actions button { flex: 1 !important; text-align: center !important; }

  /* ── Admin ── */
  .tabs { overflow-x: auto !important; white-space: nowrap !important; flex-wrap: nowrap !important; }
  .tab { padding: 10px 14px !important; flex-shrink: 0 !important; }
  .mgr-card, .form-box { margin-bottom: 12px !important; }

  /* ── Forecast ── */
  .overall-banner {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 16px !important;
  }
  .overall-info { text-align: left !important; }
  .seg-card { padding: 16px !important; }
  .setup-form { padding: 20px 16px !important; }
  .seg-top { gap: 10px !important; }

  /* ── Manager pages ── */
  .t-card { margin-bottom: 10px !important; }
  .t-header { padding: 14px 16px !important; }
  .t-body { padding: 0 16px 16px !important; }
  .alert-cards { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .deal-card { margin-bottom: 10px !important; }

  /* ── Messages ── */
  .msg-layout, .conv-layout { flex-direction: column !important; }

  /* ── Topbar ── */
  .topbar { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; margin-bottom: 20px !important; }

  /* ── Owner page ── */
  .stat-grid { grid-template-columns: 1fr 1fr !important; }

  /* ── Touch targets ── */
  .btn, .btn-sm, .btn-xs, button { min-height: 40px !important; }
  select, input, textarea { font-size: 16px !important; } /* prevents iOS zoom */

  /* ── ZOE pill: full width, attached to viewport bottom ── */
  #zoe-pill {
    width: calc(100vw - 24px) !important;
    left: 12px !important;
    right: 12px !important;
    transform: none !important;
    bottom: env(safe-area-inset-bottom, 0px) !important;
    border-radius: 0 !important;
    border-top: 1px solid #1e1e1e !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
  }
  #zoe-bar { width: 100% !important; box-sizing: border-box !important; border-radius: 0 !important; }
  #zoe-panel { width: 100% !important; }
  #zoe-textarea { font-size: 16px !important; }

  /* ── Messages FAB: lower right ── */
  #msg-fab { bottom: 80px !important; right: 12px !important; }
  #msg-tray { right: 12px !important; width: calc(100vw - 24px) !important; }

  /* ── Bottom chat panels: full-width stacked ── */
  .chat-panel {
    width: calc(100vw - 24px) !important;
    right: 12px !important;
    bottom: 60px !important;
  }

  /* ── Notification bell: don't overlap page buttons ── */
  #notif-bell-wrap { top: 12px !important; right: 12px !important; }

  /* ── Page head: account for hamburger on left and bell on right ── */
  .page-head { padding: 0 52px 0 52px !important; }
  .page-head h1 { padding-left: 0 !important; font-size: 16px !important; }
  .topbar h1 { padding-left: 0 !important; }
}

@media (max-width: 480px) {
  .seg-grid { grid-template-columns: 1fr !important; }
  .voices-grid { grid-template-columns: 1fr !important; }
  .main { padding: 16px 12px 88px !important; }
  .alert-cards { grid-template-columns: 1fr !important; }
}

/* ─────────────────────────────────────────────
   MOBILE BOTTOM TAB BAR
───────────────────────────────────────────── */

#m-tabbar {
  display: none; /* shown only on mobile via JS */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9200;
  background: #0a0a0a;
  border-top: 1px solid #1e1e1e;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0,0,0,.5);
}

.m-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: #444;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  transition: color .15s;
  min-height: 52px;
}
.m-tab:hover { color: #aaa; }
.m-tab.m-active { color: #fff; }
.m-tab svg { width: 20px; height: 20px; flex-shrink: 0; }
.m-tab .m-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: #f87171;
  color: #fff;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  border: 2px solid #0a0a0a;
}
.m-tab { position: relative; }

/* Back button injected on split panels */
#m-back-btn {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 501;
  background: #0a0a0a;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
#m-back-btn svg { width: 18px; height: 18px; color: #888; flex-shrink: 0; }
