/* ============================================
   RESPONSIVE — Mobile-first improvements
   ============================================ */

/* --- Tablet (< 1200px) --- */
@media (max-width: 1199px) {
  .sidebar.collapsed { margin-left: -260px; }
  .sidebar-toggle { display: flex; }
}

/* --- Small tablet / large phone (< 768px) --- */
@media (max-width: 768px) {
  /* Header: compact layout */
  .header {
    gap: 6px;
    padding: 8px 12px;
    flex-wrap: wrap;
    min-height: auto;
  }
  .header-title {
    font-size: .95rem;
    order: 0;
  }
  .header-title span:not(.bp-logo) { display: none; }
  .header-event { display: none; }
  .bp-logo { width: 30px; height: 30px; font-size: .85rem; border-radius: 8px; }

  .search-box {
    order: 10;
    flex: 1 1 100%;
    margin-top: 4px;
  }
  .search-box input { padding: 8px 12px 8px 32px; font-size: .85rem; }

  .view-tabs { order: 1; margin-left: auto; }
  .view-tab { padding: 5px 12px; font-size: .78rem; }

  .fav-counter { order: 2; font-size: .78rem; }

  .user-menu { order: 3; }
  .user-btn { padding: 5px 10px; font-size: .78rem; }

  .theme-toggle { order: 4; width: 30px; height: 30px; }
  .theme-toggle svg { width: 16px; height: 16px; }

  /* Day bar: horizontal scroll */
  .day-bar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 6px 12px;
    gap: 4px;
    flex-wrap: nowrap;
  }
  .day-bar::-webkit-scrollbar { display: none; }
  .day-tab {
    padding: 6px 12px;
    font-size: .78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Sidebar: overlay mode on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    min-width: 280px;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
    transition: transform .3s ease;
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    margin-left: 0;
  }

  /* Dark backdrop behind sidebar */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 190;
  }
  .sidebar-backdrop.visible {
    display: block;
  }

  /* Sidebar toggle: top-left with pulsing glow */
  .sidebar-toggle {
    display: flex;
    position: fixed;
    left: 6px;
    top: auto;
    z-index: 140;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    box-shadow: 0 0 0 0 rgba(99,102,241,.6);
    animation: pulseGlow 2.5s ease-in-out 3;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border: none;
  }
  .sidebar-toggle svg { width: 16px; height: 16px; stroke: #fff; }

  /* Timeline */
  .timeline { margin-left: 40px; }
  .hour-label { left: -38px; font-size: .68rem; width: 34px; }
  .ev-block .ev-name { font-size: .74rem; }

  /* Detail panel: fullscreen on mobile */
  .detail-panel {
    width: 100%;
    max-width: 100vw;
    border-left: none;
    padding: 20px 16px;
  }

  /* Map sidebar: overlay on mobile */
  .map-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    min-width: 280px;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
    transition: transform .3s ease;
  }
  .map-sidebar.collapsed {
    transform: translateX(-100%);
    width: 280px;
    min-width: 280px;
    padding: 16px;
    opacity: 1;
    pointer-events: auto;
    border-right: 1px solid var(--border);
  }

  /* Map sidebar open button with glow */
  .map-sidebar.collapsed ~ .map-sidebar-open {
    animation: pulseGlow 2.5s ease-in-out 3;
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  /* Map modal */
  .map-modal {
    width: 100%;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }
  .map-modal-scroll { padding: 20px 16px; }

  /* Auth & confirm popup */
  .auth-modal { padding: 24px 20px; max-width: 100%; margin: 0 12px; }
  .confirm-popup { margin: 0 16px; padding: 24px 20px; }
}

/* --- Phone (< 480px) --- */
@media (max-width: 480px) {
  /* Header: minimal */
  .header {
    padding: 6px 10px;
    gap: 4px;
  }
  .header-title {
    font-size: .88rem;
    gap: 4px;
  }

  .view-tabs { padding: 2px; }
  .view-tab { padding: 4px 10px; font-size: .75rem; }

  .user-btn { padding: 4px 8px; font-size: .75rem; gap: 4px; }
  .user-dropdown-content { min-width: 160px; }

  .theme-toggle { width: 28px; height: 28px; }

  /* Day bar */
  .day-bar { padding: 5px 8px; }
  .day-tab { padding: 5px 10px; font-size: .75rem; }

  /* Timeline */
  .timeline { margin-left: 34px; }
  .hour-label { left: -32px; font-size: .65rem; width: 28px; }
  .ev-block { padding: 4px 6px; }
  .ev-block .ev-name { font-size: .72rem; }
  .ev-block .ev-time { font-size: .64rem; }

  /* Detail panel */
  .detail-panel {
    padding: 16px 14px;
  }
  .detail-panel h2 { font-size: 1.05rem; padding-right: 30px; }
  .detail-meta { font-size: .82rem; }
  .detail-desc { font-size: .82rem; padding: 8px 10px; }

  /* Map modal */
  .map-modal-scroll { padding: 16px 14px; }
  .map-modal h2 { font-size: 1.1rem; }

  /* Conflict banner */
  .conflict-banner { font-size: .78rem; padding: 6px 12px; }

  /* Sidebar */
  .sidebar { width: 240px; min-width: 240px; padding: 12px; }
  .filter-item { font-size: .78rem; }
  .filter-section h3 { font-size: .74rem; }

  /* Toast */
  .toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { font-size: .82rem; padding: 10px 14px; }
}

/* --- Very small phone (< 360px) --- */
@media (max-width: 360px) {
  .header-title .bp-logo + *:not(.header-event) { display: none; }
  .search-box input { font-size: .82rem; }
  .view-tab { padding: 4px 8px; font-size: .72rem; }
}

/* Pulsing glow animation for toggle buttons on mobile */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,.5); }
  50% { box-shadow: 0 0 12px 6px rgba(99,102,241,.4); }
}

/* ============================================
   TOAST (moved here from inline, always loaded)
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-success { border-left: 3px solid #22C55E; }
.toast-error { border-left: 3px solid #EF4444; }
.toast-info { border-left: 3px solid var(--accent); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
