@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #1e3a8a;
  --primary-mid: #2563eb;
  --primary-light: #dbeafe;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --green: #16a34a;
  --gray: #64748b;

  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --score-excellent: #059669;
  --score-good: #65a30d;
  --score-fair: #d97706;
  --score-low: #ea580c;
  --score-poor: #dc2626;

  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ─── NAVBAR ─────────────────────────────────────────── */
.navbar {
  background: var(--primary);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
}

.logo-badge {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: white;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 16px; font-weight: 700; color: white; }
.brand-sub { font-size: 10px; color: #93c5fd; text-transform: uppercase; letter-spacing: 0.08em; }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #bfdbfe;
  font-size: 12px;
}

.navbar-right .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80;
}

/* ─── HERO ────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 60%, #1d4ed8 100%);
  padding: 28px 24px 24px;
  color: white;
}

.hero-inner {
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.2;
}

.search-bar {
  display: flex;
  gap: 0;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
  max-width: 640px;
}

.search-bar input {
  flex: 1;
  border: none;
  padding: 14px 20px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  background: transparent;
}

.search-bar input::placeholder { color: var(--text-light); }

.search-bar button {
  background: var(--primary-mid);
  color: white;
  border: none;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
}

.search-bar button:hover { background: #1d4ed8; }

/* ── Toggle IA pill ─────────────────────────────────────────────────── */
.search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 800px;
}

.search-row .search-bar {
  flex: 1;
  max-width: none;
}

.ai-pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.4);
  border-radius: 40px;
  padding: 6px 14px 6px 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.75);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}
.ai-pill-toggle:hover {
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.6);
  color: white;
}

/* Track */
.ai-pill-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255,255,255,.25);
  position: relative;
  flex-shrink: 0;
  transition: background .2s;
}
/* Thumb */
.ai-pill-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: white;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), background .2s;
}

/* ── Estado ACTIVO ───────────────────────────────────────────────────── */
.ai-pill-toggle.ai-active {
  background: rgba(255,255,255,.95);
  border-color: white;
  color: #6d28d9;
  box-shadow: 0 2px 16px rgba(124,58,237,.45);
}
.ai-pill-toggle.ai-active:hover {
  background: white;
  box-shadow: 0 4px 20px rgba(124,58,237,.55);
}
.ai-pill-toggle.ai-active .ai-pill-track { background: #7c3aed; }
.ai-pill-toggle.ai-active .ai-pill-thumb {
  transform: translateX(16px);
  background: white;
  color: #7c3aed;
}

/* Banner de resultados IA */
.ai-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #4c1d95;
  line-height: 1.4;
}
.ai-banner-icon {
  font-size: 18px;
  color: #7c3aed;
  flex-shrink: 0;
}
.ai-banner span { flex: 1; }
.ai-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #7c3aed;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.ai-banner-close:hover { background: #ede9fe; }

/* Estado de carga IA */
.ai-loading {
  flex-direction: column;
  gap: 10px;
  color: #7c3aed;
  font-size: 14px;
}

.hero-stats {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #bfdbfe;
}

.hero-stat strong { color: white; font-size: 18px; font-weight: 700; }

/* ─── MAIN LAYOUT ─────────────────────────────────────── */
.main-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px;
  gap: 20px;
  align-items: flex-start;
}

/* ─── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn-clear {
  font-size: 11px;
  color: var(--primary-mid);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  font-weight: 500;
}

.btn-clear:hover { text-decoration: underline; }

.filter-group {
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.filter-group:last-child { border-bottom: none; }

.filter-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.filter-group-label .toggle-icon { transition: transform .2s; }
.filter-group-label.collapsed .toggle-icon { transform: rotate(-90deg); }

.filter-options { display: flex; flex-direction: column; gap: 6px; }
.filter-options.hidden { display: none; }

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  padding: 3px 0;
  user-select: none;
}

.filter-option input[type="checkbox"] {
  width: 15px; height: 15px;
  border-radius: 3px;
  accent-color: var(--primary-mid);
  cursor: pointer;
  flex-shrink: 0;
}

.filter-option:hover { color: var(--primary-mid); }

.score-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.score-filter-row strong { color: var(--text); font-size: 15px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--primary-mid);
}

/* ─── RESULTS AREA ────────────────────────────────────── */
.results-area { flex: 1; min-width: 0; }

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.results-count {
  font-size: 14px;
  color: var(--text-muted);
}

.results-count strong { color: var(--text); }

.sort-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  outline: none;
}

.sort-select:focus { border-color: var(--primary-mid); }

