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

:root {
  --color-bg: #0b1220;
  --color-bg-alt: #111a2e;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-inverse: #e2e8f0;
  --color-primary: #6366f1;
  --color-primary-dark: #4338ca;
  --color-border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --max-width: 1100px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-text);
  background: #f8fafc;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
  background: var(--color-bg);
  padding: 16px 0;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-logo {
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.navbar-logo span { color: #818cf8; }

.navbar-tagline {
  color: #94a3b8;
  font-size: 13px;
  display: none;
}

@media (min-width: 640px) {
  .navbar-tagline { display: block; }
}

/*
 * Selector de idioma: menú desplegable propio (no <select> nativo). Las banderas se
 * dibujan con SVG inline en vez del emoji de bandera de país: Windows no incluye esos
 * glifos en su fuente de emoji del sistema, así que Chrome en Windows mostraba el
 * código de dos letras en texto plano en lugar de la bandera (Firefox sí la mostraba).
 */
.lang-switcher {
  position: relative;
}

.lang-switcher-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.lang-switcher-toggle:hover,
.lang-switcher-toggle:focus,
.lang-switcher.open .lang-switcher-toggle {
  border-color: rgba(255, 255, 255, 0.35);
  background-color: rgba(255, 255, 255, 0.14);
}

.lang-flag {
  display: inline-block;
  width: 18px;
  height: 13px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
  /* Un tono medio funciona como borde visible tanto sobre el navbar oscuro como sobre
     el desplegable blanco — algunas banderas (Japón) son casi blancas y, si no, se
     confunden con el fondo del desplegable. */
  box-shadow: 0 0 0 1px rgba(100, 116, 139, 0.45);
}

.lang-flag svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lang-name {
  white-space: nowrap;
}

.lang-switcher-toggle .lang-name {
  display: none;
}

@media (min-width: 640px) {
  .lang-switcher-toggle .lang-name { display: inline; }
}

.lang-chevron {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.lang-switcher.open .lang-chevron {
  transform: rotate(180deg);
}

.lang-dropdown {
  list-style: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 50;
  display: none;
}

.lang-switcher.open .lang-dropdown {
  display: block;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}

.lang-option:hover {
  background-color: #f1f5f9;
}

.lang-option.active {
  font-weight: 600;
  color: var(--color-primary);
}

/* ── Hero ────────────────────────────────────────────────────────────────── */

.hero {
  background: linear-gradient(180deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
  padding: 40px 0 60px;
}

.hero h1 {
  color: #fff;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.hero-description {
  color: #94a3b8;
  font-size: 15px;
  text-align: center;
  max-width: 520px;
  margin: 0 auto 44px;
  line-height: 1.5;
}

.share-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 0 auto 28px;
}

.share-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  transition: transform 0.15s, opacity 0.15s;
}

.share-btn:hover { transform: scale(1.08); opacity: 0.88; }

.share-btn--facebook { background: #1877f2; }
.share-btn--twitter { background: #000000; }
.share-btn--whatsapp { background: #25d366; }
.share-btn--telegram { background: #26a5e4; }
.share-btn--instagram {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
}

.share-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.share-tooltip--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.share-block {
  margin: 24px 0;
  text-align: center;
}

.share-block .share-bar {
  margin: 8px auto 0;
}

.share-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-box {
  max-width: 480px;
  margin: 0 auto 32px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  outline: none;
  box-shadow: var(--shadow);
}

.search-box gmp-place-autocomplete {
  display: block;
  width: 100%;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.search-fallback-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 20;
}

.search-fallback-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 14px;
}

.search-fallback-item:hover { background: #f1f5f9; }

.search-fallback-empty {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.map-wrap {
  background: var(--color-bg-alt);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

#map-root {
  height: 320px;
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
}

@media (min-width: 640px) {
  #map-root { height: 420px; }
}

.map-click-status {
  display: none;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 13px;
  text-align: center;
}

.map-click-status.map-click-status--visible { display: block; }

.map-click-status.map-click-status--error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.map-status {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

/* ── Sections ────────────────────────────────────────────────────────────── */

.section { padding: 48px 0; }

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

/* ── Top cities list ─────────────────────────────────────────────────────── */

.top-cities-list {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
}

.top-city-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

.top-city-row:last-child { border-bottom: none; }
.top-city-row:hover { background: #f8fafc; }

.top-city-rank {
  font-weight: 700;
  color: var(--color-text-muted);
  width: 28px;
  flex-shrink: 0;
  text-align: center;
}

.top-city-rank.rank-1 { color: #eab308; }
.top-city-rank.rank-2 { color: #94a3b8; }
.top-city-rank.rank-3 { color: #b45309; }

.top-city-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24px;
}

.top-city-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.top-city-flag {
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: var(--color-primary-dark);
  border-radius: 6px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.top-city-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.top-city-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-city-bidder {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-city-bid {
  font-weight: 700;
  color: #16a34a;
  white-space: nowrap;
}

.empty-msg {
  padding: 24px;
  text-align: center;
  color: var(--color-text-muted);
}

/* ── City page ───────────────────────────────────────────────────────────── */

.city-page {
  max-width: 560px;
  margin: 40px auto;
  padding: 0 20px;
}

.city-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.back-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--color-primary); }

.city-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.city-flag {
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: var(--color-primary-dark);
  border-radius: 6px;
  padding: 2px 8px;
}

.city-header h1 { font-size: 24px; font-weight: 800; }
.city-country { color: var(--color-text-muted); margin-bottom: 24px; }

.city-stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.city-stat {
  flex: 1;
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 14px 16px;
}

.city-stat-label { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.city-stat-value { font-size: 20px; font-weight: 700; margin-top: 2px; }

.city-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #eef2ff;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 16px;
}

.city-photo img { width: 100%; height: 100%; object-fit: cover; }

.city-photo-initial {
  font-size: 48px;
  font-weight: 800;
  color: var(--color-primary);
}

.city-display-name {
  text-align: center;
  font-weight: 600;
  margin-bottom: 28px;
  color: var(--color-text-muted);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field select, .field input[type="number"], .field input[type="text"], .field input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}

.field-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  transition: background 0.15s;
}

.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.test-mode-notice {
  background: #fefce8;
  border: 1px solid #fde68a;
  color: #854d0e;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

.loading-block { text-align: center; padding: 48px 0; color: var(--color-text-muted); }

.footer {
  text-align: center;
  padding: 28px 20px;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .hero { padding: 28px 0 40px; }
  .city-card { padding: 24px 20px; }
  .city-stats-row { flex-direction: column; gap: 10px; }
  .top-city-row { padding: 10px 16px; gap: 10px; }
  .top-city-avatar { width: 48px; height: 48px; font-size: 18px; }
}
