/* ═══════════════════════════════════════════════════════════════
   ESTADÍSTICAS EDUCATIVAS DEL PERÚ — estadisticas.css
   Dashboard minimalista tipo Google Analytics / Tableau
   ═══════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Inter:wght@400;500;600&display=swap');

/* ── TOKENS ──────────────────────────────────────────────────── */
:root {
  --ed-navy:    #0f2744;
  --ed-blue:    #1d4ed8;
  --ed-blue-lt: #3b82f6;
  --ed-teal:    #0891b2;
  --ed-green:   #16a34a;
  --ed-amber:   #d97706;
  --ed-red:     #dc2626;
  --ed-purple:  #7c3aed;
  --ed-bg:      #f0f4f9;
  --ed-card:    #ffffff;
  --ed-border:  #e2e8f0;
  --ed-text:    #1e293b;
  --ed-muted:   #64748b;
  --ed-radius:  14px;
  --ed-shadow:  0 1px 4px rgba(15,39,68,.06), 0 4px 16px rgba(15,39,68,.08);
  --ed-shadow-lg: 0 8px 32px rgba(15,39,68,.14);
  --ed-trans:   .25s ease;
}

/* ── RESET BASE ──────────────────────────────────────────────── */
.ed-wrap * { box-sizing: border-box; }
.ed-wrap { font-family: 'Inter', sans-serif; color: var(--ed-text); background: var(--ed-bg); min-height: 100vh; }

