/* main.css */
/* ========== TOKENS GLOBALES ========== */
:root {
  /* ===== Paleta base ===== */
  --bg: #0e0f1a;
  --light-bg: #1e2030;
  --card: #17182a;

  /* Texto */
  --text: #d3daf4; /* cuerpo */
  --text-strong: #f2f4ff; /* headings */
  --muted: #9ba3c6; /* ayudas/etiquetas */

  /* Acentos */
  --accent: #8b6eff;
  --accent-rgb: 139, 110, 255;
  --accent-warm: #ffb84d;
  --accent-warm-rgb: 255, 184, 77;

  /* Estados */
  --ok: #62cf73;
  --warn: var(--accent-warm);
  --info: #6ea8fe;
  --err: #ff6f7a;

  /* ===== Superficies / bordes / sombras ===== */
  --surface-1: rgba(255, 255, 255, 0.025);
  --surface-2: rgba(255, 255, 255, 0.045);

  --border-weak-color: rgba(255, 255, 255, 0.06);
  --border-weak: 1px solid var(--border-weak-color);
  --border-cta: 1px solid var(--accent);

  --outline: rgba(255, 255, 255, 0.16);
  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.32), 0 12px 28px -18px rgba(0, 0, 0, 0.55);

  /* Glow cálido (usado en badges/botones especiales) */
  --glow-warm-border: 1px solid var(--accent-warm);
  --glow-warm-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(var(--accent-warm-rgb), 0.3);

  /* Focus (unificado) */
  --focus-color: var(--accent);
  --focus-ring:
    0 0 0 1px var(--focus-color), 0 0 0 4px color-mix(in oklab, var(--focus-color) 18%, transparent);

  /* ===== Espaciado ===== */
  --gap-1: 6px; /* legacy */
  --gap-2: 8px; /* legacy */
  --gap-3: 12px; /* legacy */

  /* Aliases nuevos (para usar en layout de forma consistente) */
  --space-1: var(--gap-1);
  --space-2: var(--gap-2);
  --space-3: var(--gap-3);
  --space-4: 16px;

  /* ===== Radios ===== */
  --radius-10: 10px; /* legacy */
  --radius-12: 12px; /* legacy */

  /* Aliases nuevos */
  --radius-sm: 8px;
  --radius-control: var(--radius-10); /* inputs/botones/icon-button */
  --radius-card: 16px; /* cards */

  /* ===== Controles (altura/padding) ===== */
  --control-h-sm: 36px; /* botones compactos, input-search, icon-button */
  --control-h-md: 38px; /* acciones en headers que pedían 38px */
  --icon-button-size: 36px; /* .btn-icon */

  --input-py: 10px; /* padding vertical de inputs */
  --input-px: 12px; /* padding horizontal de inputs */

  /* ===== Tablas ===== */
  --table-th-py: 8px;
  --table-td-py: 8px;
  --table-x: 16px; /* padding horizontal de celdas */
  --table-row-hover-bg: rgba(255, 255, 255, 0.018);
  --table-row-divider: 1px solid rgba(255, 255, 255, 0.05);

  /* ===== Section ===== */
  --section-bg:
    radial-gradient(circle at 20% 0%, rgba(139, 110, 255, 0.08), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(110, 168, 254, 0.08), transparent 55%),
    color-mix(in oklab, var(--card) 92%, #020617 8%);

  /* ===== Scrollbars ===== */
  --scrollbar-size: 8px;
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);

  /* ===== Layout / breakpoints ===== */
  --container-max: 980px;
  --bp-md: 820px;
  --bp-lg: 980px;

  /* ===== Z-index ===== */
  --z-popover: 999;
  --z-overlay: 1000; /* NUEVO: por debajo del modal */
  --z-modal-backdrop: 1000; /* ya lo tenés */
  --z-modal: 1001;
}

/* ========== RESETS Y TIPOGRAFÍA ========== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.5 system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Ubuntu,
    'Helvetica Neue',
    Arial,
    'Noto Sans',
    'Apple Color Emoji',
    'Segoe UI Emoji',
    'Segoe UI Symbol';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1,
h2,
h3,
.card-title {
  color: var(--text-strong);
}
p,
.muted,
.help {
  color: var(--muted);
}

/* ===== Status row ===== */
.status-row {
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  min-height: 20px;
  margin: 6px 2px 10px;
}
.help {
  font-size: 13px;
  color: var(--muted);
}
.helpSuccess {
  color: var(--ok);
}
.helpWarning {
  color: var(--warn);
}
.helpError {
  color: var(--err);
}

