/* ==========================================================================
   DESIGN SYSTEM — Sistema de Acreditación
   Única fuente de verdad para color, tipografía, espaciado y componentes.
   Todas las páginas deben consumir estos tokens en lugar de estilos ad-hoc.
   Cambiar la identidad visual = cambiar las variables de :root.
   ========================================================================== */

/* ---------- Tipografía self-hosted (Inter, con fallback a system-ui) ------ */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/inter-700.woff2") format("woff2");
}

/* ---------- Tipografía display (Archivo Expanded, para títulos y KPIs) ----- */
/* Grotesque geométrica ancha y pesada. Da carácter a los números y encabezados
   sin tocar la legibilidad del cuerpo (que sigue en Inter). Solo pesos 700/800. */
@font-face {
  font-family: "Archivo Expanded";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/archivo-expanded-700.woff2") format("woff2");
}
@font-face {
  font-family: "Archivo Expanded";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("../fonts/archivo-expanded-800.woff2") format("woff2");
}

/* ---------- Aplicación de la fuente display (identidad tipográfica global) ---
   La marca del header y una clase utilitaria para títulos grandes usan Archivo
   Expanded en TODAS las páginas, para unificar la personalidad con Index/acreditar.
   El cuerpo sigue en Inter. Cargá design-system.css DESPUÉS de Bootstrap. */
