/* ================================================
   Serytec — Sistema de Certificaciones
   Paleta basada en logo: gris #787878 + dorado #DCA028
================================================ */

:root {
  /* ── Colores principales del logo ── */
  --primario:       #DCA028;   /* dorado */
  --primario-dark:  #B8841F;   /* dorado oscuro */
  --primario-light: #FDF3DC;   /* dorado muy claro */
  --secundario:     #4A4A4A;   /* gris oscuro */
  --secundario-med: #787878;   /* gris medio (del logo) */
  --secundario-light:#F0F0F0;  /* gris claro */

  /* ── Colores de sistema ── */
  --gris-bg:     #F5F5F5;
  --gris-borde:  #E0E0E0;
  --gris-texto:  #6B7280;
  --negro:       #1A1D23;
  --blanco:      #FFFFFF;
  --rojo:        #DC2626;
  --rojo-light:  #FEF2F2;
  --amarillo:    #D97706;
  --amarillo-light: #FFFBEB;
  --azul:        #2563EB;
  --azul-light:  #EFF6FF;

  /* ── Aliases para compatibilidad ── */
  --verde:        var(--primario);
  --verde-dark:   var(--primario-dark);
  --verde-light:  var(--primario-light);

  --sombra: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --radio:  10px;
  --font:   'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--gris-bg);
  color: var(--negro);
  line-height: 1.5;
}

a { color: var(--primario); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Tipografía ── */
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

/* ── Botones ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--gris-borde);
  background: var(--blanco);
  color: var(--negro);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--gris-bg); }

.btn-primary {
  background: var(--primario);
  color: var(--blanco);
  border-color: var(--primario-dark);
}
.btn-primary:hover { background: var(--primario-dark); }

.btn-danger {
  background: var(--blanco);
  color: var(--rojo);
  border-color: #FCA5A5;
}
.btn-danger:hover { background: var(--rojo-light); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Inputs ── */
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--blanco);
  color: var(--negro);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primario);
  box-shadow: 0 0 0 3px rgba(220,160,40,.15);
}
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gris-texto);
  margin-bottom: 4px;
}
.form-group { margin-bottom: 14px; }

/* ── Card ── */
.card {
  background: var(--blanco);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 1.25rem;
  box-shadow: var(--sombra);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ok    { background: #D1FAE5; color: #065F46; }
.badge-warn  { background: var(--amarillo-light); color: var(--amarillo); }
.badge-err   { background: var(--rojo-light); color: var(--rojo); }
.badge-info  { background: var(--primario-light); color: var(--primario-dark); }
.badge-admin { background: #F3E8FF; color: #7C3AED; }

/* ── Tabla ── */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--gris-bg);
  color: var(--gris-texto);
  font-weight: 500;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gris-borde);
  white-space: nowrap;
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gris-borde);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gris-bg); }
tr.fila-error td { background: var(--rojo-light); }

/* ── Métricas ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 1.25rem;
}
.metric {
  background: var(--blanco);
  border: 1px solid var(--gris-borde);
  border-radius: var(--radio);
  padding: 1rem;
  box-shadow: var(--sombra);
  border-left: 3px solid var(--primario);
}
.metric-label { font-size: 11px; color: var(--gris-texto); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.metric-val   { font-size: 24px; font-weight: 600; }
.metric-val.verde    { color: var(--primario); }
.metric-val.rojo     { color: var(--rojo); }
.metric-val.amarillo { color: var(--amarillo); }

/* ── Step bar ── */
.step-bar {
  display: flex;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.step {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
  text-align: center;
  background: var(--gris-bg);
  color: var(--gris-texto);
  border-right: 1px solid var(--gris-borde);
}
.step:last-child { border-right: none; }
.step.active { background: var(--primario-light); color: var(--primario-dark); font-weight: 500; }
.step.done   { background: #D1FAE5; color: #065F46; }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--gris-borde);
  border-radius: var(--radio);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primario);
  background: var(--primario-light);
}
.drop-icon  { font-size: 32px; margin-bottom: 8px; }
.drop-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.drop-sub   { font-size: 12px; color: var(--gris-texto); }

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--secundario);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .2s ease;
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--primario);
  line-height: 1.2;
}
.sidebar-logo-text span {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  font-weight: 400;
  display: block;
}

.sidebar-nav { flex: 1; padding: .75rem 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .6rem 1rem;
  font-size: 13px;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: var(--blanco); }
.nav-item.active {
  background: rgba(220,160,40,.15);
  color: var(--primario);
  border-left-color: var(--primario);
  font-weight: 500;
}
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
}
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(220,160,40,.2);
  color: var(--primario);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar.admin { background: rgba(124,58,237,.2); color: #A78BFA; }
.user-name  { font-weight: 500; color: var(--blanco); font-size: 13px; }
.user-role  { font-size: 11px; color: rgba(255,255,255,.45); }
.sidebar-footer .btn {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.65);
  border-color: rgba(255,255,255,.15);
  width: 100%;
  justify-content: center;
}
.sidebar-footer .btn:hover {
  background: rgba(255,255,255,.15);
  color: var(--blanco);
}

.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  transition: margin-left .2s ease;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-sub   { font-size: 13px; color: var(--gris-texto); margin-top: 2px; }

/* ── Alerts ── */
.alert {
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-err  { background: var(--rojo-light);     color: var(--rojo);     border: 1px solid #FCA5A5; }
.alert-ok   { background: var(--primario-light);  color: var(--primario-dark); border: 1px solid #FCD34D; }
.alert-warn { background: var(--amarillo-light); color: var(--amarillo); border: 1px solid #FCD34D; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gris-borde);
  border-top-color: var(--primario);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1rem; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Sidebar toggle ── */
.sidebar-toggle-btn {
  background: rgba(255,255,255,.08);
  border: none;
  color: rgba(255,255,255,.8);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  transition: background .15s;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,.18); color: var(--blanco); }

.nav-item .label { white-space: nowrap; overflow: hidden; }
.sidebar-footer .btn .label { margin-left: 4px; }

/* ── Sidebar colapsado ── */
body.sidebar-colapsado .sidebar { width: 60px; }
body.sidebar-colapsado .main-content { margin-left: 60px; }
body.sidebar-colapsado .sidebar-logo { justify-content: center; padding: 1rem .5rem; }
body.sidebar-colapsado .sidebar-logo img,
body.sidebar-colapsado .sidebar-logo-text,
body.sidebar-colapsado .nav-item .label,
body.sidebar-colapsado .user-text,
body.sidebar-colapsado .sidebar-footer .btn .label {
  display: none;
}
body.sidebar-colapsado .nav-item { justify-content: center; padding: .6rem; }
body.sidebar-colapsado .user-info { justify-content: center; }
body.sidebar-colapsado .sidebar-footer .btn { justify-content: center; padding: 8px; }

/* ── Subtítulos de sección (analytics.html) ── */
.seccion-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gris-texto);
  margin: 1.75rem 0 .5rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--gris-borde);
}
.seccion-titulo:first-of-type { margin-top: 0; }