/* ============================================
   RESPONSIVE / MOBILE-FIRST OVERRIDES
   ============================================ */

/* ── MOBILE (max 768px) ── */
@media (max-width: 768px) {

  /* Header: compact & flexible */
  #app-header    { height: 56px; padding: 0 10px; gap: 8px; }
  .logo-text     { display: none; }
  .logo-icon     { font-size: 24px; }
  #btn-filter-desktop { display: none !important; }
  .search-wrapper { min-width: 0; flex: 1; }
  #search-input  { height: 38px; padding: 0 32px 0 34px; font-size: 13px; }
  .search-icon   { left: 10px; font-size: 14px; }
  #search-clear  { right: 8px; font-size: 14px; }

  /* Register button in header */
  .btn-register  { padding: 6px 11px; font-size: 12px; }

  /* Main fills to above toolbar */
  #app-main { top: 56px; bottom: 58px; }

  /* Sidebar: slide-in overlay */
  #sidebar {
    position: fixed;
    left: 0; top: 56px;
    bottom: 58px;
    width: 100%;
    min-width: unset;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    z-index: var(--z-sidebar);
  }
  #sidebar.open { transform: translateX(0); }
  #btn-close-sidebar { display: flex !important; }

  /* Map fills full width */
  #map-container { left: 0; }

  /* Mobile toolbar: 4 items evenly spaced */
  #mobile-toolbar {
    height: 58px;
    display: flex !important;
    padding: 0 4px;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    z-index: 1200;
    pointer-events: auto;
  }
  .toolbar-btn {
    flex: 1;
    min-width: 0;
    padding: 4px 2px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: var(--font-weight-medium);
    border: none;
    background: none;
    border-radius: var(--radius-md);
  }
  .toolbar-btn:active, .toolbar-btn.active {
    color: var(--color-primary);
    background: var(--color-primary-bg);
  }
  .toolbar-btn .icon { font-size: 19px; line-height: 1; }
  .toolbar-btn.toolbar-btn-register {
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
  }

  /* Bottom sheet: completely hidden and non-blocking when closed */
  #bottom-sheet {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
    position: fixed;
    bottom: 58px; left: 0; right: 0;
    max-height: 72vh;
    z-index: 1100;
    transform: translateY(100%);
    transition: transform 0.25s ease, opacity 0.2s ease;
    opacity: 0;
  }
  #bottom-sheet.open {
    display: block !important;
    pointer-events: auto !important;
    visibility: visible !important;
    transform: translateY(0) !important;
    opacity: 1 !important;
  }

  /* Filter panel wider */
  #filter-panel { width: min(88vw, 340px); }

  /* Map controls smaller */
  #map-controls { right: 8px; top: 8px; }
  .map-control-btn { width: 38px; height: 38px; font-size: 16px; }

  /* Map hint hidden on mobile */
  .map-hint { display: none; }

  /* Toast higher (above toolbar) */
  .toast { bottom: 68px; }
}

/* ── EXTRA SMALL MOBILE (< 400px) ── */
@media (max-width: 400px) {
  #app-header { padding: 0 6px; gap: 6px; }
  .logo-text { white-space: nowrap; font-size: 14px; }
  .platform-switcher .platform-tab span:last-child { display: none; }
  .btn-register-text { display: none; }
  .btn-register {
    width: 34px; height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }
  .btn-register-icon { font-size: 15px; margin: 0; }
  #search-input { font-size: 12px; }
  .toolbar-btn { font-size: 10px; }
}

/* ── DESKTOP (min 769px) ── */
@media (min-width: 769px) {
  /* Hide mobile-only elements */
  #mobile-toolbar { display: none !important; }
  #bottom-sheet   { display: none !important; }
  #btn-close-sidebar { display: none !important; }

  /* Main fills full height */
  #app-main { bottom: 0; }

  /* Sidebar always visible */
  #sidebar {
    display: flex !important;
    transform: none !important;
    position: static;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }

  /* Map adjusted for sidebar */
  #map-container { flex: 1; }

  /* Desktop filter button */
  #btn-filter-desktop { display: inline-flex !important; }

  /* Larger search */
  .search-wrapper { max-width: 600px; }

  /* Toast lower (no toolbar) */
  .toast { bottom: 24px; }
}

/* ── LARGE DESKTOP (min 1200px) ── */
@media (min-width: 1200px) {
  :root { --sidebar-width: 400px; }
  #search-input { font-size: var(--font-size-base); }
}

/* ── TOUCH OPTIMIZATION ── */
@media (hover: none) and (pointer: coarse) {
  .btn       { min-height: 48px; }
  .btn-sm    { min-height: 40px; }
  .toolbar-btn { min-height: 52px; }
  .filter-option { min-height: 48px; }
  .list-item { padding: 14px 16px; }
  .suggestion-item { padding: 13px 16px; }
  #search-input { height: 48px; }
}

/* ── HIGH DPI ── */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .custom-marker { image-rendering: crisp-edges; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── PRINT ── */
@media print {
  #app-header, #mobile-toolbar, #map-container,
  #filter-panel, #bottom-sheet, #overlay { display: none !important; }
  #sidebar { position: static; width: 100%; transform: none; }
}
