/* ===== Design Tokens – FLACSO Institutional Theme ===== */
:root {
  --flacso-navy: #163970;
  --flacso-navy-light: #1e4d8a;
  --flacso-navy-dark: #0f2a54;
  --flacso-blue: #2563a8;
  --flacso-sky: #3b82c4;

  --bg-primary: #f4f6f9;
  --bg-secondary: #e9edf3;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --border-card: rgba(22, 57, 112, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --accent-1: #163970;
  --accent-2: #2563a8;
  --accent-3: #3b82c4;
  --accent-4: #d97706;
  --accent-5: #dc2626;
  --accent-6: #059669;

  --gradient-primary: linear-gradient(135deg, var(--flacso-navy), var(--flacso-blue));
  --gradient-accent: linear-gradient(135deg, var(--flacso-blue), var(--flacso-sky));

  --shadow-card: 0 2px 12px rgba(22, 57, 112, 0.08);
  --shadow-glow: 0 0 24px rgba(22, 57, 112, 0.10);

  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar Navigation ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: var(--flacso-navy);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  text-align: center;
}

.sidebar-logo {
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: #ffffff;
  padding: 4px;
  object-fit: contain;
}

.sidebar-header h1 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  background: none;
  -webkit-text-fill-color: #ffffff;
}

.sidebar-header .subtitle {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
}

.nav-items {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-items li {
  margin: 2px 8px;
}

.nav-items a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-items a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-items a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.nav-items a .nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.4);
}

/* ===== Mobile Menu Toggle ===== */
.menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

/* ===== Main Content ===== */
.main-content {
  margin-left: 260px;
  padding: 32px 40px 60px;
  min-height: 100vh;
}

/* ===== Page sections ===== */
.page {
  display: none;
  animation: fadeIn 0.4s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--flacso-navy);
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: rgba(22, 57, 112, 0.2);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

/* ===== Scorecards ===== */
.scorecards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.scorecard {
  text-align: center;
  padding: 28px 20px;
  position: relative;
  overflow: hidden;
}

.scorecard::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.scorecard:nth-child(1)::before {
  background: var(--gradient-primary);
}

.scorecard:nth-child(2)::before {
  background: var(--gradient-accent);
}

.scorecard:nth-child(3)::before {
  background: linear-gradient(135deg, var(--accent-4), var(--accent-5));
}

.scorecard:nth-child(4)::before {
  background: linear-gradient(135deg, var(--accent-6), var(--accent-1));
}

.scorecard .sc-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  display: block;
}

.scorecard .sc-value {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--flacso-navy);
  -webkit-text-fill-color: var(--flacso-navy);
  line-height: 1.1;
}

.scorecard:nth-child(2) .sc-value {
  color: var(--flacso-blue);
  -webkit-text-fill-color: var(--flacso-blue);
}

.scorecard:nth-child(3) .sc-value {
  color: var(--accent-4);
  -webkit-text-fill-color: var(--accent-4);
}

.scorecard:nth-child(4) .sc-value {
  color: var(--accent-6);
  -webkit-text-fill-color: var(--accent-6);
}

.scorecard .sc-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}

.scorecard .sc-year {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Grid Layouts ===== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.grid-full {
  margin-bottom: 24px;
}

/* ===== Chart Containers ===== */
.chart-container {
  position: relative;
  width: 100%;
  height: 320px;
}

.chart-container.tall {
  height: 420px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== Filters ===== */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}

.filters-bar label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filters-bar select,
.filters-bar input[type="range"] {
  background: var(--bg-secondary);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition);
}

.filters-bar select:hover,
.filters-bar select:focus {
  border-color: var(--accent-1);
  outline: none;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Multi-select checkboxes */
.country-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-card);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}

.country-chip.selected {
  background: var(--gradient-primary);
  border-color: var(--flacso-navy);
  color: #fff;
}

.country-chip:hover {
  border-color: var(--flacso-navy);
}

/* ===== Provincial Table ===== */
.prov-table-wrapper {
  max-height: 500px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
}

.prov-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.prov-table th,
.prov-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-card);
}

.prov-table th {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
}

.prov-table td {
  color: var(--text-primary);
}

.prov-table tbody tr:hover {
  background: rgba(22, 57, 112, 0.05);
}

.prov-bar {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  background: var(--gradient-primary);
  vertical-align: middle;
  margin-left: 8px;
  transition: width var(--transition);
}

/* ===== Significance Indicators ===== */
.sig-yes {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  font-weight: 600;
  font-size: 0.8rem;
}

.sig-no {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.15);
  color: #64748b;
  font-weight: 600;
  font-size: 0.8rem;
}


/* ===== Hero Section (Inicio) ===== */
.hero {
  text-align: center;
  padding: 48px 20px 36px;
  margin-bottom: 32px;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(22, 57, 112, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
}

.hero h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--flacso-navy);
  -webkit-text-fill-color: var(--flacso-navy);
  background: none;
}

.hero .hero-affiliation {
  font-size: 0.85rem;
  color: var(--flacso-blue);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

.hero p {
  font-size: 1.02rem;
  color: var(--text-secondary);
  max-width: 650px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ===== Sub-Tab Toggles ===== */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
  border: 1px solid var(--border-card);
}

.sub-tab {
  padding: 10px 22px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.sub-tab.active {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22, 57, 112, 0.2);
}

.sub-tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(22, 57, 112, 0.08);
}

.sub-tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.sub-tab-content.active {
  display: block;
}

/* Extended scorecard colors for 8 cards */
.scorecard:nth-child(5)::before {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.scorecard:nth-child(6)::before {
  background: linear-gradient(135deg, #ec4899, #f43f5e);
}

.scorecard:nth-child(7)::before {
  background: linear-gradient(135deg, #14b8a6, #06b6d4);
}

.scorecard:nth-child(8)::before {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.scorecard:nth-child(5) .sc-value {
  color: #6366f1;
  -webkit-text-fill-color: #6366f1;
}

.scorecard:nth-child(6) .sc-value {
  color: var(--accent-5);
  -webkit-text-fill-color: var(--accent-5);
}

.scorecard:nth-child(7) .sc-value {
  color: var(--flacso-sky);
  -webkit-text-fill-color: var(--flacso-sky);
}

.scorecard:nth-child(8) .sc-value {
  color: var(--accent-4);
  -webkit-text-fill-color: var(--accent-4);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-content {
    margin-left: 0;
    padding: 70px 16px 40px;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .scorecards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h2 {
    font-size: 1.6rem;
  }

  .chart-container {
    height: 260px;
  }

  .sub-tabs {
    flex-wrap: wrap;
  }
}