/* VK Trail — globals.css
   Identidad de marca VK Trail: brochazo sobre papel, montaña afilada,
   paleta oficial del manual (terracota, arena, carbón, gris piedra).

   Colores de marca (fijos, NO cambian entre temas):
     #8B3E2A terracota  ·  #D8C3A5 arena  ·  #3F3F3B carbón  ·  #7A7974 gris

   Tema claro = el papel del logotipo (por defecto, legible a pleno sol).
   Tema oscuro = la banda carbón del manual (automático de noche).

   El semáforo verde/ámbar/rojo se usa a propósito como la señalización de
   riesgo en sendero/aludes — no son solo "colores de estado" genéricos.
*/

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* --- Marca (invariantes) --- */
  --brand-terracota: #8b3e2a;
  --brand-arena: #d8c3a5;
  --brand-carbon: #3f3f3b;
  --brand-gris: #7a7974;

  /* --- Tema claro: el papel del logotipo --- */
  --bg: #f2ece2;              /* papel de montaña */
  --surface: #fbf7f0;         /* papel iluminado */
  --surface-soft: #ebe2d4;
  --surface-alt: #f6f0e6;     /* segundo tono del hero */
  --bg-blur: rgba(242,236,226,.85);
  --nav-bg: rgba(251,247,240,.97);
  --line: #ddd0bb;
  --text: #3f3f3b;            /* carbón de marca */
  --muted: #63625e;           /* gris piedra, contrastado para texto pequeño */

  --accent: #8b3e2a;          /* terracota de marca */
  --accent-dim: #6d3020;
  --accent-soft: rgba(139,62,42,.10);
  --accent-glow: rgba(139,62,42,.14);
  --neutral-soft: rgba(63,63,59,.07);

  --forest: #5a7a52;          /* pino — éxito/completado */
  --glacier: #5b7f91;         /* glaciar — info/frío */
  --granite: #7a7974;         /* granito — neutro secundario */

  --green: #4d6f45;           /* semáforo de sendero: vía libre */
  --amber: #a8761f;           /* semáforo de sendero: precaución */
  --red: #b02f18;             /* semáforo de sendero: peligro */
  --green-soft: rgba(77,111,69,.12);
  --amber-soft: rgba(168,118,31,.14);

  --shadow-lg: 0 16px 40px rgba(63,63,59,.16);
  --shadow-md: 0 10px 28px rgba(63,63,59,.12);
  --shadow-sm: 0 4px 12px rgba(63,63,59,.08);

  --radius-xl: 10px;
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
}

/* --- Tema oscuro: la banda carbón del manual --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #292927;
    --surface: #333330;
    --surface-soft: #3f3f3b;    /* carbón de marca */
    --surface-alt: #2f2f2c;
    --bg-blur: rgba(41,41,39,.85);
    --nav-bg: rgba(47,47,44,.97);
    --line: #4a4a45;
    --text: #f2ece2;            /* papel */
    --muted: #a9a8a2;

    --accent: #b8543a;          /* terracota aclarado para contraste sobre carbón */
    --accent-dim: #8b3e2a;
    --accent-soft: rgba(184,84,58,.14);
    --accent-glow: rgba(184,84,58,.18);
    --neutral-soft: rgba(242,236,226,.07);

    --green: #7ba36c;
    --amber: #d0a24a;
    --red: #d4644a;
    --green-soft: rgba(123,163,108,.14);
    --amber-soft: rgba(208,162,74,.14);

    --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
    --shadow-md: 0 10px 28px rgba(0,0,0,.4);
    --shadow-sm: 0 4px 12px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== SHELL ===== */
.hm-shell {
  display: flex;
  min-height: 100dvh;
  background: var(--bg);
}

/* SIDEBAR */
.hm-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.hm-sidebar-logo {
  padding: 4px 8px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hm-sidebar-logo-img { width: 100%; max-width: 176px; height: auto; display: block; }

.hm-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hm-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: all .15s;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.hm-sidebar-link:hover { background: var(--surface-soft); color: var(--text); }
.hm-sidebar-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; border-left-color: var(--accent); }
.hm-sidebar-link .icon { font-size: 18px; line-height: 1; }

.hm-sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

/* MAIN */
.hm-main {
  flex: 1 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hm-desktop-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-blur);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.hm-desktop-topbar .title { font-weight: 600; font-size: 14px; }
.hm-desktop-topbar .actions { display: flex; align-items: center; gap: 8px; }
.hm-desktop-topbar .actions a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--muted);
  transition: background .15s;
}
.hm-desktop-topbar .actions a:hover { background: var(--surface-soft); color: var(--text); }

