/* ════════════════════════════════════════════════════════════════════
   TerraNava — Components v6 · Dark / Mapbox
   Requiere terranava-tokens.css cargado primero.
   ════════════════════════════════════════════════════════════════════ */

/* ═══ HERO institucional ════════════════════════════════════════════ */

.tn-hero {
  padding: clamp(48px, 8vw, 96px) 0 clamp(40px, 6vw, 72px);
  background: var(--tn-bg);
  border-bottom: 1px solid var(--tn-line);
}
.tn-hero .shell { max-width: var(--shell-max); margin: 0 auto; padding: 0 var(--shell-pad); }
.tn-hero-overline {
  font-family: var(--tn-display);
  font-size: var(--fs-tiny);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--tn-accent);
  margin-bottom: var(--space-md);
  font-weight: 600;
}
.tn-hero-title {
  font-family: var(--tn-display);
  font-size: var(--fs-hero);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--tn-ink);
  max-width: 880px;
}
.tn-hero-subtitle {
  font-family: var(--tn-body);
  font-size: clamp(16px, 1.4vw, 19px);
  color: var(--tn-muted);
  margin-top: var(--space-md);
  line-height: 1.55;
  max-width: 680px;
}
.tn-hero-actions {
  display: flex; gap: 14px;
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

/* ═══ Botones — Outline style (Mapbox) ══════════════════════════════ */
.tn-btn {
  font-family: var(--tn-body);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
/* Outline blanco — CTA principal */
.tn-btn-primary {
  background: transparent;
  color: var(--tn-ink);
  border: 1.5px solid rgba(255, 255, 255, 0.50);
}
.tn-btn-primary:hover {
  background: var(--tn-ink);
  color: var(--tn-ink-inverse);
  border-color: var(--tn-ink);
}
/* Outline dorado — CTA secundario / accent */
.tn-btn-secondary {
  background: transparent;
  color: var(--tn-accent);
  border: 1.5px solid var(--tn-accent);
}
.tn-btn-secondary:hover {
  background: var(--tn-accent);
  color: var(--tn-ink-inverse);
}
/* Link style */
.tn-btn-link {
  background: transparent;
  color: var(--tn-accent);
  border: none;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

/* ═══ IVH Badges ════════════════════════════════════════════════════ */
.tn-ivh-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--tn-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid;
}
.tn-ivh-badge--critico { background: var(--ivh-critico-bg); color: var(--ivh-critico-ink); border-color: rgba(231,76,60,0.40); }
.tn-ivh-badge--alto    { background: var(--ivh-alto-bg);    color: var(--ivh-alto-ink);    border-color: rgba(230,126,34,0.40); }
.tn-ivh-badge--medio   { background: var(--ivh-medio-bg);   color: var(--ivh-medio-ink);   border-color: rgba(243,156,18,0.40); }
.tn-ivh-badge--bajo    { background: var(--ivh-bajo-bg);    color: var(--ivh-bajo-ink);    border-color: rgba(39,174,96,0.40); }

/* Aliases soft */
.tn-ivh-badge--critico-soft { background: var(--ivh-critico-bg); color: var(--ivh-critico-ink); border-color: rgba(231,76,60,0.30); }
.tn-ivh-badge--alto-soft    { background: var(--ivh-alto-bg);    color: var(--ivh-alto-ink);    border-color: rgba(230,126,34,0.30); }
.tn-ivh-badge--medio-soft   { background: var(--ivh-medio-bg);   color: var(--ivh-medio-ink);   border-color: rgba(243,156,18,0.30); }
.tn-ivh-badge--bajo-soft    { background: var(--ivh-bajo-bg);    color: var(--ivh-bajo-ink);    border-color: rgba(39,174,96,0.30); }

/* ═══ Map shell ═════════════════════════════════════════════════════ */
.tn-map-shell {
  position: relative;
  width: 100%;
  height: calc(100vh - 120px);
  min-height: 540px;
  background: var(--tn-bg);
  overflow: hidden;
}
#map-canvas {
  position: absolute;
  inset: 0;
  left: 220px;
  background: #0E1A2D;
}
@media (max-width: 860px) {
  #map-canvas { left: 0; }
}

/* ─── Sidebar izquierda del mapa — dark ─── */
.tn-sidebar-left {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 220px;
  background: rgba(14, 14, 14, 0.97);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--tn-line);
  padding: 22px 18px;
  overflow-y: auto;
  z-index: 100;
  font-family: var(--tn-body);
}
.tn-sidebar-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--tn-line);
}
.tn-sidebar-section:last-child { border-bottom: none; }
.tn-sidebar-section .overline {
  font-family: var(--tn-display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--tn-faint);
  font-weight: 600;
  margin-bottom: 12px;
}
.tn-sidebar-section a,
.tn-sidebar-section label,
.tn-sidebar-section .tn-tag {
  display: block;
  font-family: var(--tn-body);
  font-size: 13px;
  color: var(--tn-muted);
  padding: 5px 0;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: left;
  width: 100%;
}
.tn-sidebar-section a:hover,
.tn-sidebar-section .tn-tag:hover { color: var(--tn-ink); }
.tn-sidebar-section .tn-tag.active {
  color: var(--tn-accent);
  font-weight: 600;
  position: relative;
}
.tn-sidebar-section .tn-tag.active::before {
  content: '';
  position: absolute;
  left: -18px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 14px;
  background: var(--tn-accent);
}
.tn-sidebar-section input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--tn-accent);
}

