/* ============================================================
   Vera CC Tracker — Mobile Responsive Styles
   Served at /static/responsive.css via StaticFiles mount
   Breakpoints: mobile ≤640px | tablet 641–768px | desktop >768px

   LOAD ORDER NOTE: This file loads before inline <style> blocks.
   Use !important only where inline CSS would otherwise win the cascade.
   Documented at each use site.
   ============================================================ */

/* ============================================================
   FOUNDATION — overflow + font baseline
   ============================================================ */

/* Prevent any element from causing horizontal body scroll */
html, body { overflow-x: hidden; max-width: 100%; }

/* UX rule: minimum 16px body text on mobile for readability */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding: 16px; }
}

/* ============================================================
   TABLE RESPONSIVE WRAPPER
   ============================================================ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Widget has overflow:hidden — release on mobile so .table-responsive can scroll */
@media (max-width: 768px) {
  .widget { overflow: visible; }
}

/* Reduce table cell padding on mobile — less wasted space, more data visible */
@media (max-width: 640px) {
  th { padding: 7px 10px !important; font-size: 10px; }
  td { padding: 8px 10px !important; font-size: 12px; }
}

/* Column priority hide on mobile */
@media (max-width: 640px) {
  .col-hide-mobile { display: none !important; }
}

/* ============================================================
   TOPBAR — Hamburger Navigation
   ============================================================ */

/* Hamburger: hidden on desktop. 44×44px touch target (UX rule). */
.tb-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: rgba(0,0,0,0.10);
  border: none;
  cursor: pointer;
  color: #0f2e12;
  flex-shrink: 0;
  transition: background .15s;
}
.tb-hamburger:hover  { background: rgba(0,0,0,0.20); }
.tb-hamburger:active { background: rgba(0,0,0,0.28); }

@media (max-width: 768px) {
  /* Show hamburger, hide email text */
  .tb-hamburger { display: flex; }
  .tb-email     { display: none !important; }

  /* Gear button: enlarge to 44×44px touch target */
  .gear-btn {
    width:  44px !important;
    height: 44px !important;
    border-radius: 8px !important;
  }

  /* Topbar: fixed 56px height kept — hamburger nav sits below it at fixed top:56px */
  .topbar { padding: 0 14px; }

  /* Nav: hidden by default on mobile.
     !important needed: responsive.css loads BEFORE inline <style> blocks,
     so inline .tb-nav { display:flex; position:absolute; transform:translateX(-50%) }
     wins the cascade without !important. */
  .tb-nav {
    display: none !important;
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    right: 0 !important;
    flex-direction: column;
    height: auto !important;
    transform: none !important;
    background: #5ba832;
    border-top: 1px solid rgba(0,0,0,0.15);
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    z-index: 200;
    padding: 6px 0;
  }
  .tb-nav.mob-open { display: flex !important; }

  /* Nav links: full-width, 44px touch target */
  .tb-link {
    width: 100%;
    padding: 0 22px !important;
    min-height: 44px;
    height: auto !important;
    font-size: 14px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.07);
  }
  .tb-link::after { display: none !important; }

  /* Gear dropdown: keep within right edge of screen */
  .gear-dropdown { right: 0 !important; left: auto !important; }
}

/* ============================================================
   DATE FILTER BAR & CONTROLS
   ============================================================ */
@media (max-width: 640px) {
  /* Wrap date buttons naturally — don't stack them individually */
  .date-bar,
  .controls { flex-wrap: wrap; gap: 6px; align-items: flex-start; }

  /* Date separator not useful when wrapping */
  .date-sep { display: none; }

  /* Date input group and sort group take full row */
  .date-input-group { width: 100%; gap: 6px; }
  .date-input-group input[type="date"] { flex: 1; min-width: 90px; }
  .sort-group { width: 100%; margin-left: 0; gap: 8px; }
  select      { width: 100%; min-height: 40px; }

  /* Touch targets: all action buttons ≥44px tall */
  .date-btn  { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .btn-apply { min-height: 40px; padding: 8px 14px; }
  input[type="date"] { min-height: 40px; padding: 8px 10px; }
}

/* ============================================================
   PAGE HEADER — stack title + date picker on mobile
   ============================================================ */
@media (max-width: 640px) {
  /* !important on align-items: inline <style> blocks (loaded after this file)
     have same specificity and would otherwise win the cascade. */
  .page-hdr    { flex-direction: column !important; align-items: flex-start !important; gap: 10px; }
  .page-hdr > .dp-wrap { align-self: flex-start; }
  .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 10px; }

  /* Inline date picker trigger: 44px touch target */
  .dp-trigger { min-height: 44px; padding: 0 14px; }
}