.hm-page-content {
  flex: 1 1;
  padding: 28px 28px 48px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.hm-page-header { margin-bottom: 24px; }
.hm-page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.hm-page-header .sub { color: var(--muted); font-size: 13px; }

/* CARDS */
.hm-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.hm-card h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.hm-card .empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0; }

/* GRIDS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* READINESS HERO */
.readiness-hero {
  display: flex; align-items: center; gap: 24px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.readiness-hero::before {
  content: "";
  position: absolute; top: -40%; right: -10%;
  width: 240px; height: 240px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
}
.readiness-score {
  width: 96px; height: 96px; border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--accent)) 0% var(--p, 92%), var(--surface-soft) var(--p, 92%) 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0;
}
.readiness-score::after {
  content: ""; position: absolute; inset: 7px; background: var(--surface); border-radius: 50%;
}
.readiness-score span {
  position: relative; z-index: 1; font-size: 30px; font-weight: 700; color: var(--text);
}
.readiness-info .label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px; font-weight: 600;
}
.readiness-info .title { font-size: 22px; font-weight: 700; margin: 4px 0 6px; color: var(--text); }
.readiness-info .desc { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* METRIC ROW */
.metric { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.metric:last-child { border-bottom: none; }
.metric .k { color: var(--muted); font-size: 13px; }
.metric .v { font-weight: 600; font-size: 14px; color: var(--text); }
.metric .v.good { color: var(--green); }
.metric .v.warn { color: var(--amber); }
.metric .v.bad { color: var(--red); }

/* PLAN ITEM */
.plan-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: none; }
.plan-item .dot {
  width: 8px; height: 8px; border-radius: 2px; margin-top: 6px; transform: rotate(45deg);
  background: var(--accent); flex-shrink: 0;
}
.plan-item .dot.done { background: var(--green); }
.plan-item .dot.todo { background: var(--accent); }
.plan-item .name { font-weight: 600; font-size: 13px; color: var(--text); }
.plan-item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* BOTTOM NAV (móvil) */
.hm-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 72px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  z-index: 200;
  padding: 0 8px;
  align-items: center;
  justify-content: space-around;
}
.hm-bottom-link {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted);
  padding: 8px 12px;
}
.hm-bottom-link.active { color: var(--accent); font-weight: 600; }
.hm-bottom-link .icon { font-size: 22px; }

@media (max-width: 800px) {
  .hm-shell { flex-direction: column; }
  .hm-sidebar { display: none; }
  .hm-bottom-nav { display: flex; }
  .hm-main { padding-bottom: 96px; }
  .hm-page-content { padding: 16px 16px 32px; }
}

/* CHIPS / BADGES */
.chip {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.gray { background: var(--neutral-soft); color: var(--muted); }

/* SKELETON LOADING */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-soft) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== PANTALLA DE LOGIN ===== */
/* Con .is-login el armazón desaparece: no hay navegación hasta entrar. */
.hm-shell.is-login .hm-sidebar,
.hm-shell.is-login .hm-desktop-topbar,
.hm-shell.is-login .hm-bottom-nav { display: none; }
.hm-shell.is-login .hm-page-content { padding: 0; max-width: none; }

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  /* Fondo fijo (no sigue el tema): el logo horizontal lleva el texto "VK" en
     carbón oscuro, ilegible sobre el fondo oscuro del tema dark. */
  background: #fbf7f0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 28px 32px;
  text-align: center;
}

.login-mark { width: 72px; height: 72px; margin-bottom: 18px; }
.login-mark-horizontal { width: 100%; max-width: 320px; height: auto; margin-bottom: 22px; }

.login-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: 8px;
}
.login-title em { font-style: normal; color: var(--accent); }

.login-sub {
  /* Fijo, no sigue el tema: la tarjeta de login es siempre clara. */
  color: #63625e;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 26px;
}

.login-buttons { display: flex; flex-direction: column; gap: 10px; }

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid #ddd0bb;
  background: #fbf7f0;
  color: #3f3f3b;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
}
.login-btn:hover:not(:disabled) { border-color: var(--brand-terracota); background: rgba(139,62,42,.10); }
.login-btn:disabled { opacity: .55; cursor: progress; }

