/* ============================================================
   mobile.css — RouteForge Mobile Responsiveness
   Strategy: Tab-bar with full-screen sliding panels
   Breakpoint: ≤768px
============================================================ */

#mobile-tab-bar { display: none; }

@media (max-width: 768px) {

  html, body {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* ── Header ────────────────────────────────────────────── */
  #app-header {
    height: auto;
    padding: 0 12px;
  }
  .header-inner {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
  }
  .header-tagline { display: none; }
  .logo-text { font-size: 18px; }
  .logo-icon { height: 26px; }

  .header-actions {
    width: 100%;
    margin-left: 0;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    flex-wrap: nowrap;
  }
  .header-actions::-webkit-scrollbar { display: none; }
  .header-actions .btn {
    padding: 5px 9px;
    font-size: 11px;
    flex-shrink: 0;
  }
  #auth-btn { order: -1; }
  #token-badge { order: 0; }

  /* ── Main layout ─────────────────────────────────────── */
  #app-main {
    flex-direction: column;
    height: calc(100dvh - var(--mob-header-h, 88px));
    position: relative;
  }

  /* ── Side panels: full-screen sliding overlays ──────── */
  aside#panel-left,
  aside#panel-right {
    position: fixed;
    top: var(--mob-header-h, 88px);
    left: 0;
    right: 0;
    bottom: 52px;
    width: 100%;
    z-index: 300;
    border: none;
    border-top: 1px solid var(--border);
    transform: translateX(-110%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-panel);
  }
  aside#panel-right {
    transform: translateX(110%);
  }
  aside#panel-left.mobile-active,
  aside#panel-right.mobile-active {
    transform: translateX(0);
  }

  /* ── Map ──────────────────────────────────────────────── */
  #map-container {
    position: fixed;
    top: var(--mob-header-h, 88px);
    left: 0; right: 0;
    bottom: 52px;
    z-index: 100;
    transition: opacity 0.2s;
  }
  #map-container.mobile-hidden {
    opacity: 0;
    pointer-events: none;
  }

  /* ── Tab bar ──────────────────────────────────────────── */
  #mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 52px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 500;
  }
  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 52px;
    transition: color 0.15s, background 0.15s;
  }
  .mob-tab-icon { font-size: 19px; line-height: 1; }
  .mob-tab.active {
    color: var(--accent);
    background: var(--accent-glow);
  }
  .mob-tab.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20px; right: 20px;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
  }

  /* ── Left panel internals ─────────────────────────────── */
  #waypoint-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
  }
  .panel-actions { padding: 6px 10px 8px; flex-shrink: 0; }
  .panel-header { padding: 10px 12px 8px; flex-shrink: 0; }
  .panel-header h2 { font-size: 16px; }
  #stats-box { margin: 0 10px 8px; flex-shrink: 0; }
  .layer-controls { padding: 8px 10px; flex-shrink: 0; }
  .layer-btn { font-size: 10px; padding: 5px 3px; min-height: 34px; }

  /* ── Waypoint cards ───────────────────────────────────── */
  .waypoint-card { padding: 10px; }
  .wc-input {
    font-size: 16px; /* prevents iOS zoom */
    padding: 9px 10px;
  }
  .transport-connector { padding: 3px 10px; }

  /* ── Right panel internals ────────────────────────────── */
  .export-settings {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    gap: 10px;
  }
  #preview-box {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  #preview-canvas-wrap { min-height: 60px; }
  #preview-controls { gap: 6px; margin-top: 6px; }
  #preview-controls .btn { font-size: 11px; padding: 6px; }
  #btn-download-video { margin: 8px 10px; }
  #export-progress { margin: 0 10px 6px; }

  .setting-label { font-size: 11px; gap: 6px; }
  .setting-label select { font-size: 13px; padding: 5px 6px; }
  .ratio-grid { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .ratio-btn { font-size: 9px; padding: 5px 2px; }
  .fmt-btn { padding: 6px 6px; font-size: 12px; }

  /* ── Footer hidden ────────────────────────────────────── */
  .footer { display: none; }

  /* ── Modals: bottom-sheet style ───────────────────────── */
  .auth-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .auth-modal-box {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 16px 16px;
  }
  .auth-dashboard-box,
  .routes-panel-box,
  .upgrade-modal-box,
  .upgrade-confirm-box {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 14px 16px;
  }
  .token-packs-grid { grid-template-columns: repeat(2, 1fr); }
  .token-pack-btn.double-width { grid-column: span 2; }
  .pro-plans { grid-template-columns: 1fr; }
  .upgrade-tab { font-size: 12px; padding: 7px 6px 9px; }

  /* ── Geocoder ─────────────────────────────────────────── */
  #geocoder-dropdown {
    min-width: unset;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
  }

  /* ── Misc ─────────────────────────────────────────────── */
  #map-overlay-hint {
    bottom: 64px;
    font-size: 11px;
    padding: 5px 14px;
  }
  .ctx-menu-item { padding: 12px 14px; font-size: 14px; }

} /* end @media */

@media (max-width: 360px) {
  .logo-text { font-size: 15px; }
  .logo-icon { height: 22px; }
  .mob-tab-icon { font-size: 16px; }
  .mob-tab { font-size: 8px; }
}