/* ── HERO ─────────────────────────────────────────────────────  */
.ed-hero {
  background: linear-gradient(135deg, var(--ed-navy) 0%, #1e3a72 50%, #0891b2 100%);
  padding: 4.5rem 0 3rem; position: relative; overflow: hidden;
}
.ed-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.ed-hero-content { position: relative; z-index: 2; text-align: center; color: #fff; }
.ed-hero-label {
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 50px; padding: .35rem 1.1rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #93c5fd; margin-bottom: 1.25rem;
  animation: fadeInDown .6s ease both;
}
.ed-hero h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 900; line-height: 1.1;
  margin-bottom: 1rem;
  animation: fadeInUp .6s ease .1s both;
}
.ed-hero h1 span { color: #60a5fa; }
.ed-hero-sub {
  font-size: 1.05rem; opacity: .82; max-width: 560px; margin: 0 auto 2rem; line-height: 1.7;
  animation: fadeInUp .6s ease .2s both;
}
.ed-hero-stats {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 2rem;
  animation: fadeInUp .6s ease .3s both;
}
.ed-hero-stat { text-align: center; }
.ed-hero-stat-val {
  font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1.75rem; color: #fff;
}
.ed-hero-stat-lbl { font-size: .75rem; opacity: .7; letter-spacing: .04em; }

/* ── SELECTOR GEOGRÁFICO ─────────────────────────────────────── */
.ed-geo-bar {
  background: var(--ed-card); border-bottom: 1px solid var(--ed-border);
  padding: 1.1rem 0; position: sticky; top: var(--nav-h, 70px); z-index: 100;
  box-shadow: 0 2px 12px rgba(15,39,68,.08);
}
.ed-geo-inner {
  display: flex; align-items: center; flex-wrap: wrap; gap: .875rem;
}
.ed-geo-breadcrumb {
  display: flex; align-items: center; gap: .35rem; flex: 1; min-width: 0;
  font-size: .8rem; color: var(--ed-muted); flex-wrap: wrap;
}
.ed-geo-breadcrumb a, .ed-geo-breadcrumb span { cursor: pointer; white-space: nowrap; }
.ed-geo-breadcrumb a:hover { color: var(--ed-blue); }
.ed-geo-breadcrumb .sep { color: var(--ed-border); }
.ed-geo-breadcrumb .current { color: var(--ed-navy); font-weight: 700; }
.ed-geo-selects { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; }
.ed-select-wrap { position: relative; }
.ed-select-wrap i {
  position: absolute; left: .875rem; top: 50%; transform: translateY(-50%);
  color: var(--ed-blue); font-size: .8rem; pointer-events: none;
}
.ed-select {
  appearance: none; padding: .6rem 2.5rem .6rem 2.25rem;
  border: 1.5px solid var(--ed-border); border-radius: var(--ed-radius);
  font-size: .83rem; font-weight: 600; color: var(--ed-text);
  background: #fff; cursor: pointer; min-width: 170px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right .75rem center; background-size: 14px;
  transition: border-color var(--ed-trans), box-shadow var(--ed-trans);
}
.ed-select:focus { outline: none; border-color: var(--ed-blue); box-shadow: 0 0 0 3px rgba(29,78,216,.1); }
.ed-select:disabled { opacity: .45; cursor: not-allowed; }

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.ed-main { padding: 2rem 0 4rem; }
.ed-section-title {
  font-family: 'Outfit', sans-serif; font-size: 1.15rem; font-weight: 800;
  color: var(--ed-navy); display: flex; align-items: center; gap: .625rem;
  margin-bottom: 1.25rem;
}
.ed-section-title i { color: var(--ed-blue); font-size: .95rem; }
.ed-section-title small { font-size: .75rem; font-weight: 500; color: var(--ed-muted); margin-left: .5rem; }

/* ── STAT CARDS ──────────────────────────────────────────────── */
.ed-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem;
  margin-bottom: 2rem;
}
.ed-stat-card {
  background: var(--ed-card); border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius); padding: 1.25rem 1.4rem;
  box-shadow: var(--ed-shadow);
  transition: transform var(--ed-trans), box-shadow var(--ed-trans);
  position: relative; overflow: hidden;
}
.ed-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--card-accent, var(--ed-blue));
  border-radius: var(--ed-radius) var(--ed-radius) 0 0;
}
.ed-stat-card:hover { transform: translateY(-3px); box-shadow: var(--ed-shadow-lg); }
.ed-stat-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .875rem; }
.ed-stat-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--card-accent-bg, rgb(29,78,216,.1));
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; color: var(--card-accent, var(--ed-blue));
}
.ed-stat-card-delta {
  font-size: .7rem; font-weight: 700; padding: .2rem .5rem;
  border-radius: 50px; background: rgba(22,163,74,.1); color: #16a34a;
}
.ed-stat-card-val {
  font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 900;
  color: var(--ed-navy); line-height: 1; margin-bottom: .375rem;
}
.ed-stat-card-lbl { font-size: .75rem; font-weight: 600; color: var(--ed-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── CHART GRID ──────────────────────────────────────────────── */
.ed-chart-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem;
  margin-bottom: 2rem;
}
.ed-chart-grid-wide { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.ed-chart-card {
  background: var(--ed-card); border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius); box-shadow: var(--ed-shadow);
  overflow: hidden;
}
.ed-chart-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.4rem .75rem;
  border-bottom: 1px solid var(--ed-border);
}
.ed-chart-card-title {
  font-family: 'Outfit', sans-serif; font-size: .9rem; font-weight: 800; color: var(--ed-navy);
  display: flex; align-items: center; gap: .5rem;
}
.ed-chart-card-title i { color: var(--ed-blue); }
.ed-chart-card-body { padding: 1.25rem; }
.ed-chart-wrap { position: relative; }
.ed-chart-wrap canvas { max-height: 280px; }

