/* ============================================================
   Vietnam Travel Map — Design System
   ============================================================ */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@600;700;800&display=swap');

/* ---------- Custom Properties ---------- */
:root {
  /* Navy / Blue palette (B-Bot brand) */
  --navy-900: #0a1628;
  --navy-800: #111d35;
  --navy-700: #1a2d4e;
  --navy-600: #1a3a6e;
  --navy-500: #2563eb;
  --navy-400: #60a5fa;
  --navy-300: #93c5fd;

  /* Accent / Orange */
  --orange-500: #ff6b35;
  --orange-400: #ff8c5a;
  --orange-300: #ffb088;

  /* Semantic */
  --green-500: #22c55e;
  --green-400: #4ade80;
  --red-500: #ef4444;
  --red-400: #f87171;
  --grey-500: #6b7280;
  --grey-400: #9ca3af;
  --grey-300: #d1d5db;
  --grey-200: #e5e7eb;
  --grey-100: #f3f4f6;
  --grey-50: #f9fafb;

  /* Layout */
  --sidebar-width: 380px;
  --header-height: 56px;

  /* Glass */
  --glass-bg: rgba(10, 22, 40, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--navy-900);
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- App Layout ---------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* ---------- Map Container ---------- */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
  transition: transform 0.4s var(--ease-out);
}

/* ---------- Sidebar Header ---------- */
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(135deg, rgba(26, 58, 110, 0.4), rgba(10, 22, 40, 0.6));
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  background: linear-gradient(135deg, #fff 0%, var(--orange-300) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-header .trip-dates {
  font-size: 0.8rem;
  color: var(--grey-400);
  margin-top: 4px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ---------- Stats Bar ---------- */
.stats-bar {
  display: flex;
  gap: 1px;
  background: var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
}

.stat {
  flex: 1;
  padding: 14px 12px;
  text-align: center;
  background: rgba(10, 22, 40, 0.6);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--orange-400);
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--grey-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ---------- Location List ---------- */
.location-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-600) transparent;
}

.location-list::-webkit-scrollbar {
  width: 5px;
}

.location-list::-webkit-scrollbar-track {
  background: transparent;
}

.location-list::-webkit-scrollbar-thumb {
  background: var(--navy-600);
  border-radius: 3px;
}

.location-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  border-left: 3px solid transparent;
  position: relative;
}

.location-item:hover {
  background: rgba(37, 99, 235, 0.1);
  border-left-color: var(--navy-500);
}

.location-item.active {
  background: rgba(37, 99, 235, 0.15);
  border-left-color: var(--orange-500);
}

.location-item.type-current {
  background: rgba(239, 68, 68, 0.08);
}

.location-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.location-icon.start {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green-400);
}

.location-icon.visited {
  background: rgba(255, 107, 53, 0.15);
  color: var(--orange-400);
}

.location-icon.current {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-400);
  position: relative;
}

.location-icon.current::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  border: 2px solid var(--red-400);
  animation: pulse-ring 2s ease-out infinite;
}

.location-icon.planned {
  background: rgba(156, 163, 175, 0.1);
  color: var(--grey-400);
}

.location-info {
  flex: 1;
  min-width: 0;
}

.location-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.location-date {
  font-size: 0.7rem;
  color: var(--grey-400);
  margin-top: 2px;
}

.location-item.type-planned .location-name {
  color: var(--grey-400);
  font-weight: 400;
}

/* ---------- Toast Notification ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 0.875rem;
  color: #fff;
  box-shadow: var(--glass-shadow);
  z-index: 1000;
  transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Pulse Animation ---------- */
@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Current marker pulse (used on map) */
.marker-current {
  width: 24px;
  height: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-current .dot {
  width: 16px;
  height: 16px;
  background: radial-gradient(circle, var(--red-400), var(--red-500));
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
  animation: pulse-dot 2s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.marker-current .ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--red-400);
  animation: pulse-ring 2s ease-out infinite;
}

