/* ═══════════════════════════════════════════════════════════════
   CURSO IA PROFUTURO — PANAMÁ
   Design system: clean government dashboard, mobile-first
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --primary: #1d4ed8;
  --primary-lt: #3b82f6;
  --primary-bg: #eff6ff;
  --secondary: #1e293b;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --dark: #0f172a;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --sh-sm: 0 1px 4px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --sh-md: 0 4px 12px rgba(0, 0, 0, .08), 0 2px 4px rgba(0, 0, 0, .04);
  --sh-lg: 0 8px 28px rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .06);
}

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

body {
  background: var(--bg);
  font-family: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  color: var(--secondary);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════════════════════
   HERO
   ══════════════════════════════════════════════════════════════ */
.hero {
  background: linear-gradient(140deg, #1e40af 0%, #1e3a8a 55%, #0f172a 100%);
  color: #fff;
  padding: 40px 0 70px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(99, 179, 237, .12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 10% 80%, rgba(59, 130, 246, .08) 0%, transparent 50%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(to bottom, transparent, var(--bg));
}

.hero h1 {
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: .4rem;
}

.hero-subtitle {
  font-size: clamp(.88rem, 2.5vw, 1.05rem);
  font-weight: 400;
  opacity: .88;
  margin-bottom: .6rem;
  line-height: 1.4;
}

.hero .lead {
  font-size: .95rem;
  opacity: .8;
  margin-bottom: .6rem;
}

.hero-badge .badge {
  font-size: .75rem;
  padding: .4rem .9rem;
  border-radius: var(--r-sm);
  letter-spacing: .3px;
}

.hero-image {
  max-width: 260px;
  width: 100%;
  border-radius: var(--r-xl);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
  transition: transform .4s ease;
  position: relative;
  z-index: 1;
}

.hero-image:hover {
  transform: translateY(-6px) scale(1.01);
}

/* ══════════════════════════════════════════════════════════════
   MAIN CONTAINER
   ══════════════════════════════════════════════════════════════ */
.section-main {
  padding: 0 12px 60px;
}

@media (min-width: 576px) {
  .section-main {
    padding: 0 16px 60px;
  }
}

@media (min-width: 992px) {
  .section-main {
    padding: 0 0 60px;
  }
}

/* ══════════════════════════════════════════════════════════════
   INFORME GENERAL
   ══════════════════════════════════════════════════════════════ */
.informe-wrapper {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 20px 16px 24px;
  box-shadow: var(--sh-lg);
  margin-top: -38px;
  position: relative;
  z-index: 10;
  margin-bottom: 20px;
}

@media (min-width: 576px) {
  .informe-wrapper {
    padding: 24px 24px 28px;
  }
}

@media (min-width: 768px) {
  .informe-wrapper {
    padding: 26px 30px 32px;
  }
}

.informe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
}

.informe-header h5 {
  font-weight: 700;
  font-size: 1rem;
  color: var(--secondary);
  margin: 0;
}

@media (min-width: 576px) {
  .informe-header h5 {
    font-size: 1.1rem;
  }
}

.btn-refresh {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 11px;
  font-size: .95rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: border-color .2s, color .2s, transform .3s;
  flex-shrink: 0;
}

.btn-refresh:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: rotate(180deg);
}

/* KPIs del informe */
.kpi-informe {
  border-radius: var(--r-lg);
  padding: 14px 12px 12px;
  text-align: center;
  transition: transform .3s, box-shadow .3s;
  height: 100%;
}

.kpi-informe:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
}

.kpi-total {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1.5px solid #93c5fd;
}

.kpi-aprobado {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1.5px solid #86efac;
}

.kpi-iniciado {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1.5px solid #fcd34d;
}

.kpi-no-iniciado {
  background: linear-gradient(135deg, #fff5f5, #fee2e2);
  border: 1.5px solid #fca5a5;
}

.kpi-inf-icon {
  font-size: 1.4rem;
  line-height: 1;
  margin-bottom: 5px;
}

.kpi-inf-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--secondary);
  line-height: 1;
}

.kpi-inf-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-top: 4px;
}

.kpi-inf-pct {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 3px;
}

