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

:root {
  --bg-deep:      #080e1a;
  --bg-surface:   #0f172a;
  --bg-raised:    #1a2540;
  --bg-hover:     #1e2d4a;
  --border:       rgba(148, 180, 255, 0.12);
  --border-hover: rgba(148, 180, 255, 0.24);
  --text-primary: #e8f0ff;
  --text-secondary: #7b93c4;
  --text-hint:    #445577;
  --accent:       #3b7dff;
  --accent-glow:  rgba(59, 125, 255, 0.2);

  --c-free:    rgb(10, 200, 10);
  --c-arrival:  rgb(100, 255, 100);
  --c-eta:      rgb(255, 150, 150);
  --c-evisa:    rgb(255, 100, 100);
  --c-required: rgb(200, 70, 70);
  --c-no-admission: rgba(158, 8, 8, 1);
  --c-self:     "yellow";
  --c-none:     #1e2d4a;

  --topbar-h: 56px;
  --stats-h: 0px;
  --sheet-radius: 20px;
  --transition: 220ms cubic-bezier(0.4, 0, 0.2, 1);

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ─── Top Bar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(8, 14, 26, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 0.5px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 22px; height: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ─── Passport Trigger Button ──────────────────────────────────── */
.passport-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.passport-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  border-radius: 100px;
  padding: 8px 32px 8px 14px;
  cursor: pointer;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  max-width: 230px;
  transition: background var(--transition), border-color var(--transition);
}

.passport-select:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.passport-select:focus { outline: none; border-color: var(--border-hover); }

/* Native option list follows the OS theme; keep text readable on dark UIs. */
.passport-select option { color: "white"; }

.chevron {
  position: absolute;
  right: 12px;
  width: 14px; height: 14px;
  color: var(--text-hint);
  pointer-events: none;
}

/* ─── Map ──────────────────────────────────────────────────────── */
.map-wrapper {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
}

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

/* MapLibre controls */
.maplibregl-ctrl-group {
  background: var(--bg-raised) !important;
  border: 0.5px solid var(--border) !important;
  box-shadow: none !important;
  border-radius: 10px !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  background: transparent !important;
  border-bottom: 0.5px solid var(--border) !important;
  color: var(--text-secondary) !important;
  width: 36px !important;
  height: 36px !important;
}

.maplibregl-ctrl-group button:last-child { border-bottom: none !important; }
.maplibregl-ctrl-group button:hover { background: var(--bg-hover) !important; }
.maplibregl-ctrl-group button span { filter: invert(0.7) hue-rotate(200deg); }
.maplibregl-ctrl-attrib { display: none !important; }
.maplibregl-ctrl-logo { display: none !important; }

/* ─── Loading ──────────────────────────────────────────────────── */
.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg-deep);
  z-index: 10;
  color: var(--text-secondary);
  font-size: 14px;
}

.map-loading.hidden { display: none; }

.loading-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ─── Tooltip (desktop hover) ──────────────────────────────────── */
.map-tooltip {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(8, 14, 26, 0.92);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 180px;
  max-width: 240px;
  pointer-events: none;
  z-index: 20;
  backdrop-filter: blur(16px);
  opacity: 0;
  transition: opacity var(--transition);
}

.map-tooltip.visible { opacity: 1; }

.tooltip-flag { font-size: 22px; margin-bottom: 4px; }
.tooltip-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }

.tooltip-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 100px;
  margin-bottom: 8px;
}

.tooltip-note {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  border-top: 0.5px solid var(--border);
  padding-top: 8px;
}

/* ─── Legend ───────────────────────────────────────────────────── */
.legend {
  visibility: hidden;
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(8, 14, 26, 0.86);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  backdrop-filter: blur(12px);
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.legend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Stats bar ─────────────────────────────────────────────────── */
.stats-bar {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  display: flex;
  gap: 0;
  background: rgba(8, 14, 26, 0.88);
  border: 0.5px solid var(--border);
  border-radius: 100px;
  overflow: hidden;
  backdrop-filter: blur(16px);
  z-index: 10;
}

.stats-bar[hidden] { display: none; }

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  gap: 1px;
  border-right: 0.5px solid var(--border);
}
.stat:last-child { border-right: none; }

.stat-num {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-label {
  font-size: 10px;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

#statFree .stat-num    { color: var(--c-free); }
#statArrival .stat-num { color: var(--c-arrival); }
#statEta .stat-num { color: var(--c-eta); }
#statEvisa .stat-num   { color: var(--c-evisa); }
#statRequired .stat-num{ color: var(--c-required); }
#statNoAdmission .stat-num   { color: var(--c-no-admission); }
 
/* ─── Bottom Sheet ──────────────────────────────────────────────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.sheet-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 201;
  background: var(--bg-surface);
  border-top: 0.5px solid var(--border);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
  padding: 0 20px 40px;
  transform: translateY(100%);
  transition: transform 350ms cubic-bezier(0.32, 0.72, 0, 1);
}

.bottom-sheet:not([hidden]) { display: block; }

.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 100px;
  margin: 12px auto 20px;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-country-flag { font-size: 32px; margin-bottom: 4px; }
.sheet-country-name { font-size: 20px; font-weight: 600; color: var(--text-primary); }

.sheet-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 100px;
  margin-top: 6px;
  white-space: nowrap;
}

.sheet-note {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  border-top: 0.5px solid var(--border);
  padding-top: 14px;
  min-height: 40px;
}

.sheet-close {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: var(--bg-raised);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.sheet-close:hover { background: var(--bg-hover); }
.sheet-close:active { transform: scale(0.98); }

/* ─── Badge color helpers ───────────────────────────────────────── */
.badge-free     { background: rgba(34,197,94,0.18);  color: #4ade80; }
.badge-arrival  { background: rgba(20,184,166,0.18); color: #2dd4bf; }
.badge-evisa    { background: rgba(167,139,250,0.18); color: #c4b5fd; }
.badge-eta      { background: rgba(249,115,22,0.18); color: #fb923c; }
.badge-required { background: rgba(239,68,68,0.18);  color: #f87171; }
.badge-self     { background: rgba(59,125,255,0.18); color: #7ca9ff; }
.badge-none     { background: rgba(100,116,139,0.18); color: #94a3b8; }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (min-width: 640px) {
  /* Bottom sheet becomes a floating panel */
  .bottom-sheet {
    left: auto;
    right: 16px;
    bottom: 32px;
    width: 300px;
    border-radius: 16px;
    border: 0.5px solid var(--border);
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    transform: translateY(20px);
    opacity: 0;
    transition: transform var(--transition), opacity var(--transition);
  }
  .bottom-sheet.open {
    transform: translateY(0);
    opacity: 1;
  }

  .sheet-handle { display: none; }

  /* Tooltip visible on desktop, not needed on mobile */
  .map-tooltip { display: block; }

  /* Legend larger */
  .legend { bottom: 32px; left: 20px; }

  /* Stats centred at top */
  .stats-bar { top: 16px; }
}

@media (max-width: 639px) {
  /* Hide hover tooltip on mobile — use bottom sheet instead */
  .map-tooltip { display: none !important; }

  /* Stats pill: smaller on mobile */
  .stat { padding: 6px 12px; }
  .stat-num { font-size: 14px; }
  .stat-label { font-size: 9px; }

  /* Legend: smaller */
  .legend { bottom: 12px; left: 12px; padding: 8px 10px; gap: 5px; }
  .legend-item { font-size: 11px; }
}

/* ─── Focus visible ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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