/* ═══════════════════════════════════════════════════════════════════════
   INCLUIA — Sistema de diseño global
   Principio: blanco dominante, minimalismo extremo, una acción por pantalla

   Unificado 2026-08-08 con el sistema real del sitio público (ver
   home.php / docs/Incluia-Manual-de-Imagen.html): el admin tenía su propia
   paleta divergente (acento morado, tipografía Inter vía Google Fonts) —
   pasa a los mismos tokens de marca (azul/verde, tipografía de sistema).
   Se mantienen los NOMBRES de variable existentes (--c-purple, etc.) para
   no tener que tocar cada vista que los referencia — solo cambian los
   valores. Nunca cargar fuentes externas: ver regla en el manual de marca.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
  --c-black:        #101828;
  --c-white:        #FFFFFF;
  --c-gray:         #667085;
  --c-purple:       #2867F0;  /* alias histórico — es el azul de marca, no morado */
  --c-green:        #167B59;
  --c-purple-light: #EEF4FF;
  --c-green-light:  #EDF8F2;
  --c-gray-light:   #F7F9FC;
  --c-border:       rgba(16,24,40,0.09);
  --c-red:          #EF4444;
  --c-red-light:    #FEF2F2;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);

  --font: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;

  --transition: 150ms ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--c-black);
  background: var(--c-white);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ── Tipografía ─────────────────────────────────────────────────────── */
h1 {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--c-black);
}
h2 {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
h3 {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
}
.text-sm   { font-size: 13px; }
.text-gray { color: var(--c-gray); }
.text-green { color: var(--c-green); }
.text-purple { color: var(--c-purple); }

/* ── Layout ─────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}
.container--narrow { max-width: 640px; }
.container--wide   { max-width: 1280px; }

/* ── Botones ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:hover   { opacity: 0.88; }
.btn:active  { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn--primary {
  background: var(--c-purple); /* alias histórico — es el azul de marca */
  color: var(--c-white);
}
.btn--ai {
  background: var(--c-purple);
  color: var(--c-white);
}
.btn--ghost {
  background: transparent;
  color: var(--c-black);
  border: 0.5px solid var(--c-border);
}
.btn--ghost:hover { background: var(--c-gray-light); opacity: 1; }
.btn--danger {
  background: var(--c-red);
  color: var(--c-white);
}
.btn--sm { padding: 7px 14px; font-size: 13px; }
.btn--lg { padding: 13px 28px; font-size: 15px; }

/* Spinner dentro de botón */
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn-text { opacity: 0.5; }

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

/* ── Formularios ─────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-black);
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-white);
  color: var(--c-black);
  font-size: 15px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--c-purple);
  box-shadow: 0 0 0 3px rgba(40,103,240,0.12);
}
.form-input.is-error {
  border-color: var(--c-red);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.form-hint {
  font-size: 12px;
  color: var(--c-gray);
}
.form-error {
  font-size: 12px;
  color: var(--c-red);
  display: none;
}
.form-error.visible { display: block; }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--c-white);
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card--hover {
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card--hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}
.badge--green  { background: var(--c-green-light);  color: var(--c-green); }
.badge--purple { background: var(--c-purple-light); color: #1557E8; }
.badge--gray   { background: var(--c-gray-light);   color: var(--c-gray); }
.badge--red    { background: var(--c-red-light);    color: #DC2626; }

/* ── Avatar con iniciales ─────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 500;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--md { width: 40px; height: 40px; font-size: 15px; }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }
.avatar--green  { background: var(--c-green-light);  color: var(--c-green); }
.avatar--purple { background: var(--c-purple-light); color: #1557E8; }
.avatar--gray   { background: var(--c-gray-light);   color: #52525B; }

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--c-border);
  height: 60px;
  display: flex;
  align-items: center;
}
.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.navbar__logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--c-purple);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.navbar__logo img {
  height: 28px;
  width: auto;
}
.navbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Sidebar app ─────────────────────────────────────────────────────── */
.layout-app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--c-white);
  border-right: 0.5px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__logo {
  padding: 0 20px 24px;
  font-size: 17px;
  font-weight: 600;
  color: var(--c-purple);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 0.5px solid var(--c-border);
  margin-bottom: 16px;
}
.sidebar__tenant {
  padding: 0 20px 16px;
  font-size: 12px;
  color: var(--c-gray);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sidebar__nav { flex: 1; padding: 0 12px; }
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--c-gray);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.sidebar__link:hover,
.sidebar__link.active {
  background: var(--c-gray-light);
  color: var(--c-black);
}
.sidebar__link.active { color: var(--c-purple); }
.sidebar__link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar__footer {
  padding: 16px 20px 0;
  border-top: 0.5px solid var(--c-border);
  margin-top: auto;
}
.main-content {
  padding: 40px;
  background: var(--c-gray-light);
  min-height: 100vh;
}

/* ── Tablas ──────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--c-white);
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 0.5px solid var(--c-border);
  background: var(--c-gray-light);
}
tbody td {
  padding: 14px 20px;
  font-size: 14px;
  border-bottom: 0.5px solid var(--c-border);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFAFA; }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28,28,28,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--c-white);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(12px) scale(0.98);
  transition: transform 200ms ease;
}
.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}
.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-gray);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: color var(--transition);
}
.modal__close:hover { color: var(--c-black); }

/* ── Alertas ─────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}
.alert--success { background: var(--c-green-light); color: var(--c-green); }
.alert--error   { background: var(--c-red-light);   color: #991B1B; }
.alert--info    { background: var(--c-purple-light); color: #1557E8; }
.alert--gray    { background: var(--c-gray-light);   color: #3F3F46; }

/* ── Page header ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header__title h1 { font-size: 26px; }
.page-header__title p  { color: var(--c-gray); font-size: 14px; margin-top: 4px; }

/* ── Stats grid ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--c-white);
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.stat-card__value {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--c-black);
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-gray);
}
.empty-state__icon {
  width: 48px; height: 48px;
  margin: 0 auto 16px;
  opacity: 0.4;
}
.empty-state h3 { color: var(--c-black); margin-bottom: 8px; }

/* ── Toast notificaciones ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--c-black);
  color: var(--c-white);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  max-width: 340px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 250ms ease;
  pointer-events: auto;
}
.toast.show   { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--c-green); }
.toast--error   { background: var(--c-red); }

/* ── Loading overlay ─────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(4px);
  z-index: 250;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.loading-overlay.active { opacity: 1; pointer-events: auto; }
.loading-overlay__spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--c-gray-light);
  border-top-color: var(--c-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-overlay p { font-size: 14px; color: var(--c-gray); }

/* ── Nivel de contexto IA ────────────────────────────────────────────── */
.nivel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}
.nivel-badge--1 { background: var(--c-purple-light); color: #1557E8; }
.nivel-badge--2 { background: var(--c-green-light);  color: var(--c-green); }
.nivel-badge--3 { background: var(--c-gray-light);   color: #52525B; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout-app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    width: 260px;
    height: 100%;
  }
  .sidebar.open { display: flex; }
  .main-content { padding: 20px 16px; }
  .page-header { flex-direction: column; }
  thead { display: none; }
  tbody tr {
    display: block;
    padding: 12px 0;
    border-bottom: 0.5px solid var(--c-border);
  }
  tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    border: none;
    font-size: 13px;
  }
  tbody td::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--c-gray);
    font-size: 12px;
  }
}

/* ── Utilities ───────────────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mt-auto { margin-top: auto; }
.w-full { width: 100%; }
.hidden { display: none; }
