/* ============================================================
   smgr · css/pages/viz_mapa_paises.css — DISEÑO de la visualización
   "Mapa Mundial de la ACB" (visualizacion_mapa_paises.php).
   La TARJETA capturable (mapamundi D3 + ranking) va scopeada bajo #captureArea;
   los CONTROLES viven FUERA (namespace .mapviz-tools). Tooltip y modal
   (position:fixed) a nivel de página con nombres de clase distintivos.
   Ancho natural 1200px. Sin reset global ni body{background}.
   ============================================================ */

/* ---------- Controles (fuera del captureArea) ---------- */
.mapviz-tools {
  background: #fff; border-radius: 12px; padding: 16px 25px;
  width: 1200px; max-width: 100%;
  margin: 16px auto 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  font-family: 'Inter', sans-serif;
}
.mapviz-tools .control-group { display: flex; flex-direction: column; gap: 4px; }
.mapviz-tools .control-group label {
  font-size: 11px; font-weight: 600; color: #4a5568;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.mapviz-tools .control-group select {
  font-family: 'Inter', sans-serif; font-size: 13px;
  padding: 8px 12px; border: 1px solid #cbd5e0;
  border-radius: 8px; outline: none; background: #f7fafc;
}
.mapviz-tools .control-group select:focus {
  border-color: #4299e1; box-shadow: 0 0 0 2px rgba(66,153,225,0.2);
}
.mapviz-tools .map-switch-link {
  font-size: 13px; font-weight: 600; color: #2c5282;
  text-decoration: none; padding: 8px 14px; border: 1px solid #cbd5e0;
  border-radius: 8px; background: #f7fafc; white-space: nowrap;
  transition: all 0.2s;
}
.mapviz-tools .map-switch-link:hover { background: #edf2f7; border-color: #4299e1; }
.mapviz-tools .map-switch-link i { margin-right: 4px; }

/* ---------- Tarjeta capturable ---------- */
#captureArea {
  font-family: 'Inter', sans-serif;
  background: #fff; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.1);
  overflow: hidden; width: 1200px; position: relative;
}

/* Header */
#captureArea .chart-header {
  background: linear-gradient(135deg, #2c5282 0%, #2a4365 100%);
  padding: 12px 24px; display: flex; align-items: center; gap: 14px;
}
#captureArea .logo {
  width: 50px; height: 38px; background: white; border-radius: 15%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.3); overflow: hidden; flex-shrink: 0;
}
#captureArea .logo img { width: 100%; height: 100%; object-fit: contain; }
#captureArea .chart-header h2 { color: white; font-size: 17px; font-weight: 700; }
#captureArea .chart-header p { color: rgba(255,255,255,0.7); font-size: 11px; margin-top: 2px; }

/* Stat pills */
#captureArea .stat-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 24px;
  background: #f7fafc; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap;
}
#captureArea .stat-pill {
  padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid #cbd5e0; background: white; color: #4a5568;
  transition: all 0.2s;
}
#captureArea .stat-pill:hover { border-color: #4299e1; color: #2c5282; }
#captureArea .stat-pill.active {
  background: linear-gradient(135deg, #2c5282, #2a4365);
  color: white; border-color: #2c5282;
}
#captureArea .stat-bar-spacer { flex: 1; }

/* Main layout */
#captureArea .map-layout {
  display: flex; padding: 16px 24px; gap: 20px; min-height: 520px;
}
#captureArea .map-panel { flex: 1; min-width: 0; position: relative; }
#captureArea .map-panel svg { width: 100%; height: 100%; cursor: grab; }
#captureArea .map-panel svg:active { cursor: grabbing; }
#captureArea .map-panel path.country {
  stroke: #cbd5e0; stroke-width: 0.4; transition: fill 0.15s;
}
#captureArea .map-panel path.country:hover { stroke: #2c5282; stroke-width: 1.2; }
#captureArea .map-panel path.country.has-data:hover { cursor: pointer; }

/* Legend */
#captureArea .legend-bar {
  position: absolute; bottom: 8px; left: 24px; right: 24px;
  display: flex; align-items: center; gap: 8px;
}
#captureArea .legend-gradient {
  flex: 1; height: 10px; border-radius: 5px; border: 1px solid #e2e8f0;
}
#captureArea .legend-labels {
  display: flex; justify-content: space-between; font-size: 10px;
  color: #718096; margin-top: 2px;
}
#captureArea .legend-section { flex: 1; }

#captureArea .btn-reset-zoom {
  position: absolute; top: 8px; right: 8px;
  background: white; border: 1px solid #cbd5e0; border-radius: 6px;
  padding: 4px 10px; font-size: 11px; font-weight: 600; color: #4a5568;
  cursor: pointer; font-family: 'Inter', sans-serif; z-index: 2;
}
#captureArea .btn-reset-zoom:hover { background: #f7fafc; }

