/**
 * ============================================================================
 * ARCHIVO: src/public/css/ranking.css
 * PROPOSITO: Estilos para el Comparador Regional (-5 a +5) inspirado en
 *            Ground News (ranking.html).
 *            - Barra de distribucion en 3 tramos (Izquierda, Centro, Derecha)
 *            - Casilleros de -5 a +5 con banderas circulares
 *            - Fila en gris para paises con cobertura "sin_datos"
 *            - Panel de evidencia con los puntos que sostienen el puntaje
 * ============================================================================
 */

html:has(body.as-ranking-page),
html.as-ranking-html,
body.as-ranking-page {
  overflow-y: auto !important;
  overflow-x: hidden;
  height: auto !important;
  min-height: 100vh;
  background: #f8fafc;
}

.as-ranking-container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.as-ranking-hero {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

/* Si se incrusta en modo compacto (?embed=1&solo_tabla=1), oculta el selector superior */
body.is-compact-ranking #ranking-controls-card {
  display: none !important;
}

body.is-embed .as-ranking-container {
  padding: 12px 12px 32px;
}

.as-ranking-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.as-capa-switch {
  display: inline-flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.as-capa-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.as-capa-btn.is-active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.as-spectrum-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.as-db-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.as-db-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 99px;
}

.as-db-pill.is-pry {
  background: #ccfbf1;
  color: #0f766e;
}

.as-db-pill.is-pol {
  background: #dbeafe;
  color: #1d4ed8;
}

.as-flag-counts {
  font-size: 9.5px;
  font-weight: 600;
  color: #64748b;
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 5px;
  border-radius: 4px;
}

.as-country-breakdown-pills {
  display: flex;
  gap: 6px;
}

.as-evidence-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.as-col-heading {
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.as-col-heading.is-pry {
  background: #f0fdfa;
  color: #0f766e;
  border-left: 4px solid #0d9488;
}

.as-col-heading.is-pol {
  background: #eff6ff;
  color: #1d4ed8;
  border-left: 4px solid #2563eb;
}

.as-evidence-type-badge {
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

@media (max-width: 900px) {
  .as-evidence-columns {
    grid-template-columns: 1fr;
  }
}

.as-ranking-hero h1 {
  font-size: 22px;
  color: #0f172a;
  margin-bottom: 6px;
}

.as-ranking-hero p {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 16px;
}

.as-idea-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.as-idea-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.as-idea-pill:hover {
  border-color: #0d9488;
  color: #0f766e;
}

.as-idea-pill.is-active {
  background: #0d9488;
  border-color: #0d9488;
  color: #ffffff;
}

/* Tarjeta principal estilo Ground News */
.as-spectrum-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.as-spectrum-header h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.as-spectrum-header p {
  font-size: 13.5px;
  color: #64748b;
}

/* Barra horizontal de 3 tramos */
.as-gn-bar-track {
  display: flex;
  width: 100%;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
}

.as-gn-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.as-gn-segment.is-left {
  background: #dc2626;
}

.as-gn-segment.is-center {
  background: #475569;
}

.as-gn-segment.is-right {
  background: #0d9488;
}

/* Grilla de 11 columnas (-5 a +5) con banderas circulares */
.as-scale-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(78px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.as-score-column {
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 12px;
}

.as-score-column.slot-left {
  background: #fff1f2;
  border-color: #fecdd3;
}

.as-score-column.slot-center {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.as-score-column.slot-right {
  background: #f0fdfa;
  border-color: #99f6e4;
}

.as-score-header {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 10px;
  padding: 2px 8px;
  border-radius: 99px;
}

.slot-left .as-score-header {
  color: #be123c;
  background: #ffe4e6;
}

.slot-center .as-score-header {
  color: #334155;
  background: #e2e8f0;
}

.slot-right .as-score-header {
  color: #0f766e;
  background: #ccfbf1;
}

.as-score-flags {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.as-slot-empty {
  color: #cbd5e1;
  font-size: 20px;
  margin-top: 24px;
}

/* Burbuja circular con la bandera del pais */
.as-flag-bubble {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 10px;
  transition: transform 0.15s ease;
}

.as-flag-bubble:hover {
  transform: translateY(-2px) scale(1.06);
}

.as-flag-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #ffffff;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.22);
  background: #e2e8f0;
}

.as-flag-bubble.is-selected .as-flag-img {
  border-color: #0f172a;
  box-shadow: 0 0 0 3px #14b8a6;
}

.as-flag-iso {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
}

/* Fila gris para paises con cobertura "sin_datos" */
.as-nodata-box {
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.as-nodata-info h3 {
  font-size: 14px;
  color: #334155;
  margin-bottom: 2px;
}

.as-nodata-info p {
  font-size: 12.5px;
  color: #64748b;
}

.as-nodata-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.as-flag-bubble.is-nodata .as-flag-img {
  filter: grayscale(85%);
  opacity: 0.78;
}

.as-nodata-tag {
  font-size: 10px;
  background: #cbd5e1;
  color: #334155;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Panel de explicacion y puntos que sostienen el puntaje */
.as-evidence-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
}

.as-evidence-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 16px;
}

.as-evidence-country {
  display: flex;
  align-items: center;
  gap: 14px;
}

.as-evidence-flag {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.as-evidence-country h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.as-evidence-country p {
  font-size: 13.5px;
  color: #475569;
}

.as-evidence-score-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.as-score-badge {
  font-size: 20px;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 10px;
  color: #ffffff;
}

.as-score-badge.badge-left {
  background: #dc2626;
}

.as-score-badge.badge-center {
  background: #475569;
}

.as-score-badge.badge-right {
  background: #0d9488;
}

.as-score-badge.badge-nodata {
  background: #94a3b8;
  font-size: 13px;
}

.as-link-map {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: #0f766e;
  background: #ccfbf1;
  padding: 8px 14px;
  border-radius: 8px;
}

.as-evidence-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.as-evidence-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.as-evidence-thumb {
  width: 84px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.as-evidence-info {
  flex: 1;
}

.as-evidence-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 3px;
}

.as-evidence-code {
  font-family: monospace;
  font-weight: 700;
  color: #0f172a;
}

.as-verified-pill {
  color: #0f766e;
  font-weight: 700;
}

.as-evidence-info h4 {
  font-size: 15px;
  margin-bottom: 4px;
}

.as-evidence-info p {
  font-size: 12.5px;
  color: #475569;
}

.as-evidence-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #0f172a;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.as-empty-evidence {
  padding: 20px;
  text-align: center;
  color: #64748b;
  font-size: 13.5px;
}