/* ============================================================
   DATE PICKER DROPDOWN — prevent off-screen clipping
   ============================================================ */
@media (max-width: 500px) {
  .dp-dropdown {
    left: 0 !important;
    right: auto !important;
    max-width: calc(100vw - 28px);
  }
}

/* ============================================================
   STAT CARDS — readable on mobile
   ============================================================ */
@media (max-width: 640px) {
  .stat-label { font-size: 12px; }
  .stat-value { font-size: 18px; }
  .stat-card-icon { display: none; }
  .stat-card  { padding-right: 16px; }
}

/* ============================================================
   OVERVIEW PAGE — page header + scope dropdown
   ============================================================ */

/* Page header left side: full width in stacked column layout.
   flex-wrap:wrap on .page-hdr (in inline style) handles natural wrapping;
   this ensures .page-hdr-left fills width when in column direction. */
@media (max-width: 640px) {
  .page-hdr-left { width: 100%; min-width: 0; }
  /* Inner title+scope row: allow wrap so scope-btn doesn't overflow */
  .page-hdr-left > div { min-width: 0; }
  .page-hdr-left > div > div:first-child { flex-wrap: wrap; }
}

/* Scope dropdown: use fixed positioning to guarantee it stays on-screen.
   !important overrides position:absolute + left:0 set in inline <style>. */
@media (max-width: 640px) {
  .scope-menu {
    position: fixed !important;
    left: 16px !important;
    right: 16px !important;
    top: 120px !important;
    min-width: unset !important;
    max-height: 70vh !important;
    overflow-y: auto !important;
    z-index: 300 !important;
  }
}

/* ============================================================
   WIDGET ROW — already stacks at 720px in base styles
   ============================================================ */

/* ============================================================
   GRIDS — chart-row, token-grid, cache-kpi collapse
   ============================================================ */
@media (max-width: 768px) {
  .chart-row  { grid-template-columns: 1fr !important; }
  .token-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  .token-grid      { grid-template-columns: 1fr !important; }
  .chart-wrap      { height: 180px !important; }
  .chart-wrap-tall { height: 200px !important; }
  .cache-kpi       { min-width: 100%; }
}

/* ============================================================
   TABS — 44px touch targets + scroll on mobile
   ============================================================ */
@media (max-width: 640px) {
  .tabs    { overflow-x: auto; flex-wrap: nowrap; width: 100%; -webkit-overflow-scrolling: touch; }
  .tab-btn { flex-shrink: 0; min-height: 40px; padding: 6px 14px; font-size: 13px; }
  .tabs-row { gap: 8px; }
}

/* ============================================================
   SCOPE / TEAM MENU — expand on narrow screens
   ============================================================ */
@media (max-width: 480px) {
  .scope-menu { min-width: min(95vw, 240px); }
}

/* ============================================================
   MODAL — full-width on mobile
   ============================================================ */
@media (max-width: 640px) {
  .modal-overlay { padding: 12px; align-items: flex-start; padding-top: 60px; }
  .modal-box     { width: 100% !important; max-width: 100% !important; max-height: 85vh; overflow-y: auto; }
}

/* ============================================================
   BREADCRUMB — truncate on small screens
   ============================================================ */
@media (max-width: 480px) {
  .breadcrumb { flex-wrap: wrap; gap: 4px; }
  .bc-current {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }
}

/* ============================================================
   INSIGHTS PAGE — KPI grid + gauge
   ============================================================ */
@media (max-width: 768px) {
  .kpi-grid      { grid-template-columns: repeat(2, 1fr) !important; }
  .gauge-section { flex-direction: column; }
  .gauge-wrap    { max-width: 260px; margin: 0 auto; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
   USERS DIRECTORY / TEAMS ADMIN
   ============================================================ */
@media (max-width: 640px) {
  .edit-inline-form { flex-direction: column; gap: 6px; }
}

/* ============================================================
   SIGN-IN PAGE — card fits narrow phones
   ============================================================ */
@media (max-width: 400px) {
  .card { width: calc(100vw - 32px); padding: 28px 20px; }
}
