/* ═══ JVD Responsive — Mobile & Tablet ═══ */
/* Loaded via <link> on all pages. Overrides inline desktop styles. */

/* ─── Mobile bottom nav (injected by mobile-nav.js) ─── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: var(--surface, #0c0d1e);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
}
.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--dim, #b8bdd4);
  font-size: 10px;
  font-family: 'DM Sans', sans-serif;
  padding: 4px 2px;
  border-radius: 8px;
  transition: color .15s;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav a.active {
  color: #c4b5fd;
}
.mobile-nav a:active {
  background: rgba(139,124,248,0.12);
}
.mobile-nav .mn-icon {
  font-size: 20px;
  line-height: 1;
}
.mobile-nav .mn-icon img {
  width: 20px; height: 20px;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 0 2px rgba(255,255,255,.1));
}
.mobile-nav a.active .mn-icon img {
  filter: brightness(0) invert(0.8) sepia(1) hue-rotate(220deg) saturate(3);
}
.mobile-nav .mn-label {
  font-size: 9.5px;
  white-space: nowrap;
}

/* ─── Dropbox new-file indicator ─── */
.dropbox-new-dot {
  position: absolute;
  top: 2px; right: 6px;
  width: 8px; height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid var(--surface, #0c0d1e);
  pointer-events: none;
}

/* ─── Mobile header bar ─── */
.mobile-header {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface, #0c0d1e);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  position: sticky;
  top: 0;
  z-index: 100;
}
.mobile-header .mh-logo {
  width: 28px; height: 28px;
  filter: drop-shadow(0 0 6px rgba(255,70,20,.45));
}
.mobile-header .mh-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #e2e4f6);
  flex: 1;
}
.mobile-header .mh-status {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green, #00e87a);
  box-shadow: 0 0 6px rgba(0,232,122,.6);
}

/* ═══ TABLET (≤ 1024px) ═══ */
@media (max-width: 1024px) {
  .sidebar {
    width: 180px !important;
    min-width: 180px !important;
  }
  .main {
    padding: 22px 20px 20px !important;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ═══ MOBILE (≤ 768px) ═══ */
@media (max-width: 768px) {
  /* Hide desktop sidebar, show mobile nav */
  .sidebar {
    display: none !important;
  }
  .mobile-nav {
    display: flex !important;
  }
  .mobile-header {
    display: flex !important;
  }

  /* Main content adjustments */
  body {
    flex-direction: column !important;
    height: auto !important;
    overflow: auto !important;
  }
  .main {
    padding: 16px 14px 80px !important; /* 80px = bottom nav height */
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
  }

  /* Typography */
  .page-title {
    font-size: 20px !important;
  }
  .page-sub {
    font-size: 12px !important;
  }
  .stat-val, .hstat-val {
    font-size: 22px !important;
  }
  .stat-label, .hstat-label {
    font-size: 11.5px !important;
  }

  /* Page header — stack on mobile */
  .page-header {
    flex-direction: column !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }
  .status-pill {
    align-self: flex-start;
    font-size: 12px !important;
    padding: 5px 10px !important;
  }

  /* Stat cards */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .stat {
    padding: 14px 14px 12px !important;
    border-radius: 12px !important;
  }

  /* Two-column layouts → stack */
  .two-col {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Cards */
  .card {
    padding: 14px !important;
    border-radius: 12px !important;
  }

  /* Trend chart — responsive SVG */
  .trend-chart svg,
  #trendChart svg,
  .chart-wrap svg {
    width: 100% !important;
    height: auto !important;
  }

  /* Donut — scale down */
  .donut-wrap svg {
    max-width: 180px;
    margin: 0 auto;
    display: block;
  }

  /* Provider cards grid */
  #providers-wrap {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Sessions rows */
  .sess-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  /* Tab bars (agents, etc.) */
  .agent-tab-bar,
  .tab-bar {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 2px !important;
  }
  .agent-tab-bar::-webkit-scrollbar,
  .tab-bar::-webkit-scrollbar {
    display: none;
  }
  .agent-tab,
  .tab-item {
    white-space: nowrap;
    min-width: max-content;
    font-size: 13px !important;
    padding: 8px 12px !important;
  }

  /* Tasks kanban → vertical stack */
  .kanban-board {
    flex-direction: column !important;
    gap: 16px !important;
  }
  .kanban-col {
    min-width: auto !important;
    width: 100% !important;
  }

  /* Chat — already mostly OK, just adjust padding */
  .chat-messages,
  #messages {
    padding: 10px !important;
  }
  .bubble {
    max-width: 92% !important;
  }
  .input-bar {
    padding: 8px !important;
    gap: 6px !important;
  }
  #msgInput {
    font-size: 16px !important; /* prevent iOS zoom */
  }

  /* Journal/Schedule cards */
  .journal-grid,
  .schedule-grid {
    grid-template-columns: 1fr !important;
  }

  /* Modals — full screen on mobile */
  .modal-box,
  .confirm-box {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    margin: auto !important;
    border-radius: 14px !important;
  }

  /* Month navigation */
  .month-nav {
    flex-wrap: wrap !important;
    justify-content: center !important;
  }

  /* Overview sections */
  .section-cards-grid {
    grid-template-columns: 1fr !important;
  }

  /* Touch optimization */
  a, button, .nav-item, .agent-tab, .tab-item, .kanban-card {
    -webkit-tap-highlight-color: transparent;
  }

  /* Org chart — horizontal scroll */
  .org-chart-wrap,
  #orgChart {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* 2nd Brain notes grid */
  .notes-grid {
    grid-template-columns: 1fr !important;
  }

  /* Hide desktop-only elements */
  .sidebar-footer {
    display: none !important;
  }
}

/* ═══ SMALL PHONE (≤ 390px) ═══ */
@media (max-width: 390px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
  .page-title {
    font-size: 18px !important;
  }
  .stat-val, .hstat-val {
    font-size: 20px !important;
  }
  .mobile-nav .mn-label {
    font-size: 8.5px;
  }
  .main {
    padding: 12px 10px 80px !important;
  }
}

/* ═══ PWA Standalone fixes ═══ */
@media (display-mode: standalone) {
  body {
    /* Safe area for iPhone notch */
    padding-top: env(safe-area-inset-top, 0px);
  }
  .mobile-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
}