/* ========== LAYOUTS BÁSICOS ========== */
header {
  padding: 32px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.container {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.brand-left {
  display: flex;
  align-items: center;
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand-link:hover {
  opacity: 0.9;
  text-decoration: none;
}

.brand-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.logo {
  width: 64px; /* ajustá el tamaño */
  height: 64px;
  background-image: url('/assets/logo/logo2-128x128.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

h1 {
  font-size: 28px;
  margin: 0;
}
h2 {
  font-size: 22px;
  margin: 24px 0 12px;
}
p {
  margin: 0 0 12px;
}
ul {
  padding-left: 18px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 760px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

footer {
  padding: 24px 16px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.footer-links a[aria-current='page'] {
  font-weight: 600;
  text-decoration: underline;
  pointer-events: none; /* evita que el link actual sea clickeable */
}

/* ========== COMPONENTES GLOBALES BÁSICOS ========== */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 15px 20px;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(var(--accent-rgb), 0.05);
}

/* ========== BADGE BASE GLOBAL ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;

  border: 1px solid var(--border-weak-color);
  background: var(--surface-1);
  color: var(--muted);
}

/* Variantes semánticas (colores) */
.badge--accent {
  background: rgba(var(--accent-rgb), 0.12) !important;
  border-color: rgba(var(--accent-rgb), 0.45) !important;
  color: var(--accent);
}

.badge--success {
  background: color-mix(in oklab, var(--ok) 15%, transparent) !important;
  border-color: color-mix(in oklab, var(--ok) 45%, transparent) !important;
  color: var(--ok);
}

.badge--danger {
  background: color-mix(in oklab, var(--err) 15%, transparent) !important;
  border-color: color-mix(in oklab, var(--err) 45%, transparent) !important;
  color: var(--err);
}

.badge--warning {
  background: color-mix(in oklab, var(--warn) 15%, transparent) !important;
  border-color: color-mix(in oklab, var(--warn) 45%, transparent) !important;
  color: var(--warn);
}

.badge--muted {
  background: var(--surface-1) !important;
  border-color: var(--border-weak-color) !important;
  color: var(--muted);
}

/* Variante “cerrado” que ya usabas */
.badge--closed {
  background: var(--surface-1) !important;
  color: var(--muted);
}

/* Variante interactiva (para filtros o clickeables) */
.badge--interactive {
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    color 0.15s ease;
}
.badge--interactive:hover {
  background: rgba(var(--accent-warm-rgb), 0.12) !important;
  border-color: rgba(var(--accent-warm-rgb), 0.5) !important;
  color: var(--accent-warm);
}

.flex {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ========== BOTONES (UNIFICADO) ========== */
.btn {
  display: inline-block;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  font-size: 0.8em;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}
.btn:hover {
  filter: brightness(1.05);
  text-decoration: none;
  border-color: var(--accent-warm);
  background: rgba(var(--accent-warm-rgb), 0.12);
  color: var(--accent-warm);
}
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
}

/* ========== FORM (LOGIN) ESPECÍFICO ========== */
/* Para formularios generales usar lo de shared-ui (.field …). */
input[type='email'],
.otp input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0e1130cc;
  color: var(--text);
  outline: none;
}

input[type='email']:focus {
  border-color: rgba(110, 168, 254, 0.45);
}

.status {
  margin-top: 10px;
  min-height: 22px;
  font-size: 14px;
}

/* Formulario del ogin */
.narrow .card > * {
  margin-top: 12px;
}

/* Que el botón ocupe el ancho del input */
.narrow #sendCode.btn {
  width: 100%;
}

/* Modal + OTP (pantalla de login) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  /* transparente por defecto */
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;

  transition:
    opacity 200ms ease-out,
    background 200ms ease-out;

  z-index: var(--z-modal-backdrop, var(--z-modal));
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
  /* scrim suave, ajustá al gusto */
  background: color-mix(in oklab, #000 45%, transparent);
}

/* Dialog: entra con leve slide + fade-in */
.modal-backdrop .modal {
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 200ms ease-out,
    transform 200ms ease-out;
}

/* Dialog visible */
.modal-backdrop.show .modal {
  opacity: 1;
  transform: translateY(0);
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.12));
}

.modal-close {
  background: transparent;
  border: 0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.modal p {
  margin: 0 0 14px;
  color: var(--muted);
}

.modal-body {
  padding: 16px;
}

.otp {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 12px 0 6px;
}
.otp input {
  width: 46px;
  height: 54px;
  text-align: center;
  font-size: 22px;
  letter-spacing: 2px;
}
.otp input.error {
  border-color: var(--err);
}
.modal .actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.link {
  color: var(--accent);
  cursor: pointer;
}

.status-row .help {
  font-size: 13px;
}

/* Helpers de layout en forms simples */
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (prefers-color-scheme: light) {
  :root {
    /* ===== Paleta base (light) ===== */
    --bg: #f5f7fb;
    --light-bg: #e9ecf8;
    --card: #ffffff;

    /* Texto */
    --text: #1b2138;
    --text-strong: #070815;
    --muted: #6a6f88;

    /* Acentos (mantenemos familia pero más suaves) */
    --accent: #6b5bff;
    --accent-rgb: 107, 91, 255;
    --accent-warm: #ffb84d;
    --accent-warm-rgb: 255, 184, 77;

    /* Estados (ligeramente ajustados para fondo claro) */
    --ok: #2a9d4b;
    --warn: #e79b2f;
    --info: #2f7de7;
    --err: #e7515b;

    /* Superficies en modo claro */
    --surface-1: rgba(0, 0, 0, 0.02);
    --surface-2: rgba(0, 0, 0, 0.04);

    --border-weak-color: rgba(0, 0, 0, 0.06);
    --border-weak: 1px solid var(--border-weak-color);
    --border-cta: 1px solid var(--accent);

    --outline: rgba(0, 0, 0, 0.16);
    --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.06), 0 10px 30px rgba(15, 23, 42, 0.08);

    /* Focus (ligeramente más suave en light) */
    --focus-color: var(--accent);
    --focus-ring:
      0 0 0 1px var(--focus-color),
      0 0 0 4px color-mix(in oklab, var(--focus-color) 14%, transparent);

    /* Tablas */
    --table-row-hover-bg: rgba(15, 23, 42, 0.03);
    --table-row-divider: 1px solid rgba(15, 23, 42, 0.06);

    /* Scrollbars */
    --scrollbar-thumb: rgba(15, 23, 42, 0.18);
    --scrollbar-thumb-hover: rgba(15, 23, 42, 0.28);
  }

  /* Inputs en light (no queremos fondo casi negro) */
  input[type='email'],
  .otp input {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.18);
    color: var(--text);
  }

  input[type='email']:focus,
  .otp input:focus {
    border-color: rgba(47, 125, 231, 0.7);
    outline: none;
  }

  /* Cards: sombra más suave en light */
  .card {
    background: var(--card);
    border-color: rgba(15, 23, 42, 0.06);
    box-shadow:
      0 1px 2px rgba(15, 23, 42, 0.04),
      0 8px 20px rgba(15, 23, 42, 0.06);
  }

  /* Botones: siguen funcionando porque usan accent/accent-rgb */
  .btn {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
    border-color: var(--accent);
  }

  .btn:hover {
    background: rgba(var(--accent-warm-rgb), 0.12);
    color: var(--accent-warm);
    border-color: var(--accent-warm);
  }

  /* Badges: un poco más ligeras en light */
  .badge {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
  }

  .badge--closed {
    background: rgba(15, 23, 42, 0.02);
    color: var(--muted);
  }

  /* Header / footer bordes adaptados */
  header,
  footer {
    border-color: rgba(15, 23, 42, 0.06);
  }
}

/* Responsive forms en mobile */
@media (max-width: 920px) {
  .row {
    gap: 8px;
  }
}

/* (Opcional) un pelín más de separación justo entre input y botón */
@media (min-width: 0) {
  .narrow #email + #sendCode {
    margin-top: 14px; /* si querés 14 en vez de 12 solo acá */
  }
}

@media (min-width: 1024px) {
  .narrow .card {
    padding: 32px 28px;
  }
}

button,
a,
[role='button'],
.btn,
.tab,
.link,
[onclick],
[data-clickable='true'] {
  cursor: pointer !important;
}