/* ── TABLA ───────────────────────────────────────────────────── */
.ed-table-card {
  background: var(--ed-card); border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius); box-shadow: var(--ed-shadow);
  overflow: hidden; margin-bottom: 2rem;
}
.ed-table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .875rem;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--ed-border);
}
.ed-search-wrap { position: relative; }
.ed-search-wrap i { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); color: var(--ed-muted); font-size: .82rem; }
.ed-search {
  padding: .6rem 1rem .6rem 2.25rem;
  border: 1.5px solid var(--ed-border); border-radius: var(--ed-radius);
  font-size: .83rem; color: var(--ed-text); width: 280px; max-width: 100%;
  transition: border-color var(--ed-trans);
}
.ed-search:focus { outline: none; border-color: var(--ed-blue); }
.ed-table-total { font-size: .82rem; color: var(--ed-muted); font-weight: 600; }
.ed-table-wrap { overflow-x: auto; }
table.ed-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.ed-table thead th {
  background: #f8fafc; padding: .75rem 1rem; text-align: left;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ed-muted); border-bottom: 1px solid var(--ed-border);
  position: sticky; top: 0; white-space: nowrap; cursor: pointer; user-select: none;
}
table.ed-table thead th:hover { background: #f1f5f9; color: var(--ed-blue); }
table.ed-table thead th.sort-asc::after { content: ' ↑'; }
table.ed-table thead th.sort-desc::after { content: ' ↓'; }
table.ed-table tbody tr { transition: background var(--ed-trans); }
table.ed-table tbody tr:hover { background: #f8fafc; }
table.ed-table tbody td { padding: .75rem 1rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.ed-table-name { font-weight: 600; color: var(--ed-navy); }
.ed-table-name a { color: inherit; }
.ed-table-name a:hover { color: var(--ed-blue); }
.ed-nivel-badge {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .15rem .55rem; border-radius: 50px;
  font-size: .68rem; font-weight: 700; white-space: nowrap;
}
.ed-num { font-family: 'Outfit', sans-serif; font-weight: 700; text-align: right; }
.ed-table-pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.4rem; border-top: 1px solid var(--ed-border); font-size: .82rem;
}
.ed-pager-btns { display: flex; gap: .375rem; }
.ed-pager-btn {
  padding: .375rem .75rem; border-radius: 8px; border: 1.5px solid var(--ed-border);
  background: #fff; font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--ed-text);
  transition: all .2s;
}
.ed-pager-btn:hover:not(:disabled) { border-color: var(--ed-blue); color: var(--ed-blue); }
.ed-pager-btn.active { background: var(--ed-blue); color: #fff; border-color: var(--ed-blue); }
.ed-pager-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── RANKINGS ────────────────────────────────────────────────── */
.ed-rankings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.ed-ranking-card { background: var(--ed-card); border: 1px solid var(--ed-border); border-radius: var(--ed-radius); box-shadow: var(--ed-shadow); overflow: hidden; }
.ed-ranking-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--ed-border); }
.ed-ranking-head h3 { font-family: 'Outfit', sans-serif; font-size: .9rem; font-weight: 800; color: var(--ed-navy); display: flex; align-items: center; gap: .5rem; }
.ed-ranking-head h3 i { color: var(--ed-amber); }
.ed-ranking-list { padding: .5rem 0; }
.ed-ranking-item {
  display: flex; align-items: center; gap: .875rem;
  padding: .625rem 1.25rem; transition: background var(--ed-trans);
}
.ed-ranking-item:hover { background: #f8fafc; }
.ed-rank-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif; font-size: .75rem; font-weight: 900;
  background: var(--ed-bg); color: var(--ed-navy);
}
.ed-rank-num.gold   { background: #fef3c7; color: #d97706; }
.ed-rank-num.silver { background: #f1f5f9; color: #64748b; }
.ed-rank-num.bronze { background: #fef2f2; color: #b45309; }
.ed-rank-info { flex: 1; min-width: 0; }
.ed-rank-name { font-weight: 700; font-size: .83rem; color: var(--ed-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-rank-sub  { font-size: .7rem; color: var(--ed-muted); }
.ed-rank-bar-wrap { width: 80px; flex-shrink: 0; }
.ed-rank-bar { height: 5px; border-radius: 3px; background: var(--ed-bg); overflow: hidden; margin-bottom: 3px; }
.ed-rank-bar-fill { height: 100%; border-radius: 3px; background: var(--ed-blue); transition: width .8s ease; }
.ed-rank-val { font-family: 'Outfit', sans-serif; font-size: .75rem; font-weight: 800; color: var(--ed-navy); text-align: right; }

/* ── COMPARADOR ──────────────────────────────────────────────── */
.ed-compare-card { background: var(--ed-card); border: 1px solid var(--ed-border); border-radius: var(--ed-radius); box-shadow: var(--ed-shadow); overflow: hidden; margin-bottom: 2rem; }
.ed-compare-head { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--ed-border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .875rem; }
.ed-compare-selects { display: flex; align-items: center; gap: .875rem; flex-wrap: wrap; }
.ed-compare-vs { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1rem; color: var(--ed-muted); padding: 0 .25rem; }
.ed-compare-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.25rem; border-radius: var(--ed-radius);
  background: linear-gradient(135deg, var(--ed-blue), var(--ed-teal));
  color: #fff; font-size: .82rem; font-weight: 700; cursor: pointer;
  border: none; transition: opacity var(--ed-trans), transform var(--ed-trans);
}
.ed-compare-btn:hover { opacity: .88; transform: translateY(-1px); }
.ed-compare-body { padding: 1.4rem; }
.ed-compare-result {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.5rem; align-items: center;
  margin-bottom: 1.5rem;
}
.ed-cmp-region { text-align: center; }
.ed-cmp-region-name { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1.1rem; color: var(--ed-navy); margin-bottom: .375rem; }
.ed-cmp-region-val { font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 900; line-height: 1; }
.ed-cmp-sep { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: var(--ed-bg); font-weight: 900; font-size: .85rem; color: var(--ed-muted); flex-shrink: 0; }
.ed-cmp-bar-row { margin-bottom: 1rem; }
.ed-cmp-bar-label { display: flex; justify-content: space-between; font-size: .75rem; font-weight: 600; color: var(--ed-muted); margin-bottom: .375rem; }
.ed-cmp-bar-track { height: 10px; border-radius: 5px; background: var(--ed-bg); display: flex; overflow: hidden; }
.ed-cmp-bar-a { border-radius: 5px 0 0 5px; transition: width .9s ease; }
.ed-cmp-bar-b { border-radius: 0 5px 5px 0; transition: width .9s ease; }

/* ── MAPA ────────────────────────────────────────────────────── */
.ed-map-card { background: var(--ed-card); border: 1px solid var(--ed-border); border-radius: var(--ed-radius); box-shadow: var(--ed-shadow); overflow: hidden; margin-bottom: 2rem; }
.ed-map-card-head { padding: 1rem 1.4rem; border-bottom: 1px solid var(--ed-border); display: flex; align-items: center; justify-content: space-between; }
#edMap { height: 420px; }

/* ── ANIMACIONES ─────────────────────────────────────────────── */
@keyframes fadeInDown { from { opacity:0; transform:translateY(-16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeInUp   { from { opacity:0; transform:translateY(16px);  } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn     { from { opacity:0; }                              to { opacity:1; } }
@keyframes scaleIn    { from { opacity:0; transform:scale(.92); }        to { opacity:1; transform:scale(1); } }
.ed-anim-in { animation: fadeInUp .45s ease both; }

/* SKELETON */
.ed-skel { background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 50%,#f1f5f9 75%); background-size:200%; animation:shimmer 1.4s infinite; border-radius:6px; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── LOADING OVERLAY ─────────────────────────────────────────── */
.ed-loading {
  display: none; align-items: center; justify-content: center; gap: .5rem;
  position: fixed; inset: 0; background: rgba(15,39,68,.35); z-index: 9999;
  backdrop-filter: blur(2px);
}
.ed-loading.show { display: flex; }
.ed-spinner {
  width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.ed-empty { text-align: center; padding: 3rem 1rem; color: var(--ed-muted); }
.ed-empty i { font-size: 2.5rem; margin-bottom: .875rem; opacity: .4; display: block; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .ed-chart-grid { grid-template-columns: 1fr; }
  .ed-compare-result { grid-template-columns: 1fr; }
  .ed-cmp-sep { margin: .5rem auto; }
  .ed-hero-stats { gap: 1.25rem; }
}
@media (max-width: 640px) {
  .ed-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ed-geo-selects { width: 100%; }
  .ed-select { min-width: 100%; width: 100%; }
  .ed-search, .ed-search-wrap { width: 100%; }
  .ed-table-toolbar { flex-direction: column; align-items: flex-start; }
  .ed-rankings-grid { grid-template-columns: 1fr; }
  #edMap { height: 300px; }
}