@media (min-width: 576px) {
  .kpi-inf-val {
    font-size: 2.2rem;
  }

  .kpi-inf-label {
    font-size: .72rem;
  }

  .kpi-informe {
    padding: 18px 16px 14px;
  }
}

/* Tarjetas internas del informe */
.informe-card {
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 16px;
  border: 1px solid var(--border);
  height: 100%;
}

@media (min-width: 576px) {
  .informe-card {
    padding: 18px 20px;
  }
}

.informe-card-title {
  font-weight: 700;
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 14px;
}

/* Barra progreso apilada */
.prog-grande-bar {
  display: flex;
  height: 24px;
  border-radius: 30px;
  overflow: hidden;
  background: #e2e8f0;
  margin-bottom: 10px;
}

.prog-grande-fill {
  height: 100%;
  transition: width .9s ease;
  min-width: 0;
}

.aprobado-fill {
  background: var(--success);
}

.iniciado-fill {
  background: #f59e0b;
}

.no-ini-fill {
  background: #cbd5e1;
}

.prog-leyenda {
  display: flex;
  gap: 10px 16px;
  flex-wrap: wrap;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.dot-aprobado {
  background: var(--success);
}

.dot-iniciado {
  background: #f59e0b;
}

.dot-no-ini {
  background: #cbd5e1;
  border: 1px solid #94a3b8;
}

.promedio-label {
  font-size: .83rem;
  color: var(--muted);
}

.promedio-label strong {
  color: var(--secondary);
  font-size: .95rem;
}

/* Donut HAD */
.had-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.had-donut-wrap {
  width: 90px;
  margin: 4px auto 12px;
}

@media (min-width: 768px) {
  .had-donut-wrap {
    width: 110px;
  }
}

.had-donut {
  display: block;
  width: 100%;
}

.donut-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 3.8;
}

.donut-fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 3.8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dasharray .9s ease;
}

.donut-text {
  font-family: 'DM Sans', sans-serif;
  font-size: 7px;
  font-weight: 800;
  fill: var(--secondary);
  text-anchor: middle;
}

.had-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.had-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .83rem;
  color: var(--muted);
}

.had-stat-row strong {
  margin-left: auto;
  color: var(--secondary);
  font-weight: 700;
}

.had-stat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.had-stat-dot.si {
  background: var(--success);
}

.had-stat-dot.no {
  background: #e2e8f0;
  border: 1px solid #94a3b8;
}

/* ── Actividades del informe ────────────────────────────────── */
.acts-informe {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.act-informe-row {
  display: grid;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  /* mobile: label / barra+pct */
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
}

.act-informe-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--secondary);
  font-weight: 500;
  line-height: 1.3;
  grid-column: 1;
  grid-row: 1;
}

.act-informe-num {
  font-family: 'DM Mono', monospace;
  font-size: .68rem;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 18px;
}

.act-informe-pct {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-size: .8rem;
  grid-column: 2;
  grid-row: 1 / 3;
  text-align: right;
  align-self: center;
}

.act-informe-pct small {
  color: var(--muted);
  font-weight: 400;
  font-size: .68rem;
  display: block;
}

.act-informe-bar-wrap {
  background: #e2e8f0;
  border-radius: 30px;
  height: 7px;
  overflow: hidden;
  grid-column: 1;
  grid-row: 2;
}

.act-informe-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-lt));
  border-radius: 30px;
  min-width: 2px;
  transition: width .7s ease;
}

/* tablet+ → layout en una sola fila */
@media (min-width: 640px) {
  .act-informe-row {
    grid-template-columns: 2fr 3fr 56px;
    grid-template-rows: auto;
  }

  .act-informe-label {
    grid-column: 1;
    grid-row: 1;
  }

  .act-informe-bar-wrap {
    grid-column: 2;
    grid-row: 1;
  }

  .act-informe-pct {
    grid-column: 3;
    grid-row: 1;
  }
}