.navbar-brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
/* Clase utilitaria: aplicala al título principal de cada página (h1/h2 grande). */
.display-title {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

/* ==========================================================================
   TOKENS
   ========================================================================== */
:root {
  /* -- Marca (estética Resend: el "color de marca" es NEGRO/grafito, no un color).
        Escala de grises neutros cálidos. Cambiar aquí propaga a toda la app. -- */
  --brand-50:  #f5f5f5;
  --brand-100: #e8e8e8;
  --brand-200: #d4d4d4;
  --brand-300: #a8a8a8;
  --brand-400: #6b6b6b;
  --brand-500: #2e2e2e;
  --brand-600: #1a1a1a;  /* color principal (casi negro) */
  --brand-700: #121212;
  --brand-800: #0a0a0a;
  --brand-900: #000000;

  --brand:       var(--brand-600);
  --brand-hover: var(--brand-700);
  --brand-active:var(--brand-800);

  /* -- Neutros (grises neutros, look Resend limpio) -- */
  --gray-50:  #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #ececec;
  --gray-300: #e2e2e2;
  --gray-400: #9a9a9a;
  --gray-500: #6b6b6b;
  --gray-600: #525252;
  --gray-700: #3a3a3a;
  --gray-800: #1f1f1f;
  --gray-900: #0a0a0a;

  /* -- Roles semánticos (sobrios, estilo Resend) -- */
  --success:      #1a7f52;
  --success-bg:   #e9f6ef;
  --warning:      #b45309;
  --warning-bg:   #fef3e2;
  --danger:       #c0392b;
  --danger-bg:    #fbeceb;
  --info:         #2563eb;
  --info-bg:      #eaf1fe;

  /* -- Superficies y texto -- */
  --surface:        #ffffff;   /* cards, modales */
  --surface-subtle: var(--gray-50);
  --page-bg:        var(--gray-50);
  --text-primary:   var(--gray-900);
  --text-secondary: var(--gray-500);
  --text-muted:     var(--gray-400);
  --text-on-brand:  #ffffff;

  /* -- Bordes -- */
  --border:        var(--gray-200);
  --border-strong: var(--gray-300);
  --border-focus:  var(--brand-400);

  /* -- Tipografía -- */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  /* Display: títulos de pantalla y números de KPI. Fallback a una condensada
     pesada del sistema para que el layout no se rompa si la fuente no carga. */
  --font-display: "Archivo Expanded", "Arial Black", "Helvetica Neue", var(--font-sans);
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;

  --fs-xs:   0.75rem;   /* 12px */
  --fs-sm:   0.875rem;  /* 14px */
  --fs-base: 1rem;      /* 16px */
  --fs-lg:   1.125rem;  /* 18px */
  --fs-xl:   1.375rem;  /* 22px */
  --fs-2xl:  1.75rem;   /* 28px */
  --fs-3xl:  2.25rem;   /* 36px */

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* -- Radios -- */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full:9999px;

  /* -- Sombras (muy sutiles, estilo Resend — casi planas) -- */
  --shadow-xs: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-sm: 0 1px 3px rgba(10, 10, 10, 0.06), 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow:    0 4px 12px rgba(10, 10, 10, 0.06);
  --shadow-lg: 0 10px 30px rgba(10, 10, 10, 0.10);
  --shadow-brand: 0 8px 24px rgba(10, 10, 10, 0.16);
  --focus-ring: 0 0 0 3px rgba(10, 10, 10, 0.12);

  /* -- Espaciado (escala de 4px) -- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;

  /* -- Transiciones -- */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur:  180ms;
}

/* ==========================================================================
   RESET / BASE
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

.ds-body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ==========================================================================
   COMPONENTES
   ========================================================================== */

/* -- Botón -- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.ds-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ds-btn:active { transform: scale(0.985); }
.ds-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ds-btn--primary {
  background: var(--brand);
  color: var(--text-on-brand);
}
.ds-btn--primary:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: var(--shadow-brand);
}

.ds-btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.ds-btn--secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: var(--gray-400);
}

.ds-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.ds-btn--ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--text-primary);
}

.ds-btn--danger {
  background: var(--danger);
  color: #fff;
}
.ds-btn--danger:hover:not(:disabled) { background: #b91c1c; }

.ds-btn--block { width: 100%; }
.ds-btn--lg { padding: 0.9rem 1.5rem; font-size: var(--fs-base); }

/* -- Campo de formulario -- */
.ds-field { margin-bottom: var(--sp-4); }
.ds-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}
.ds-input {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.ds-input::placeholder { color: var(--text-muted); }
.ds-input:hover { border-color: var(--border-strong); }
.ds-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* Campo con icono a la izquierda */
.ds-input-group { position: relative; display: flex; align-items: center; }
.ds-input-group .ds-input { padding-left: 2.6rem; }
.ds-input-group__icon {
  position: absolute;
  left: 0.9rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  pointer-events: none;
  transition: color var(--dur) var(--ease);
}
.ds-input-group .ds-input:focus + .ds-input-group__icon,
.ds-input-group:focus-within .ds-input-group__icon { color: var(--brand); }

/* -- Card -- */
.ds-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* -- Alert / mensaje -- */
.ds-alert {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.ds-alert--danger  { background: var(--danger-bg);  color: #991b1b; border-color: #fecaca; }
.ds-alert--success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.ds-alert--warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.ds-alert--info    { background: var(--info-bg);    color: #075985; border-color: #bae6fd; }

/* -- Utilidad: spinner -- */
.ds-spinner {
  width: 1.05em;
  height: 1.05em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* Respeta a quienes prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   SIDEBAR / LAYOUT DEL CENTRO DE MANDO (dashboard + admin-panel)
   Generado por js/sidebar.js. Clases propias (app-*) para no chocar con Bootstrap.
   ========================================================================== */
.app-layout { display: flex; min-height: 100vh; }
.app-main   { flex: 1; min-width: 0; padding: 30px 36px 60px; }

.app-sidebar {
  width: 240px; flex: 0 0 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.app-sidebar__org { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 14px; }
.app-sidebar__logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: 0 0 auto;
}
.app-sidebar__org-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--text-primary); }

.app-nav { display: flex; flex-direction: column; gap: 1px; }
.app-nav__group {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 600;
  padding: 10px 10px 5px;
}
.app-nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
}
.app-nav__item i { font-size: 16px; width: 18px; text-align: center; flex: 0 0 auto; }
.app-nav__item:hover { background: var(--gray-100); color: var(--text-primary); }
.app-nav__item.active { background: var(--gray-100); color: var(--text-primary); font-weight: 600; }

.app-sidebar__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.app-sidebar__event, .app-sidebar__user { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sidebar__actions { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.app-sidebar__btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12.5px; font-weight: 500;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.app-sidebar__btn:hover { background: var(--gray-100); color: var(--text-primary); }
.app-sidebar__btn--danger:hover { color: var(--danger); border-color: var(--danger); }

/* Botón hamburguesa (oculto en desktop) */
.app-sidebar__toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 1060;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-primary); font-size: 20px; cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed; top: 0; left: 0; z-index: 1055;
    transform: translateX(-100%); transition: transform .2s var(--ease, ease);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar--open { transform: translateX(0); }
  .app-sidebar__toggle { display: flex; }
  .app-main { padding: 64px 16px 48px; }
}