.login-btn-dark {
  background: var(--brand-carbon);
  border-color: var(--brand-carbon);
  color: #f2ece2;
}
.login-btn-dark:hover:not(:disabled) { background: #2f2f2c; border-color: #2f2f2c; color: #f2ece2; }

.login-btn-icon { font-size: 16px; font-weight: 700; line-height: 1; }

.login-error {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.4;
}

/* ===== INTEGRACIONES (Perfil) ===== */
.hm-connect-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.hm-connect-btn:hover { background: var(--accent-glow); }

/* ===== ACTIVITY DETAIL DRAWER (mapa) =====
   Drawer a pantalla completa en móvil, panel lateral en desktop.
   Pinchar una actividad abre este drawer con el mapa Leaflet. */

.activity-row-clickable {
  cursor: pointer;
  transition: background .12s;
  border-radius: var(--radius-md);
  padding: 4px 6px;
  margin: -4px -6px;
}
.activity-row-clickable:hover { background: var(--accent-soft); }
.activity-row-clickable:active { background: var(--accent-glow); }

.vk-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.vk-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.vk-drawer {
  position: fixed;
  z-index: 9100;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  /* Móvil: bottom sheet */
  left: 0; right: 0; bottom: 0;
  max-height: 92vh;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
  transform: translateY(100%);
  transition: transform .22s cubic-bezier(.2,.7,.2,1);
}
.vk-drawer.is-open { transform: translateY(0); }
@media (min-width: 800px) {
  .vk-drawer {
    /* Desktop: panel lateral derecho */
    left: auto; bottom: 0; top: 0;
    width: 480px;
    max-height: 100vh;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top-right-radius: 0;
    transform: translateX(100%);
  }
  .vk-drawer.is-open { transform: translateX(0); }
}

.vk-drawer-handle {
  width: 44px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 8px auto 0;
}
@media (min-width: 800px) { .vk-drawer-handle { display: none; } }

.vk-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line);
}
.vk-drawer-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
  margin: 0;
}
.vk-drawer-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.vk-drawer-close:hover { color: var(--text); background: var(--neutral-soft); }

.vk-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
  -webkit-overflow-scrolling: touch;
}
.vk-drawer-body .vk-map {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  margin-bottom: 14px;
}
.vk-drawer-body .vk-map .map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}
.vk-drawer-body .vk-map-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 12px;
}
.vk-drawer-body .vk-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin-bottom: 16px;
}
.vk-drawer-body .vk-metrics .metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.vk-drawer-body .vk-metrics .metric .k { color: var(--muted); font-size: 12px; }
.vk-drawer-body .vk-metrics .metric .v { font-weight: 600; font-size: 14px; color: var(--text); }
.vk-drawer-body .vk-open-maps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.vk-drawer-body .vk-open-maps:hover { background: var(--accent-dim); }
.vk-drawer-body .vk-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

/* ===== ACTIVITY PLAYER (playback animado + HUD) ===== */

.vk-player {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--surface);
}
.vk-player-map {
  width: 100%;
  height: 280px;
  background: var(--surface-soft);
  /* El icono Leaflet necesita position:relative para que aparezca */
  position: relative;
}
.vk-player-no-route {
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Marker del corredor: círculo blanco con borde terracota + halo */
.vk-runner-icon { background: transparent; border: 0; }
.vk-runner-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.85), 0 2px 6px rgba(0,0,0,0.35);
  animation: vk-runner-pulse 1.6s ease-out infinite;
}
@keyframes vk-runner-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(231,111,44,0.45), 0 2px 6px rgba(0,0,0,0.35); }
  70%  { box-shadow: 0 0 0 12px rgba(231,111,44,0.00), 0 2px 6px rgba(0,0,0,0.35); }
  100% { box-shadow: 0 0 0 0   rgba(231,111,44,0.00), 0 2px 6px rgba(0,0,0,0.35); }
}

/* HUD */
.vk-player-hud {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vk-player-progress {
  position: relative;
  height: 8px;
  background: var(--surface-soft);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid var(--line);
}
.vk-player-progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 4px;
  transition: width 0.12s linear;
}

.vk-player-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.vk-player-stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4px 2px;
}
.vk-player-stats .stat .k {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.vk-player-stats .stat .v {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}

.vk-player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.vk-player-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: background .12s, transform .08s;
}
.vk-player-btn:hover { background: var(--neutral-soft); }
.vk-player-btn:active { transform: scale(0.94); }
.vk-player-btn-primary {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-size: 18px;
}
.vk-player-btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.vk-player-btn-speed {
  width: auto;
  border-radius: 18px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

@media (max-width: 480px) {
  .vk-player-map { height: 220px; }
  .vk-player-stats .stat .v { font-size: 13px; }
}