/* ═══ Breadcrumb ════════════════════════════════════════════════════ */
.tn-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--tn-body);
  font-size: 12px; color: var(--tn-muted);
  flex-wrap: wrap; margin-bottom: var(--space-md);
}
.tn-breadcrumb-item { color: var(--tn-muted); text-decoration: none; }
.tn-breadcrumb-item:hover { color: var(--tn-accent); }
.tn-breadcrumb-item--active { color: var(--tn-ink); font-weight: 500; }
.tn-breadcrumb-sep { color: var(--tn-line-strong); font-size: 11px; user-select: none; }

/* ═══ Back button ═══════════════════════════════════════════════════ */
.tn-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--tn-body); font-size: 12.5px; font-weight: 500;
  color: var(--tn-muted); background: none; border: none;
  cursor: pointer; padding: 6px 0; text-decoration: none;
  transition: color var(--t-fast);
}
.tn-back-btn::before { content: '←'; font-size: 13px; }
.tn-back-btn:hover { color: var(--tn-accent); }

/* ═══ Status Badge ══════════════════════════════════════════════════ */
.tn-status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--tn-display);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--radius-sm);
  white-space: nowrap;
}
.tn-status-badge--critico { background: var(--ivh-critico-bg); color: var(--ivh-critico-ink); }
.tn-status-badge--alto    { background: var(--ivh-alto-bg);    color: var(--ivh-alto-ink); }
.tn-status-badge--medio   { background: var(--ivh-medio-bg);   color: var(--ivh-medio-ink); }
.tn-status-badge--bajo    { background: var(--ivh-bajo-bg);    color: var(--ivh-bajo-ink); }
.tn-status-badge--info    { background: rgba(116,185,255,0.15); color: #74b9ff; }

/* ═══ Empty State ═══════════════════════════════════════════════════ */
.tn-empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: var(--space-2xl) var(--space-xl);
  text-align: center; color: var(--tn-muted);
}
.tn-empty-state__icon { font-size: 32px; margin-bottom: var(--space-md); opacity: 0.4; }
.tn-empty-state__title {
  font-family: var(--tn-display); font-size: var(--fs-h4);
  font-weight: 600; color: var(--tn-ink); margin-bottom: var(--space-sm);
}
.tn-empty-state__text { font-size: var(--fs-body-sm); line-height: var(--lh-base); max-width: 320px; }

/* ═══ Loading Skeleton ══════════════════════════════════════════════ */
.tn-skeleton {
  background: linear-gradient(90deg,
    var(--tn-surface) 25%,
    var(--tn-surface-strong) 50%,
    var(--tn-surface) 75%
  );
  background-size: 200% 100%;
  animation: tn-skeleton-wave 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes tn-skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.tn-skeleton-line { height: 14px; margin-bottom: 8px; border-radius: var(--radius-sm); }
.tn-skeleton-line--short  { width: 40%; }
.tn-skeleton-line--medium { width: 65%; }
.tn-skeleton-line--full   { width: 100%; }

/* Mobile sidebar */
@media (max-width: 860px) {
  .tn-sidebar-left {
    width: 100%; height: auto; bottom: auto;
    border-right: none; border-bottom: 1px solid var(--tn-line);
    display: flex; overflow-x: auto; padding: 12px 16px; gap: 16px;
  }
  .tn-sidebar-section {
    flex-shrink: 0; border-bottom: none;
    border-right: 1px solid var(--tn-line); padding: 0 16px 0 0;
  }
  .tn-sidebar-section:last-child { border-right: none; }
}

/* ─── Stats strip sobre el mapa ─── */
.tn-map-stats {
  position: absolute; bottom: 20px; right: 20px;
  background: rgba(14, 14, 14, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--tn-line);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--tn-body); font-size: 12px; color: var(--tn-muted);
  z-index: 60; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-md);
}
.tn-map-stats strong {
  font-family: var(--tn-display); color: var(--tn-ink);
  font-weight: 700; font-size: 16px; margin-right: 4px;
}
.tn-map-stats .sep { width: 1px; height: 16px; background: var(--tn-line-strong); }
@media (max-width: 720px) { .tn-map-stats { display: none; } }

