/* ============================================================================
   responsive.css  --  shared mobile / tablet layer for every Salesrator page.

   RULES OF THE ROAD
   * Purely additive. Nothing here applies above 1024px, so the desktop layout
     is exactly what it was before this file existed.
   * Breakpoints:  <=1024px tablet  |  <=768px phone (large)  |  <=480px phone
   * The pages keep their own <style> blocks; this file only overrides at
     narrow widths (and uses !important only to beat inline style="" attrs,
     which the pages use heavily).
   * Behavioural helpers (hamburger, grid fitting, card tables, bottom sheet)
     live in /static/js/responsive.js.
   ============================================================================ */

/* ---- things that are harmless at every width -------------------------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.rs-burger { display: none; }
/* tablet/phone-only widgets: invisible unless the media queries below turn them on */
.rs-sheet-bar { display: none; }
.rs-scroll { display: contents; }          /* wrapper added by responsive.js: invisible on desktop */

/* ======================================================================== */
/*  TABLET  (<= 1024px)                                                     */
/* ======================================================================== */
@media (max-width: 1024px) {
  .dash-wrap, .page-wrap { padding-left: 16px; padding-right: 16px; }
  /* Two-pane dashboard layout: list + 420px detail -> single column */
  .content-area { grid-template-columns: 1fr !important; }
  .rs-scroll { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* grids trimmed by responsive.js when their columns would get too narrow */
  [data-rs-cols="1"] { grid-template-columns: minmax(0, 1fr) !important; }
  [data-rs-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-rs-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  [data-rs-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  [data-rs-cols="1"] > * { grid-column: 1 / -1 !important; }

  /* ---- detail panel becomes a full-screen sheet (see responsive.js) ---- */
  .detail-panel.rs-sheet {
    display: none; position: fixed !important; inset: 0; z-index: 10050;
    margin: 0 !important; border-radius: 0 !important; width: 100% !important;
    max-height: none !important; height: 100dvh; overflow-y: auto;
    background: #fff; -webkit-overflow-scrolling: touch;
  }
  .detail-panel.rs-sheet.rs-open { display: block; }
  .detail-panel.rs-sheet .dp-body { max-height: none !important; padding-bottom: 90px; }
  .rs-sheet-bar {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: #0f172a; color: #fff;
  }
  .rs-sheet-bar button {
    background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2);
    border-radius: 9px; padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
  }
  .rs-sheet-bar span { font-size: 12px; opacity: .7; }
  body.rs-noscroll { overflow: hidden !important; }

}

/* ======================================================================== */
/*  PHONE  (<= 768px)                                                       */
/* ======================================================================== */
@media (max-width: 768px) {

  /* ---- global safety nets ---------------------------------------------- */
  html, body { max-width: 100%; overflow-x: hidden; }
  img, video, canvas { max-width: 100%; }
  /* long unbroken strings (emails, ids, urls) must wrap, not widen the page */
  p, h1, h2, h3, h4, .nav-title, .wa-cname { overflow-wrap: anywhere; }

  /* ---- top navigation bar ---------------------------------------------- */
  nav {
    height: auto !important; min-height: 54px;
    padding: 8px 12px !important;
    flex-wrap: wrap; row-gap: 0; column-gap: 8px;
  }
  nav .nav-logo { min-width: 0; flex: 1 1 auto; }
  nav .nav-logo > div:last-child { min-width: 0; }
  nav .nav-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  nav .nav-sub  { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62vw; }

  .rs-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex: 0 0 auto; margin-left: auto;
    background: rgba(255,255,255,.10); color: #fff;
    border: 1px solid rgba(255,255,255,.18); border-radius: 10px;
    font-size: 17px; cursor: pointer; line-height: 1;
  }
  .rs-burger:active { background: rgba(255,255,255,.2); }

  /* the right-hand group of buttons collapses into a drop-down panel */
  nav > .nav-links, nav > .nav-actions, nav > .nav-right {
    display: none !important;
    flex: 0 0 100%; width: 100%;
    flex-direction: column !important; align-items: stretch !important;
    gap: 8px !important; margin: 8px 0 4px; padding: 10px 0 2px;
    border-top: 1px solid rgba(255,255,255,.14);
    max-height: calc(100dvh - 74px); overflow-y: auto;
  }
  nav.rs-open > .nav-links, nav.rs-open > .nav-actions, nav.rs-open > .nav-right {
    display: flex !important;
  }
  nav > .nav-links > *, nav > .nav-actions > *, nav > .nav-right > * {
    width: 100%; max-width: 100%; justify-content: flex-start;
    min-height: 42px; margin: 0 !important;
  }
  nav > .nav-links > a, nav > .nav-links > button,
  nav > .nav-actions > a, nav > .nav-actions > button,
  nav > .nav-right > a, nav > .nav-right > button {
    padding-top: 10px !important; padding-bottom: 10px !important; font-size: 13px !important;
  }
  /* "Powered by" divider / left borders look odd when stacked */
  nav [style*="border-left"] { border-left: 0 !important; padding-left: 0 !important; }
  nav .refresh-info { margin: 0 !important; }

  /* ---- page wrappers & headers ----------------------------------------- */
  .dash-wrap, .page-wrap { padding: 12px !important; }
  .page-header { padding: 16px !important; border-radius: 14px !important; }
  .page-header-left h1, .page-header h1 { font-size: 19px !important; }
  .section { padding: 14px !important; }
  .page-header { flex-wrap: wrap; gap: 14px; }
  .header-stat-row { width: 100%; justify-content: space-around; gap: 12px; }
  .header-stat-val { font-size: 24px !important; }

  /* horizontally scrolling tab bars (revival, lp-tabs) */
  .tab-bar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-bar .tab { flex: 0 0 auto; padding: 10px 14px; white-space: nowrap; }

  /* ---- grids: named classes -------------------------------------------- */
  .two-col, .form-grid, .hero { grid-template-columns: 1fr !important; }
  .stats-row, .event-type-grid, .memory-grid, .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .stats-row > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .row-2, .row-3 { grid-template-columns: 1fr !important; }
  .event-cards, .fest-grid { grid-template-columns: 1fr !important; }

  /* ---- tables: scroll sideways instead of stretching the page ---------- */
  .table-wrap, .tablewrap { -webkit-overflow-scrolling: touch; }

  /* ---- "card" tables (opted in by responsive.js) ----------------------- */
  :is(table.rs-cards, #tableWrap table), :is(table.rs-cards, #tableWrap table) tbody { display: block; width: 100%; }
  :is(table.rs-cards, #tableWrap table) thead { display: none; }
  :is(table.rs-cards, #tableWrap table) tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
    position: relative; padding: 12px 12px 10px; margin: 10px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  :is(table.rs-cards, #tableWrap table) tr.selected { border-color: #128C7E; box-shadow: 0 0 0 2px rgba(18,140,126,.25); }
  :is(table.rs-cards, #tableWrap table) td {
    display: block; padding: 2px 0 !important; border: 0 !important;
    background: transparent !important; min-width: 0; white-space: normal;
  }
  :is(table.rs-cards, #tableWrap table) td::before {
    content: attr(data-label); display: block; margin-bottom: 1px;
    font-size: 10px; font-weight: 700; letter-spacing: .4px;
    text-transform: uppercase; color: #94a3b8;
  }
  :is(table.rs-cards, #tableWrap table) td[data-label=""]::before { display: none; }
  /* first real cell (customer) spans the card; checkbox/delete sit top-right */
  :is(table.rs-cards, #tableWrap table) td.rs-main { grid-column: 1 / -1; padding-right: 64px !important; }
  :is(table.rs-cards, #tableWrap table) td.rs-main::before { display: none; }
  :is(table.rs-cards, #tableWrap table) td.rs-sel  { position: absolute; top: 10px; right: 46px; width: auto !important; }
  :is(table.rs-cards, #tableWrap table) td.rs-act  { position: absolute; top: 4px;  right: 6px;  width: auto !important; }
  :is(table.rs-cards, #tableWrap table) td.rs-wide { grid-column: 1 / -1; }

  /* ---- modals & overlays ------------------------------------------------ */
  [style*="position:fixed"][style*="inset:0"] > div,
  .camp-modal, .aam-modal, .lead-modal, .modal-box, .modal-card {
    max-width: calc(100vw - 20px) !important;
    max-height: 92dvh; overflow-y: auto;
  }
  .camp-modal, .camp-modal[style] { width: calc(100vw - 20px) !important; }
  .camp-row2, .aam-body { grid-template-columns: 1fr !important; }

  /* ---- floating widgets -------------------------------------------------- */
  .la-panel {
    right: 8px !important; left: 8px; width: auto !important; max-width: none !important;
    bottom: 84px !important; height: min(560px, calc(100dvh - 110px)) !important;
    max-height: none !important;
  }
  #leadAssistantFab { right: 14px !important; bottom: 14px !important; width: 54px !important; height: 54px !important; }
  .toast { left: 12px; right: 12px; bottom: 80px; text-align: center; }

  /* ---- forms: 16px stops iOS zooming into focused fields ---------------- */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
  select, textarea { font-size: 16px !important; }
  .filter-select, .filter-search, .flt-select, .flt-input { min-width: 0 !important; }

  /* ---- tiny type is unreadable on a phone ------------------------------- */
  [style*="font-size:8px"], [style*="font-size:9px"], [style*="font-size:9.5px"],
  [style*="font-size:10px"], [style*="font-size:10.5px"],
  [style*="font-size: 9px"], [style*="font-size: 10px"] { font-size: 11px !important; }
  .stat-label, .nav-sub, th, .journey-label, .badge, .tab-badge, .tbl-badge { font-size: 11px !important; }

  /* ---- inline-style helpers: min-width rows that would push past 100vw -- */
  [style*="min-width:300px"], [style*="min-width:260px"], [style*="min-width:240px"],
  [style*="min-width:220px"], [style*="min-width:200px"] { min-width: 0 !important; }
}

/* ======================================================================== */
/*  SMALL PHONE  (<= 480px)                                                 */
/* ======================================================================== */
@media (max-width: 480px) {
  .stat-value { font-size: 22px !important; }
  .stats-row, .event-type-grid, .memory-grid, .tiles { gap: 8px !important; }
  .page-header { padding: 14px !important; }
  /* centred modals turn into bottom sheets */
  [style*="position:fixed"][style*="inset:0"] { align-items: flex-end !important; }
  [style*="position:fixed"][style*="inset:0"] > div {
    width: 100% !important; max-width: 100vw !important;
    border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important;
  }
}

/* ======================================================================== */
/*  TOUCH DEVICES  (any width): comfortable tap targets                     */
/* ======================================================================== */
@media (pointer: coarse) and (max-width: 1024px) {
  .btn, .btn-demo, .btn-dash, .nav-btn, .heat-btn, .filter-clear, .lp-tab,
  .tab-btn, .wa-btn, .bpcl-opt, .camp-btn {
    min-height: 40px;
  }
  .filter-select, .filter-search, .flt-select, .flt-input { min-height: 40px; height: auto; }
  .btn-icon { width: 38px !important; height: 38px !important; }
  /* give checkboxes a larger hit area without changing how they look */
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
}

/* respect users who ask for less motion */
@media (prefers-reduced-motion: reduce) {
  .rs-burger, nav { transition: none !important; }
}

/* ======================================================================== */
/*  CHATBOT PAGE (index.html): one pane at a time on a phone                */
/* ======================================================================== */
.rs-back { display: none; }
@media (max-width: 768px) {
  body:has(> .layout) { display: flex; flex-direction: column; height: 100dvh; }
  body:has(> .layout) > nav { flex: 0 0 auto; }
  .layout {
    grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr);
    height: auto !important; flex: 1 1 0; min-height: 0;
  }
  .layout .left-panel { border-right: 0; min-height: 0; }
  .layout .right-panel { display: none; min-height: 0; }
  .layout:has(#waSim.active):not(.rs-left) .left-panel { display: none; }
  .layout:has(#waSim.active):not(.rs-left) .right-panel { display: flex; }
  .rs-back {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 36px; height: 36px; margin-right: 2px; background: transparent; color: #fff;
    border: 0; font-size: 22px; cursor: pointer;
  }
  .wa-hdr-icons { display: none !important; }
  .wa-region-badge { font-size: 10px; }
  .lp-tabs { overflow-x: auto; scrollbar-width: none; }
  .lp-tab { flex: 1 0 auto; white-space: nowrap; }
}

@media (max-width: 768px) {
  /* filter rows (revival, campaigns, ...): two controls per line, search full width */
  .filter-row > select, .filter-row > .flt-select { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .filter-row > input, .filter-row > .flt-input { flex: 1 1 100%; min-width: 0; }
}