/* ─── CARDS GRID ──────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.centro-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
}

.centro-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-top {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

/* ─── SCORE RING ──────────────────────────────────────── */
.score-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) var(--pct), #e2e8f0 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.score-inner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--ring-color);
}

.card-title-block { flex: 1; min-width: 0; }

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.centro-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
  text-decoration: none;
}
.centro-name:hover { color: var(--accent); text-decoration: underline; }

.centro-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.meta-sep { color: var(--border); margin: 0 2px; }

.tipo-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
}

/* ─── VERIFICATION BADGES ─────────────────────────────── */
.nivel-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.nivel-cert {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
}

.nivel-insitu {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.nivel-documental {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #93c5fd;
}

.nivel-pendiente {
  background: var(--amber-light);
  color: var(--amber);
  border: 1px solid #fcd34d;
}

.nivel-no-verificado {
  background: #f1f5f9;
  color: var(--gray);
  border: 1px solid var(--border);
}

/* ─── CARD BODY ───────────────────────────────────────── */
.card-body-inner {
  padding: 14px 18px;
  flex: 1;
}

.areas-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.tag-area {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border);
}

.tag-more {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-mid);
}

.specs-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tag-spec {
  font-size: 10px;
  font-weight: 600;
  color: #92400e;
  background: #fefce8;
  border: 1px solid #fcd34d;
  padding: 2px 7px;
  border-radius: 4px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.metric-item svg, .metric-item i {
  font-size: 13px;
  flex-shrink: 0;
  color: var(--primary-mid);
}

.metric-item.cap-alta { color: var(--green); }
.metric-item.cap-alta i { color: var(--green); }
.metric-item.cap-baja { color: var(--red); }
.metric-item.cap-baja i { color: var(--red); }

.disp-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.disp-alta { background: var(--green); }
.disp-media { background: var(--amber); }
.disp-baja { background: var(--score-low); }
.disp-saturada { background: var(--red); }

/* ─── CARD FOOTER ─────────────────────────────────────── */
.card-footer-inner {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fafafa;
}

.phases-row { display: flex; flex-wrap: wrap; gap: 4px; }

.fase-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eff6ff;
  color: var(--primary-mid);
  border: 1px solid #bfdbfe;
}

.btn-ver {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
}

.btn-ver:hover { background: #1e40af; color: white; }

/* ─── EMPTY STATE ─────────────────────────────────────── */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-results h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }

/* ─── LOADING ─────────────────────────────────────────── */
.loading-spinner {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── DETAIL PAGE ─────────────────────────────────────── */
.detail-layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  transition: color .15s;
}

.back-link:hover { color: var(--primary-mid); }

.detail-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.detail-header-top {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.detail-score-ring {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) var(--pct), #e2e8f0 0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-score-inner {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: var(--ring-color);
  line-height: 1;
}

.detail-score-inner small {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 1px;
}

.detail-title-block { flex: 1; }

.detail-title-block h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.2;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-badges { display: flex; flex-wrap: wrap; gap: 8px; }

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.kpi-item { text-align: center; }

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  display: block;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── DETAIL SECTIONS ─────────────────────────────────── */
.detail-sections { display: flex; flex-direction: column; gap: 16px; }

.detail-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.field-item {}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.field-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.field-value.large {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.tags-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.tag-infra {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.tag-exp {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
}

.ip-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ip-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-mid));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.ip-info {}
.ip-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.ip-meta { font-size: 12px; color: var(--text-muted); }

/* ─── PROGRESS BAR ────────────────────────────────────── */
.progress-bar-wrap {
  margin-top: 6px;
}

.progress-bar-track {
  background: var(--border);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary-mid);
  transition: width .6s ease;
}

.progress-bar-fill.good { background: var(--green); }
.progress-bar-fill.fair { background: var(--amber); }
.progress-bar-fill.low { background: var(--red); }

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 900px) {
  .main-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: static;
    max-height: none;
  }
  .cards-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .hero h1 { font-size: 20px; }
  .hero-stats { display: none; }
  .cards-grid { grid-template-columns: 1fr; }
  .detail-header-top { flex-direction: column; align-items: center; text-align: center; }
  .detail-meta { justify-content: center; }
  .detail-badges { justify-content: center; }
}

/* ─── MOBILE FILTER TOGGLE ───────────────────────────── */
.filter-toggle-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

@media (max-width: 900px) {
  .filter-toggle-btn { display: flex; }
  .sidebar.mobile-hidden { display: none; }
}