/* ═══ Footer institucional ══════════════════════════════════════════ */
.tn-footer-institutional {
  background: var(--tn-bg);
  border-top: 1px solid var(--tn-line);
  padding: clamp(40px, 6vw, 64px) 0 clamp(24px, 3vw, 32px);
  font-family: var(--tn-body); font-size: 13px; color: var(--tn-muted);
}
.tn-footer-institutional .shell { max-width: var(--shell-max); margin: 0 auto; padding: 0 var(--shell-pad); }
.tn-footer-institutional .overline {
  font-family: var(--tn-display); font-size: var(--fs-tiny);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--tn-muted); font-weight: 600; margin-bottom: 24px;
}
.tn-sources-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 32px 40px; align-items: center; margin-bottom: 32px;
}
.tn-sources-grid .source {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.tn-sources-grid .source img {
  max-height: 42px; max-width: 140px; width: auto; height: auto;
  object-fit: contain; opacity: 0.55; transition: opacity var(--t-fast);
  filter: brightness(0) invert(1);
}
.tn-sources-grid .source:hover img { opacity: 0.90; }
.tn-sources-grid .source small {
  font-family: var(--tn-display); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--tn-faint); font-weight: 500;
}
.tn-footer-note {
  font-size: 12px; color: var(--tn-faint); font-style: italic;
  padding-top: 18px; border-top: 1px solid var(--tn-line);
  margin-bottom: 18px; line-height: 1.6;
}
.tn-footer-meta {
  display: flex; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; padding-top: 14px; border-top: 1px solid var(--tn-line);
  font-size: 11.5px; color: var(--tn-faint);
}

/* ═══ Container genérico ════════════════════════════════════════════ */
.tn-container, .container {
  max-width: var(--shell-max); margin: 0 auto;
  padding: clamp(32px, 5vw, 56px) var(--shell-pad);
}
.tn-section { margin-bottom: clamp(40px, 5vw, 72px); }
.tn-section-title {
  font-family: var(--tn-display); font-size: var(--fs-h2);
  font-weight: 700; margin-bottom: var(--space-sm); color: var(--tn-ink);
}
.tn-section-sub {
  font-family: var(--tn-body); color: var(--tn-muted);
  font-size: var(--fs-body); max-width: 720px;
  line-height: 1.6; margin-bottom: var(--space-lg);
}

/* ═══ KPI strip ═════════════════════════════════════════════════════ */
.tn-kpi-strip {
  background: var(--tn-surface);
  border-top: 1px solid var(--tn-line);
  border-bottom: 1px solid var(--tn-line);
}
.tn-kpi-grid {
  max-width: var(--shell-max); margin: 0 auto;
  padding: var(--space-lg) var(--shell-pad);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-xl);
}
.tn-kpi-item { border-left: 2px solid var(--tn-line-strong); padding-left: var(--space-md); }
.tn-kpi-label {
  font-family: var(--tn-display); font-size: var(--fs-tiny);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--tn-muted); font-weight: 600; margin-bottom: 4px;
}
.tn-kpi-value {
  font-family: var(--tn-display); font-size: clamp(28px, 3vw, 40px);
  font-weight: 700; color: var(--tn-ink); line-height: 1; letter-spacing: -0.02em;
}
.tn-kpi-sub { font-family: var(--tn-body); font-size: var(--fs-small); color: var(--tn-muted); margin-top: 4px; }

/* ═══ Map section ═══════════════════════════════════════════════════ */
.tn-map-section {
  background: var(--tn-surface);
  border: 1px solid var(--tn-line);
  border-radius: var(--radius-md); overflow: hidden; margin-bottom: var(--space-lg);
}
.tn-map-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--tn-line);
  background: var(--tn-surface-strong); flex-wrap: wrap; gap: var(--space-md);
}
.tn-map-title {
  font-family: var(--tn-display); font-size: var(--fs-h4); font-weight: 700; color: var(--tn-ink);
}
.tn-map-sources { font-size: var(--fs-small); color: var(--tn-muted); margin-top: 2px; }
.tn-map-body { display: grid; grid-template-columns: 1fr 280px; gap: 0; }
@media (max-width: 860px) { .tn-map-body { grid-template-columns: 1fr; } }
.tn-map-canvas { min-height: 540px; background: var(--tn-bg); }
#ivh-map { width: 100%; height: 100%; min-height: 540px; }
.tn-map-legend-panel {
  padding: var(--space-lg); border-left: 1px solid var(--tn-line);
  background: var(--tn-surface);
}
.tn-legend-title {
  font-family: var(--tn-display); font-size: var(--fs-small);
  font-weight: 700; color: var(--tn-ink);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px;
}
.tn-legend-method { font-size: var(--fs-tiny); color: var(--tn-muted); margin-bottom: var(--space-md); }
.tn-legend-item {
  display: flex; align-items: center; padding: 6px 0;
  font-size: var(--fs-small); color: var(--tn-ink);
}
.tn-legend-swatch {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 2px; margin-right: 10px; flex-shrink: 0;
}
.tn-legend-label { flex: 1; }
.tn-legend-count { font-family: var(--tn-mono); font-size: 11px; color: var(--tn-muted); }
.tn-legend-divider { margin: var(--space-sm) 0; border: none; border-top: 1px solid var(--tn-line); }
.tn-map-footnote {
  padding: var(--space-md) var(--space-lg); font-size: var(--fs-tiny);
  color: var(--tn-muted); border-top: 1px solid var(--tn-line);
  background: var(--tn-surface-strong); font-style: italic;
}

