/**
 * caseready-mobile.css
 * ════════════════════════════════════════════════════════
 * Shared responsive / mobile styles for all CaseReady modules.
 * Loaded via <link> on every HTML page after the module's own <style>.
 *
 * Breakpoints:
 *   768px  — tablet portrait / small laptop (sidebar collapses)
 *   600px  — large phone landscape / small tablet
 *   480px  — phone portrait (single-column everything)
 *   400px  — small phone (font/padding reductions)
 * ════════════════════════════════════════════════════════
 */

/* ── BASE: ensure no horizontal overflow on any module ── */
html, body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ── TYPOGRAPHY: scale down on small screens ── */
@media (max-width: 480px) {
  body { font-size: 14px; }
}

/* ── TOPBAR ── */
@media (max-width: 600px) {
  .topbar { padding: 0 12px; }
  .tb-title { display: none; } /* Hide subtitle on small screens */
  .tb-right { gap: 4px; }
  .tb-btn { padding: 4px 9px; font-size: 11px; }
  /* Hide lower-priority topbar buttons on very small screens */
  .tb-btn.tb-ghost:nth-child(n+3) { display: none; }
}

/* ── MAIN TABS (tab navigation bar) ── */
.main-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.main-tabs::-webkit-scrollbar { display: none; }

@media (max-width: 600px) {
  .main-tab { padding: 9px 13px; font-size: 12px; }
}

/* ── CONTENT AREA ── */
@media (max-width: 600px) {
  .content { padding: 12px; }
  .max { max-width: 100%; }
}

/* ── CARDS ── */
@media (max-width: 480px) {
  .card { padding: 14px; }
  .card-title { font-size: 14px; }
}

/* ── GRID COLLAPSE ── */
/* 2-column grids → 1 column on phone */
@media (max-width: 600px) {
  .grid2, .g2 { grid-template-columns: 1fr !important; }
}