/* Ranking panel */
#captureArea .ranking-panel {
  width: 300px; flex-shrink: 0; overflow-y: auto; max-height: 500px;
}
#captureArea .ranking-title {
  font-size: 13px; font-weight: 700; color: #2d3748; margin-bottom: 8px;
  padding-bottom: 6px; border-bottom: 2px solid #2c5282;
}
#captureArea .ranking-row {
  display: flex; align-items: center; padding: 5px 8px; border-radius: 6px;
  cursor: pointer; transition: background 0.15s; gap: 8px;
}
#captureArea .ranking-row:hover { background: #edf2f7; }
#captureArea .ranking-pos {
  width: 22px; font-size: 11px; font-weight: 700; color: #a0aec0; text-align: right;
}
#captureArea .ranking-name {
  flex: 1; font-size: 12px; font-weight: 600; color: #2d3748;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#captureArea .ranking-flag {
  width: 20px; height: 14px; border-radius: 2px; object-fit: cover;
  border: 1px solid #e2e8f0;
}
#captureArea .ranking-val {
  font-size: 12px; font-weight: 700; color: #2c5282;
  font-variant-numeric: tabular-nums; min-width: 50px; text-align: right;
}

/* Footer */
#captureArea .chart-footer {
  background: #2d3748; padding: 10px 16px; text-align: center; font-size: 10px;
  display: flex; justify-content: center; gap: 16px;
  border-radius: 0 0 20px 20px;
}
#captureArea .chart-footer span { color: white; opacity: 0.8; }

/* Loading overlay (dentro del captureArea) */
#captureArea .loading-overlay {
  position: absolute; inset: 0; background: rgba(255,255,255,0.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #4a5568; z-index: 10;
  border-radius: 20px;
}
#captureArea .loading-overlay.hidden { display: none; }

/* ---------- Tooltip (nivel de página, position:fixed) ---------- */
.map-tooltip {
  position: fixed; pointer-events: none; background: #2d3748; color: white;
  padding: 10px 14px; border-radius: 8px; font-size: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 1000;
  max-width: 260px; opacity: 0; transition: opacity 0.15s;
  font-family: 'Inter', sans-serif;
}
.map-tooltip.visible { opacity: 1; }
.map-tooltip .tt-country { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.map-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.map-tooltip .tt-label { color: #a0aec0; }
.map-tooltip .tt-val { font-weight: 600; }

/* ---------- Modal (nivel de página, position:fixed) ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 2000; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: white; border-radius: 16px; max-width: 700px; width: 95%;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  background: linear-gradient(135deg, #2c5282 0%, #2a4365 100%);
  padding: 16px 24px; border-radius: 16px 16px 0 0;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { color: white; font-size: 16px; font-weight: 700; }
.modal-header .modal-stats { color: rgba(255,255,255,0.8); font-size: 12px; }
.modal-close {
  background: rgba(255,255,255,0.2); border: none; color: white;
  width: 28px; height: 28px; border-radius: 50%; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.3); }
.modal-body { padding: 16px 24px; }
.modal-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px;
}
.modal-stat {
  background: #f7fafc; border-radius: 8px; padding: 10px; text-align: center;
}
.modal-stat .ms-val { font-size: 18px; font-weight: 800; color: #2c5282; }
.modal-stat .ms-label { font-size: 10px; color: #718096; text-transform: uppercase; font-weight: 600; }
.modal-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.modal-table thead th {
  background: #f7fafc; padding: 8px 10px; text-align: left;
  font-weight: 700; color: #4a5568; font-size: 11px; text-transform: uppercase;
  border-bottom: 2px solid #e2e8f0; position: sticky; top: 0;
}
.modal-table thead th.num { text-align: right; }
.modal-table tbody td { padding: 6px 10px; border-bottom: 1px solid #f0f0f0; }
.modal-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.modal-table tbody tr:hover { background: #f7fafc; }
.active-badge {
  display: inline-block; background: #48bb78; color: white;
  padding: 1px 6px; border-radius: 10px; font-size: 9px; font-weight: 700;
  margin-left: 4px; vertical-align: middle;
}
.player-photo-sm {
  width: 24px; height: 29px; border-radius: 3px; object-fit: cover;
  vertical-align: middle; background: #e2e8f0;
}
.player-link { color: inherit; text-decoration: none; }
.player-link:hover { text-decoration: underline; }
.player-cell-modal { display: flex; align-items: center; gap: 6px; }
.player-photo-placeholder {
  width: 24px; height: 29px; border-radius: 3px; background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  color: #a0aec0; font-size: 12px; flex-shrink: 0;
}
.player-teams { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 1px; }
.player-teams img { width: 14px; height: 16px; vertical-align: middle; }
.team-badge-placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 16px; background: #e2e8f0; border-radius: 2px;
  font-size: 7px; font-weight: 700; color: #718096; cursor: default;
  vertical-align: middle;
}
.modal-table thead th.sortable {
  cursor: pointer; user-select: none; position: relative; padding-right: 16px;
}
.modal-table thead th.sortable::after {
  content: '⇅'; position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: #a0aec0;
}
.modal-table thead th.sortable.sort-asc::after { content: '▲'; color: #2c5282; }
.modal-table thead th.sortable.sort-desc::after { content: '▼'; color: #2c5282; }

/* Mobile (modal + controls only — la tarjeta la escala el viz-scaler) */
@media (max-width: 900px) {
  .mapviz-tools { width: 100%; padding: 12px 16px; }
  .modal-box { max-width: 98%; border-radius: 12px; }
  .modal-header { padding: 12px 16px; border-radius: 12px 12px 0 0; }
  .modal-header h3 { font-size: 14px; }
  .modal-body { padding: 12px 16px; }
  .modal-summary { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .modal-table { font-size: 11px; }
  .modal-table thead th { padding: 6px 6px; font-size: 10px; }
  .modal-table tbody td { padding: 5px 6px; }
  .modal-table .hide-mobile { display: none; }
}