/* ═══ Tabla institucional ═══════════════════════════════════════════ */
.tn-table-card {
  background: var(--tn-surface);
  border: 1px solid var(--tn-line);
  border-radius: var(--radius-md); overflow: hidden; margin-bottom: var(--space-lg);
}
.tn-table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--tn-line);
  background: var(--tn-surface-strong); flex-wrap: wrap; gap: var(--space-sm);
}
.tn-table-overline {
  font-family: var(--tn-display); font-size: var(--fs-tiny);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--tn-muted); font-weight: 600; margin-bottom: 2px;
}
.tn-table-title {
  font-family: var(--tn-display); font-size: var(--fs-h4); font-weight: 700; color: var(--tn-ink);
}
.tn-table { width: 100%; border-collapse: collapse; font-family: var(--tn-body); }
.tn-table thead th {
  font-family: var(--tn-display); font-size: var(--fs-tiny);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
  text-align: left; padding: 12px var(--space-md);
  background: var(--tn-surface-alt); border-bottom: 1px solid var(--tn-line-strong);
  color: var(--tn-muted);
}
.tn-table tbody td {
  padding: 11px var(--space-md); font-size: var(--fs-small);
  border-bottom: 1px solid var(--tn-line); color: var(--tn-ink-soft);
}
.tn-table tbody tr:last-child td { border-bottom: none; }
.tn-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.tn-table tbody tr:hover td { background: rgba(201, 169, 110, 0.06); }
.tn-table .num-th { text-align: right; }
.tn-table td.num { text-align: right; font-family: var(--tn-mono); font-size: 12.5px; }
.tn-table-footnote {
  padding: var(--space-md) var(--space-lg); font-size: var(--fs-tiny);
  color: var(--tn-muted); border-top: 1px solid var(--tn-line); font-style: italic;
}
.tn-btn-premium {
  font-family: var(--tn-body); font-size: 11.5px; font-weight: 600;
  padding: 6px 12px; border: 1.5px solid var(--tn-accent);
  background: transparent; color: var(--tn-accent);
  text-decoration: none; border-radius: var(--radius-sm); letter-spacing: 0.02em;
}
.tn-btn-premium:hover { background: var(--tn-accent); color: var(--tn-ink-inverse); }
.tn-search-input {
  font-family: var(--tn-body); font-size: 13px; padding: 7px 12px;
  border: 1px solid var(--tn-line-strong); border-radius: var(--radius-sm);
  background: var(--tn-surface); color: var(--tn-ink);
}
.tn-search-input:focus { outline: none; border-color: var(--tn-accent); }
.tn-search-input::placeholder { color: var(--tn-muted); }

/* ═══ Exec summary ══════════════════════════════════════════════════ */
.tn-exec-summary {
  background: var(--tn-surface); border-bottom: 1px solid var(--tn-line);
}
.tn-exec-inner {
  max-width: var(--shell-max); margin: 0 auto; padding: var(--space-lg) var(--shell-pad);
}
.tn-exec-header {
  font-family: var(--tn-display); font-size: var(--fs-tiny);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--tn-muted); font-weight: 600; margin-bottom: var(--space-md);
}
.tn-exec-findings {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-md) var(--space-xl);
}
.tn-exec-finding { display: flex; gap: 10px; font-size: var(--fs-body-sm); color: var(--tn-ink-soft); line-height: 1.5; }
.tn-exec-bullet { color: var(--tn-accent); font-weight: 700; flex-shrink: 0; }

/* ═══ Overline genérico ═════════════════════════════════════════════ */
.tn-overline {
  font-family: var(--tn-display); font-size: var(--fs-tiny);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--tn-muted); font-weight: 600;
}