/* 3-column grids → 2 columns on tablet, 1 on phone */
@media (max-width: 768px) {
  .grid3, .g3 { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 480px) {
  .grid3, .g3 { grid-template-columns: 1fr !important; }
}

/* 4-column grids → 2 columns always on mobile */
@media (max-width: 768px) {
  .grid4, .g4, .stats-row {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── MODALS ── */
/* On mobile, modals slide up from bottom as a sheet */
@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 92vh !important;
  }
  .modal-hdr { padding: 14px 16px; }
  .modal-body { padding: 14px 16px 20px; }
  .modal-footer { padding: 10px 16px; }
}

/* ── FORMS ── */
@media (max-width: 480px) {
  input, textarea, select {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    padding: 10px 11px;
  }
  label { font-size: 10px; }
}

/* ── BUTTONS ── */
@media (max-width: 480px) {
  .btn { padding: 9px 14px; font-size: 13px; }
  .btn-row { gap: 6px; }
}

/* ── INCIDENT JOURNAL SPECIFIC ── */
/* Category grid: 2 columns max on mobile */
@media (max-width: 600px) {
  .cat-grid { grid-template-columns: 1fr 1fr !important; }
  .cat-btn  { font-size: 12px; padding: 8px 10px; }
}
@media (max-width: 400px) {
  .cat-grid { grid-template-columns: 1fr !important; }
}

/* Actor pills: wrap naturally */
.actor-pills { flex-wrap: wrap; }

/* Journal card: adjust padding */
@media (max-width: 480px) {
  .journal-item { padding: 12px; }
  .ji-actors { flex-wrap: wrap; gap: 5px; }
}

/* Calendar grid: allow horizontal scroll, keep usable */
.cal-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Stats row in journal */
@media (max-width: 480px) {
  .stats-strip { flex-wrap: wrap; }
  .stat-item { flex: 0 0 50%; min-width: 0; }
}

/* ── DASHBOARD SPECIFIC ── */
@media (max-width: 600px) {
  .hero { padding: 20px 16px 14px; }
  .hero-greeting { font-size: 22px; }
  .hero-sub { font-size: 13.5px; }
  .input-box { border-radius: 10px; }
  .chips { gap: 6px; }
  .chip { font-size: 12px; padding: 7px 13px; }
  .bubble { font-size: 13.5px; }
  .tool-cards { gap: 8px; }
  .tool-card { padding: 12px; }
  .tc-name { font-size: 13px; }
  .reg-callout { padding: 10px 12px; }
  .conv-area { padding-left: 12px; padding-right: 12px; }
  .daily-reminder { padding: 14px 16px; }
}

/* Sticky input full-width on mobile */
@media (max-width: 768px) {
  .sticky-input { left: 0 !important; padding: 10px 16px 14px; }
  .si-wrap textarea { font-size: 16px; } /* prevent iOS zoom */
}

/* ── MESSAGE COACH SPECIFIC ── */
@media (max-width: 600px) {
  .severity-bar { flex-wrap: wrap; }
}

/* ── EVIDENCE MODULES ── */
@media (max-width: 600px) {
  .ev-type-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ── FINANCIAL TRACKER / ANALYSIS ── */
@media (max-width: 600px) {
  .stat-box { padding: 10px 12px; }
  .stat-num { font-size: 18px; }
  .entry-row { flex-direction: column; gap: 8px; }
  .er-amount { text-align: left; }
}

/* ── MEDIA EVIDENCE ── */
@media (max-width: 600px) {
  .type-row { flex-wrap: wrap; }
  .type-btn { flex: 1 1 45%; }
  .mc-top { flex-direction: column; }
  .mc-thumb { width: 100%; height: 44px; border-radius: 6px 6px 0 0; }
}

/* ── MOTION TEMPLATES ── */
@media (max-width: 600px) {
  .motion-grid { grid-template-columns: 1fr !important; }
}

/* ── TESTIMONY PREP ── */
@media (max-width: 600px) {
  .session-panel { padding: 14px; }
  .answer-input-wrap { flex-direction: column; }
}

/* ── WITNESS MANAGER ── */
@media (max-width: 600px) {
  .witness-card { flex-direction: column; }
}

/* ── HEARING CALENDAR ── */
@media (max-width: 600px) {
  .task-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .task-meta { flex-wrap: wrap; }
}

/* ── PATTERN REPORT ── */
@media (max-width: 600px) {
  .pattern-alert { padding: 12px; }
}

/* ── AUTH PAGE ── */
@media (max-width: 480px) {
  .panel { border-radius: 0; min-height: 100vh; width: 100%; }
  .panel-header { padding: 24px 20px 20px; }
  .panel-body { padding: 20px; }
}

/* ── FLOATING ACTION BUTTON (mobile incident logging) ── */
/* A prominent FAB for "Log Incident" on the Incident Journal on mobile */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--gold, #c9a84c);
  color: var(--navy, #1a2540);
  font-size: 26px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  z-index: 400;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.mobile-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
@media (min-width: 601px) { .mobile-fab { display: none !important; } }

/* ── CASEY WIDGET MOBILE ── */
/* Widget panel: full-screen on mobile */
@media (max-width: 480px) {
  #cr-widget-panel {
    width: 100vw !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 85vh !important;
  }
  #cr-widget-btn {
    bottom: 16px !important;
    right: 16px !important;
    width: 52px !important;
    height: 52px !important;
    font-size: 22px !important;
  }
  #cr-cp-ta { font-size: 16px !important; } /* prevent iOS zoom */
}

/* ── UTILITY ── */
@media (max-width: 600px) {
  .hidden-mobile { display: none !important; }
}
@media (min-width: 601px) {
  .mobile-only { display: none !important; }
}

/* Prevent pull-to-refresh on content areas */
.content { overscroll-behavior: contain; }

/* ── MOBILE BOTTOM NAV BAR ──────────────────────────────────────────────
 * Appears on all tool pages on mobile only.
 * Gives users a permanent "return to Casey" affordance.
 * Injected by caseready-mobile.css — activated via JS in casey-widget.js
 * ----------------------------------------------------------------------- */
#cr-mobile-bar {
  display: none;
}
@media (max-width: 600px) {
  #cr-mobile-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--navy, #1a2540);
    border-top: 1px solid rgba(255,255,255,.1);
    z-index: 390;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    font-family: 'DM Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
  }
  #cr-mobile-bar a,
  #cr-mobile-bar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: rgba(255,255,255,.5);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: all .15s;
    min-width: 56px;
    font-family: 'DM Sans', sans-serif;
  }
  #cr-mobile-bar a:hover,
  #cr-mobile-bar button:hover {
    color: rgba(255,255,255,.85);
    background: rgba(255,255,255,.07);
  }
  #cr-mobile-bar a.active,
  #cr-mobile-bar button.active {
    color: var(--gold-light, #e4c97a);
  }
  #cr-mobile-bar .cmb-icon {
    font-size: 20px;
    line-height: 1;
  }
  #cr-mobile-bar .cmb-label {
    font-size: 9.5px;
    line-height: 1;
    letter-spacing: .2px;
  }
  /* Push content up so bar doesn't cover it */
  .content,
  body > .content,
  .main {
    padding-bottom: 56px !important;
  }
  /* Hide FAB when mobile bar is shown, since bar has log button */
  .mobile-fab {
    bottom: 72px !important;
  }
}
