/* ============================================================
   Asistencia — Sistema de diseño
   Tema dark, acento indigo/violeta. Sin dependencias externas.
   ============================================================ */

:root {
  --bg: #0b0d14;
  --surface: #10131d;
  --card: #151927;
  --card-hover: #1a1f30;
  --border: #232941;
  --border-soft: #1c2233;

  --text: #e9ecf6;
  --text-2: #aab1c9;
  --muted: #6d7592;

  --accent: #818cf8;
  --accent-strong: #6366f1;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #38bdf8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

  --grafico: #7b85f6;              /* barras del dashboard (validado por tema) */
  --topbar-bg: rgba(11, 13, 20, .8);
}

/* ---------- Tema Grafito: oscuro sobrio, azul corporativo ---------- */
html[data-tema="grafito"] {
  --bg: #0e1116;
  --surface: #12161c;
  --card: #161b22;
  --card-hover: #1b212a;
  --border: #2a313c;
  --border-soft: #212832;
  --text: #e8ebf0;
  --text-2: #a9b1bd;
  --muted: #6e7787;
  --accent: #5b9bf8;
  --accent-strong: #2f6fed;
  --grad: linear-gradient(135deg, #1d4ed8, #3b82f6);
  --grafico: #3b82f6;
  --topbar-bg: rgba(14, 17, 22, .8);
}
html[data-tema="grafito"] .nav-item.activo {
  background: rgba(59, 130, 246, .14);
  color: #9ec5fd;
}
html[data-tema="grafito"] .btn-primario { box-shadow: 0 4px 18px rgba(47, 111, 237, .35); }
html[data-tema="grafito"] .input:focus { box-shadow: 0 0 0 3px rgba(47, 111, 237, .25); }
html[data-tema="grafito"] .burbuja.usuario { background: rgba(59, 130, 246, .22); }

/* ---------- Tema Claro corporativo ---------- */
html[data-tema="claro"] {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #eef1f6;
  --border: #d5dbe5;
  --border-soft: #e4e8f0;
  --text: #1b2434;
  --text-2: #46526a;
  --muted: #7c8698;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --grad: linear-gradient(135deg, #1d4ed8, #2563eb);
  --grafico: #4f46e5;
  --topbar-bg: rgba(243, 245, 249, .85);
  --shadow: 0 8px 30px rgba(15, 23, 42, .08);
}
html[data-tema="claro"] input[type="date"].input,
html[data-tema="claro"] input[type="time"].input { color-scheme: light; }
html[data-tema="claro"] .nav-item.activo { background: rgba(37, 99, 235, .1); color: #1d4ed8; }
html[data-tema="claro"] .btn-primario { box-shadow: 0 4px 14px rgba(37, 99, 235, .28); }
html[data-tema="claro"] .input:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
html[data-tema="claro"] .badge.indigo { background: rgba(79, 70, 229, .1); color: #4338ca; }
html[data-tema="claro"] .badge.verde { background: rgba(5, 150, 105, .1); color: #047857; }
html[data-tema="claro"] .badge.ambar { background: rgba(217, 119, 6, .12); color: #b45309; }
html[data-tema="claro"] .badge.rojo { background: rgba(220, 38, 38, .1); color: #b91c1c; }
html[data-tema="claro"] .stat-icono.indigo { background: rgba(79, 70, 229, .1); color: #4f46e5; }
html[data-tema="claro"] .stat-icono.verde { background: rgba(5, 150, 105, .1); color: #059669; }
html[data-tema="claro"] .stat-icono.ambar { background: rgba(217, 119, 6, .12); color: #d97706; }
html[data-tema="claro"] .stat-icono.celeste { background: rgba(2, 132, 199, .1); color: #0284c7; }
html[data-tema="claro"] .burbuja.usuario { background: rgba(37, 99, 235, .12); }
html[data-tema="claro"] .alerta.error { color: #b91c1c; }
html[data-tema="claro"] .alerta.ok { color: #047857; }

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Layout general (app) ---------- */

.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--grad);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-name span { color: var(--accent); }

.nav-group-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: .92rem;
  font-weight: 500;
  transition: background .12s, color .12s;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }

.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }

.nav-item.activo {
  background: linear-gradient(135deg, rgba(99, 102, 241, .18), rgba(168, 85, 247, .12));
  color: #c7cbfb;
}

.nav-item.deshabilitado { opacity: .45; cursor: default; pointer-events: none; }

.chip-pronto {
  margin-left: auto;
  font-size: .62rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid var(--border-soft);
  font-size: .75rem;
  color: var(--muted);
}

/* ---------- Contenido ---------- */

.contenido { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.badge-empresa {
  font-size: .78rem;
  color: var(--text-2);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
}

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.btn-salir {
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.btn-salir:hover { color: var(--danger); background: var(--card); text-decoration: none; }
.btn-salir svg { width: 18px; height: 18px; }

main { padding: 28px 32px; max-width: 1280px; width: 100%; }

/* ---------- Tarjetas y stats ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
}

.card h2 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -.01em;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color .15s, transform .15s;
}

.stat:hover { border-color: var(--border); transform: translateY(-1px); }

.stat-icono {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-icono svg { width: 20px; height: 20px; }

.stat-icono.indigo  { background: rgba(99, 102, 241, .15); color: #a5b4fc; }
.stat-icono.verde   { background: rgba(52, 211, 153, .12); color: var(--success); }
.stat-icono.ambar   { background: rgba(251, 191, 36, .12); color: var(--warning); }
.stat-icono.celeste { background: rgba(56, 189, 248, .12); color: var(--info); }

.stat-valor { font-size: 1.55rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: start;
}

/* ---------- Tablas ---------- */

.tabla-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-2);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--card-hover); }

/* ---------- Badges de estado ---------- */

.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge.verde  { background: rgba(52, 211, 153, .12); color: var(--success); }
.badge.ambar  { background: rgba(251, 191, 36, .12); color: var(--warning); }
.badge.rojo   { background: rgba(248, 113, 113, .12); color: var(--danger); }
.badge.gris   { background: var(--card-hover); color: var(--text-2); }
.badge.indigo { background: rgba(99, 102, 241, .15); color: #a5b4fc; }

/* ---------- Botones y formularios ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }

.btn-primario {
  background: var(--grad);
  border: none;
  color: #fff;
  box-shadow: 0 4px 18px rgba(99, 102, 241, .35);
}

.btn-bloque { width: 100%; }

label.campo { display: block; margin-bottom: 14px; }

label.campo span {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  font-family: var(--font);
  font-size: .92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .22);
}
.input::placeholder { color: var(--muted); }

.alerta {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .86rem;
  margin-bottom: 16px;
}
.alerta.error {
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .3);
  color: #fca5a5;
}

/* ---------- Formularios y toolbars de listas ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar .input { max-width: 280px; }
.toolbar .espacio { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 16px;
}
.form-grid .campo-ancho { grid-column: 1 / -1; }

select.input { appearance: none; cursor: pointer; }
textarea.input { resize: vertical; min-height: 70px; font-family: var(--font); }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }

.dias-semana { display: flex; gap: 8px; flex-wrap: wrap; }
.dias-semana label {
  display: flex; align-items: center; gap: 5px;
  font-size: .82rem; color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
}
.dias-semana input { accent-color: var(--accent-strong); }

.btn-sm { font-size: .78rem; padding: 5px 11px; }
.btn-peligro { color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.btn-fantasma { background: transparent; border: none; color: var(--muted); padding: 4px 8px; }
.btn-fantasma:hover { color: var(--text); }

td form { display: inline; }
.celda-acciones { text-align: right; white-space: nowrap; }

.alerta.ok {
  background: rgba(52, 211, 153, .1);
  border: 1px solid rgba(52, 211, 153, .3);
  color: #6ee7b7;
}

.foto-mini {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  background: var(--card-hover);
}

.encabezado-seccion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.encabezado-seccion p { color: var(--muted); font-size: .86rem; margin-top: 3px; }

.grid-form-lista {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1080px) { .grid-form-lista { grid-template-columns: 1fr; } }

/* ---------- Estados vacios ---------- */

.vacio {
  text-align: center;
  padding: 34px 20px;
  color: var(--muted);
  font-size: .88rem;
}
.vacio svg { width: 36px; height: 36px; opacity: .4; margin-bottom: 10px; }

/* ---------- Lista de pasos (onboarding) ---------- */

.pasos { list-style: none; display: flex; flex-direction: column; gap: 12px; }

.pasos li { display: flex; gap: 12px; align-items: flex-start; font-size: .87rem; color: var(--text-2); }

.paso-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(99, 102, 241, .15);
  color: #a5b4fc;
  font-size: .72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.pasos strong { color: var(--text); font-weight: 600; display: block; margin-bottom: 1px; }

/* ---------- Login ---------- */

.login-pagina {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100vh;
}

.login-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(99, 102, 241, .28), transparent),
    radial-gradient(ellipse 50% 45% at 85% 75%, rgba(168, 85, 247, .22), transparent),
    var(--surface);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-hero h2 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.15;
  max-width: 420px;
}

.login-hero h2 em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-hero p.sub {
  margin-top: 14px;
  color: var(--text-2);
  font-size: 1rem;
  max-width: 400px;
  line-height: 1.55;
}

.hero-features { list-style: none; display: flex; flex-direction: column; gap: 14px; margin-top: 36px; }

.hero-features li { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: .92rem; }

.hero-feature-icono {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(99, 102, 241, .14);
  color: #a5b4fc;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.hero-feature-icono svg { width: 16px; height: 16px; }

.login-hero .pie { font-size: .78rem; color: var(--muted); }

.login-formulario {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.login-card { width: 100%; max-width: 380px; }

.login-card .brand { padding: 0 0 26px; }

.login-card h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }

.login-card p.ayuda { color: var(--muted); font-size: .88rem; margin-bottom: 24px; }

/* ---------- Panel lateral del Asistente IA ---------- */

.app { grid-template-columns: 250px 1fr auto; }

.panel-ia {
  width: 330px;
  background: var(--surface);
  border-left: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

html[data-ia="0"] .panel-ia { display: none; }

.panel-ia-cabecera {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-ia-cabecera .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.panel-ia-cabecera strong { font-size: .92rem; flex: 1; }

.panel-ia-chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.burbuja {
  max-width: 92%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: .84rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.burbuja.ia { background: var(--card); border: 1px solid var(--border-soft);
              align-self: flex-start; border-bottom-left-radius: 4px; }
.burbuja.usuario { background: linear-gradient(135deg, rgba(99,102,241,.35), rgba(168,85,247,.25));
                   align-self: flex-end; border-bottom-right-radius: 4px; }
.burbuja.pensando { color: var(--muted); font-style: italic; }

.sugerencias { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.sugerencias .btn { justify-content: flex-start; text-align: left; font-weight: 500; }

.panel-ia-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
}
.panel-ia-form .input { flex: 1; font-size: .84rem; }

@media (max-width: 1180px) {
  .app { grid-template-columns: 250px 1fr; }
  .panel-ia {
    position: fixed;
    right: 0; top: 0;
    width: min(360px, 100vw);
    z-index: 60;
    box-shadow: var(--shadow);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .login-pagina { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav-group-label { display: none; }
  .sidebar-footer { display: none; }
  main, .topbar { padding-left: 18px; padding-right: 18px; }
}