/* ── Provincias ─────────────────────────────────────────────── */
.provs-informe {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prov-row {
  display: grid;
  gap: 6px 10px;
  align-items: center;
  font-size: .8rem;
  /* mobile: nombre arriba, badges abajo */
  grid-template-columns: 1fr;
}

.prov-nombre {
  font-weight: 600;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prov-stats {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.prov-badge {
  font-size: .68rem;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}

.prov-badge.total {
  background: #dbeafe;
  color: #1d4ed8;
}

.prov-badge.aprobado {
  background: #dcfce7;
  color: #166534;
}

.prov-badge.iniciado {
  background: #fef3c7;
  color: #92400e;
}

.prov-badge.no-iniciado {
  background: #fee2e2;
  color: #991b1b;
}

.prov-bar-wrap {
  display: none;
}

/* oculto en mobile */

/* tablet+ → una sola fila con barra */
@media (min-width: 640px) {
  .prov-row {
    grid-template-columns: 130px 1fr;
  }

  .prov-bar-wrap {
    display: none;
  }

  /* solo en desktop */
}

@media (min-width: 900px) {
  .prov-row {
    grid-template-columns: 150px auto 1fr;
  }

  .prov-bar-wrap {
    display: block;
    background: #e2e8f0;
    border-radius: 30px;
    height: 8px;
    overflow: hidden;
  }

  .prov-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #4ade80);
    border-radius: 30px;
    min-width: 2px;
    transition: width .7s ease;
  }
}

/* ══════════════════════════════════════════════════════════════
   SEARCH CARD
   ══════════════════════════════════════════════════════════════ */
.search-card {
  background: var(--card);
  padding: 20px 16px;
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
  margin-bottom: 20px;
}

@media (min-width: 576px) {
  .search-card {
    padding: 26px 28px;
  }
}

.search-card h4 {
  color: var(--secondary);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 14px !important;
}

@media (min-width: 576px) {
  .search-card h4 {
    font-size: 1.05rem;
  }
}

/* Input group — apilado en mobile, en fila en tablet+ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--r-md);
}

.input-group-text {
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  padding: 11px 16px;
  border-radius: var(--r-md) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.form-control {
  border: 1.5px solid var(--border);
  padding: 11px 16px;
  font-size: .95rem;
  font-family: inherit;
  border-radius: var(--r-md) !important;
  width: 100%;
  background: #f8fafc;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
  border-color: var(--primary);
  background: #fff;
  outline: none;
}

.form-control::placeholder {
  color: #94a3b8;
  font-size: .88rem;
}

.input-group .btn {
  width: 100%;
  border-radius: var(--r-md) !important;
  padding: 11px 20px;
  font-weight: 600;
  font-family: inherit;
  font-size: .95rem;
  transition: background .2s, transform .2s, box-shadow .2s;
}

.btn-primary {
  background: var(--primary);
  border: none;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(29, 78, 216, .3);
}

.btn-primary:disabled {
  opacity: .65;
  transform: none;
}

.btn-secondary {
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: #94a3b8;
}

/* tablet+ → input group en fila horizontal */
@media (min-width: 576px) {
  .input-group {
    flex-direction: row;
    gap: 0;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
  }

  .input-group-text {
    width: auto;
    border-radius: var(--r-md) 0 0 var(--r-md) !important;
    padding: 12px 18px;
  }

  .form-control {
    flex: 1;
    border-radius: 0 !important;
    border-left: none;
    border-right: none;
    background: #fff;
  }

  .input-group .btn {
    width: auto;
    border-radius: 0 !important;
    padding: 12px 22px;
  }

  .input-group .btn:last-child {
    border-radius: 0 var(--r-md) var(--r-md) 0 !important;
  }
}

.search-hint {
  opacity: .65;
  font-size: .8rem;
}

/* ══════════════════════════════════════════════════════════════
   KPI CARDS (resultado individual)
   ══════════════════════════════════════════════════════════════ */
.kpi {
  text-align: center;
  padding: 16px 10px;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  transition: transform .3s, box-shadow .3s;
  height: 100%;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.kpi:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-lg);
}

.kpi h6 {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0;
}

.kpi-value {
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
}

.kpi-name {
  font-size: 1rem;
  line-height: 1.3;
}

.kpi-total {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
}

@media (min-width: 576px) {
  .kpi {
    padding: 20px 14px;
    min-height: 120px;
  }

  .kpi-value {
    font-size: 1.75rem;
  }

  .kpi-name {
    font-size: 1.05rem;
  }
}

.estado-no-iniciado {
  color: var(--danger) !important;
}

.estado-iniciado {
  color: var(--warning) !important;
}

.estado-aprobado {
  color: var(--success) !important;
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD CARDS (resultado individual)
   ══════════════════════════════════════════════════════════════ */
.dashboard-card {
  background: var(--card);
  border-radius: var(--r-xl);
  padding: 18px 16px;
  box-shadow: var(--sh-md);
  margin-bottom: 18px;
  transition: transform .3s, box-shadow .3s;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-lg);
}

.dashboard-card h5 {
  color: var(--secondary);
  font-weight: 700;
  font-size: .95rem;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

@media (min-width: 576px) {
  .dashboard-card {
    padding: 22px 24px;
  }

  .dashboard-card h5 {
    font-size: 1.05rem;
  }
}

.dashboard-card p {
  margin-bottom: .4rem;
  color: #475569;
  font-size: .9rem;
}

.dashboard-card p span {
  color: var(--secondary);
  font-weight: 500;
}

.dashboard-card b {
  color: var(--muted);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ── Progress bar ─────────────────────────────────────────── */
.progress {
  height: 22px;
  border-radius: 30px;
  background: #e2e8f0;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .06);
}

.progress-bar {
  font-weight: 700;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width .7s ease;
  border-radius: 30px;
}

/* ── Actividad cards ──────────────────────────────────────── */
.actividad-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--primary);
  background: var(--card);
  box-shadow: var(--sh-sm);
  height: 100%;
  transition: transform .2s, box-shadow .2s;
}

.actividad-card:hover {
  transform: translateX(3px);
  box-shadow: var(--sh-md);
}

.actividad-card.finalizado {
  border-left-color: var(--success);
  background: linear-gradient(135deg, #f0fdf4, #fff);
}

.actividad-card.no-finalizado {
  border-left-color: var(--danger);
  background: linear-gradient(135deg, #fff5f5, #fff);
}

.act-num {
  font-family: 'DM Mono', monospace;
  font-size: .65rem;
  color: var(--muted);
  min-width: 18px;
  padding-top: 2px;
  flex-shrink: 0;
}

.act-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.actividad-titulo {
  color: var(--secondary);
  font-weight: 600;
  font-size: .83rem;
  line-height: 1.35;
  margin: 0;
}

.act-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.act-ok {
  background: #dcfce7;
  color: #166534;
}

.act-pending {
  background: #fee2e2;
  color: #991b1b;
}

/* ── HAD ──────────────────────────────────────────────────── */
.had-ok,
.had-pending {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-md);
}

@media (min-width: 576px) {

  .had-ok,
  .had-pending {
    padding: 18px 20px;
    gap: 16px;
  }
}

.had-ok {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border: 1.5px solid #86efac;
  color: #166534;
}

.had-pending {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1.5px solid #fcd34d;
  color: #92400e;
}

.had-icon-wrap {
  font-size: 1.8rem;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-md);
  padding: 14px 18px;
  font-weight: 500;
  border: none;
  box-shadow: var(--sh-sm);
  font-size: .9rem;
}

.alert-danger {
  background: #fef2f2;
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-left: 4px solid var(--warning);
}

/* ══════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════ */
footer {
  background: var(--dark);
  color: rgba(255, 255, 255, .8);
  padding: 28px 16px;
  text-align: center;
  margin-top: 20px;
}

footer p {
  margin: .25rem 0;
  font-size: .88rem;
}

.footer-year {
  opacity: .4;
  font-size: .75rem !important;
}

footer a {
  color: #93c5fd;
  text-decoration: none;
  transition: color .2s;
}

footer a:hover {
  color: #bfdbfe;
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════════════════
   PRINT
   ══════════════════════════════════════════════════════════════ */
@media print {

  .hero,
  .search-card,
  .informe-wrapper,
  footer,
  .btn {
    display: none !important;
  }

  .dashboard-card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

  body {
    background: #fff;
  }
}

/* ══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}