.marker-current .ring:nth-child(3) {
  animation-delay: 0.5s;
}

/* Visited marker with number */
.marker-visited {
  position: relative;
  width: 30px;
  height: 42px;
}

.marker-visited img {
  width: 100%;
  height: 100%;
}

.marker-visited .number {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  color: #ea580c;
  line-height: 1;
}

/* ---------- InfoWindow Custom Styling ---------- */
.info-window {
  font-family: var(--font-body);
  max-width: 280px;
  padding: 4px;
}

.info-window h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-800);
  margin-bottom: 6px;
}

.info-window .info-date {
  font-size: 0.8rem;
  color: var(--grey-500);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.info-window .info-notes {
  font-size: 0.85rem;
  color: var(--navy-700);
  line-height: 1.5;
  margin-bottom: 8px;
}

.info-window .info-photo {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 4px;
}

.info-window .info-type {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.info-type.start { background: #dcfce7; color: #166534; }
.info-type.visited { background: #fff7ed; color: #9a3412; }
.info-type.current { background: #fef2f2; color: #991b1b; }
.info-type.planned { background: #f3f4f6; color: #4b5563; }

/* ---------- Drop animation ---------- */
@keyframes marker-drop {
  0% {
    transform: translateY(-60px);
    opacity: 0;
  }
  60% {
    transform: translateY(4px);
    opacity: 1;
  }
  80% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.marker-drop {
  animation: marker-drop 0.6s var(--ease-out) forwards;
}

/* ---------- Mobile bottom sheet ---------- */
.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.3s var(--ease-out);
}

.mobile-toggle .handle {
  width: 40px;
  height: 4px;
  background: var(--grey-500);
  border-radius: 2px;
  margin: 0 auto 8px;
}

.mobile-toggle .preview-text {
  font-size: 0.8rem;
  color: var(--grey-300);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .map-container {
    height: 100vh;
    width: 100%;
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 85vh;
    border-left: none;
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    transform: translateY(calc(100% - 140px));
    z-index: 20;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  }

  .sidebar.expanded {
    transform: translateY(0);
  }

  .sidebar-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 6px;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
  }

  .sidebar-handle .bar {
    width: 48px;
    height: 5px;
    background: var(--grey-400);
    border-radius: 3px;
    margin-bottom: 4px;
  }

  .sidebar-handle::after {
    content: 'View stops ↑';
    font-size: 0.65rem;
    color: var(--grey-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: opacity 0.3s ease;
  }

  .sidebar.expanded .sidebar-handle::after {
    content: 'Close ↓';
  }

  .sidebar-header {
    padding: 12px 16px 10px;
  }

  .sidebar-header h1 {
    font-size: 1rem;
  }

  .stats-bar {
    border-bottom: none;
  }

  .stat {
    padding: 10px 8px;
  }

  .stat-value {
    font-size: 1.15rem;
  }

  .mobile-toggle {
    display: none;
  }
}

@media (max-width: 480px) {
  .sidebar-header {
    padding: 16px 16px 12px;
  }

  .location-item {
    padding: 10px 16px;
  }

  .stat-value {
    font-size: 1.2rem;
  }
}

/* ---------- Loading State ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--navy-700);
  border-top-color: var(--orange-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Live Tracker Dot (GPS trail endpoint) ---------- */
.live-tracker-dot {
  width: 28px;
  height: 28px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.live-tracker-dot .live-center {
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, #ff4444, #cc0000);
  border-radius: 50%;
  border: 2.5px solid white;
  box-shadow: 0 2px 10px rgba(255, 0, 0, 0.6);
  position: relative;
  z-index: 2;
  animation: pulse-dot 2s ease-in-out infinite;
}

.live-tracker-dot .live-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 68, 68, 0.6);
  animation: live-pulse 2.5s ease-out infinite;
}

.live-tracker-dot .live-ring:nth-child(2) {
  animation-delay: 0.8s;
}

@keyframes live-pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}
