/* ═══════════════════════════════════════════════════════════════════════════
   Neretva – Custom CSS
   The Tailwind utilities handle most layout; this file adds:
   • Design tokens & form inputs
   • Map-specific overrides for Leaflet
   • Animations
   • Component classes too complex for inline utilities
═══════════════════════════════════════════════════════════════════════════ */

:root {
  --river: #00B4D8;
  --river-dark: #0096B4;
  --accent: #06D6A0;
  --accent-dark: #059669;
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-card: #1E293B;
  --border: rgba(148, 163, 184, 0.15);
  --text-primary: #F1F5F9;
  --text-muted: #94A3B8;
}

/* ─── Global ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
}

::selection { background: var(--river); color: #fff; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 9999px; }

/* ─── Form inputs ─────────────────────────────────────────────────────────── */
.form-input {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: #0F172A;
  border: 1.5px solid #334155;
  border-radius: 0.625rem;
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.form-input:focus {
  border-color: var(--river);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.15);
}
.form-input::placeholder { color: #475569; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.625rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
  line-height: 1.5;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--river), #00D4FF);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 180, 216, 0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 180, 216, 0.4);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #34D399);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 214, 160, 0.3);
}
.btn-accent:hover:not(:disabled) { transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid #334155;
}
.btn-ghost:hover:not(:disabled) {
  background: #1E293B;
  color: var(--text-primary);
  border-color: #475569;
}

.btn-danger {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: white;
}
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); }

/* ─── Nav links ───────────────────────────────────────────────────────────── */
.nav-link {
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94A3B8;
  text-decoration: none;
  transition: all 0.15s ease;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.06); }
.nav-link-active { color: white; background: rgba(0, 180, 216, 0.15); }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
}

.glass-card {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 1rem;
}

/* ─── Messages ────────────────────────────────────────────────────────────── */
.message-success {
  background: rgba(6, 78, 59, 0.9);
  border-color: rgba(6, 214, 160, 0.4);
  color: #D1FAE5;
}
.message-error {
  background: rgba(127, 29, 29, 0.9);
  border-color: rgba(239, 68, 68, 0.4);
  color: #FEE2E2;
}
.message-info, .message-warning {
  background: rgba(30, 58, 138, 0.9);
  border-color: rgba(59, 130, 246, 0.4);
  color: #DBEAFE;
}

/* ─── Map ─────────────────────────────────────────────────────────────────── */
#map-container {
  position: fixed;
  top: 4rem; /* below nav */
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}

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

.leaflet-container { background: #0a1628; }
.leaflet-tile-container { filter: brightness(0.85) saturate(0.8); }

/* Map sidebar panel */
.map-panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 320px;
  z-index: 400;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  scrollbar-width: thin;
}

.map-panel-left {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 280px;
  z-index: 400;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

/* Country highlight */
.country-highlight {
  fill-opacity: 0.35;
  stroke-width: 1.5;
  stroke-opacity: 0.8;
  transition: fill-opacity 0.2s ease;
}
.country-highlight:hover { fill-opacity: 0.55; }

/* Custom markers */
.custom-marker {
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 3px solid rgba(255,255,255,0.8);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.custom-marker-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(45deg);
  font-size: 10px;
  color: white;
  font-weight: 700;
}

.location-marker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  background: #1E293B;
  color: #F1F5F9;
  border-radius: 0.75rem;
  border: 1px solid rgba(148,163,184,0.2);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.leaflet-popup-tip { background: #1E293B; }
.leaflet-popup-close-button { color: #94A3B8 !important; }
.leaflet-popup-close-button:hover { color: #fff !important; }

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes slide-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fade-up {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(0,180,216,0.4); }
  50%       { box-shadow: 0 0 20px rgba(0,180,216,0.7); }
}

.animate-slide-in  { animation: slide-in  0.35s cubic-bezier(0.34,1.56,0.64,1) both; }
.animate-fade-up   { animation: fade-up   0.4s ease both; }
.animate-pulse-glow { animation: pulse-glow 2s ease infinite; }

/* Staggered children */
.stagger > * { animation: fade-up 0.4s ease both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }

/* ─── Auth pages ──────────────────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh;
  background: radial-gradient(ellipse at 20% 60%, rgba(0,180,216,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(6,214,160,0.06) 0%, transparent 50%),
              #0F172A;
}

.auth-card {
  background: rgba(30,41,59,0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(148,163,184,0.12);
  border-radius: 1.5rem;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}

/* ─── Leaderboard podium ──────────────────────────────────────────────────── */
.podium-1 { background: linear-gradient(135deg, #B8860B, #FFD700); }
.podium-2 { background: linear-gradient(135deg, #808080, #C0C0C0); }
.podium-3 { background: linear-gradient(135deg, #8B4513, #CD7F32); }

/* ─── Friend color pills ──────────────────────────────────────────────────── */
.color-swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: white; transform: scale(1.2); box-shadow: 0 0 8px rgba(255,255,255,0.5); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .map-panel, .map-panel-left { 
    position: relative; 
    width: 100%;
    top: auto; left: auto; right: auto;
    max-height: 40vh;
  }
}
