/**
 * ui.css · Sistema de diseño del panel (ver DESIGN.md)
 *
 * Se carga el ÚLTIMO y SOLO en páginas de panel (portada, herramientas, admin, login).
 * Los overlays de OBS no lo cargan, así que nada de aquí puede cambiarlos.
 */

:root {
  /* Color */
  --ui-bg: #0e0e10;
  --ui-surface: #18181b;
  --ui-surface-2: #1f1f23;
  --ui-border: #2a2a30;
  --ui-border-strong: #3a3a42;
  --ui-text: #efeff1;
  --ui-text-muted: #adadb8;
  --ui-text-dim: #85858f;
  --ui-primary: #9146ff;
  --ui-primary-hover: #772ce8;
  --ui-primary-text: #bf94ff;
  --ui-on-primary: #ffffff;
  --ui-primary-rgb: 145, 70, 255;
  --ui-success: #34d399;
  --ui-warning: #f5b84b;
  --ui-danger: #f87171;

  /* Tipografía */
  --ui-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ui-font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ui-text-xs: 0.75rem;
  --ui-text-sm: 0.875rem;
  --ui-text-md: 1rem;
  --ui-text-lg: 1.125rem;
  --ui-text-xl: 1.375rem;
  --ui-text-2xl: 1.75rem;
  --ui-text-3xl: 2.25rem;

  /* Espaciado */
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 24px;
  --ui-space-6: 32px;
  --ui-space-7: 48px;
  --ui-space-8: 64px;
  --ui-content: 1200px;

  /* Forma */
  --ui-radius-sm: 6px;
  --ui-radius-md: 10px;
  --ui-radius-lg: 14px;
  --ui-radius-pill: 999px;
  --ui-shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.45);

  /* Tokens heredados de shared.css / admin.css / profile-sidebar.css, redirigidos al
     sistema para que las páginas existentes cambien sin tocar sus CSS (que comparten
     con los overlays). Los colores de marca (Twitch, Spotify) y de acento no se tocan. */
  --bg-primary: var(--ui-bg);
  --bg-secondary: var(--ui-surface);
  --bg-tertiary: var(--ui-surface-2);
  --bg-card: var(--ui-surface);
  --bg-card-hover: var(--ui-surface-2);
  --bg-glass: var(--ui-surface);
  --bg-glass-strong: var(--ui-surface);
  --bg-input: var(--ui-surface-2);
  --border-subtle: var(--ui-border);
  --border-glow: var(--ui-border-strong);
  --border-active: var(--ui-primary);
  --text-main: var(--ui-text);
  --text-muted: var(--ui-text-muted);
  --text-dim: var(--ui-text-dim);
  --font-main: var(--ui-font);
  --radius-sm: var(--ui-radius-sm);
  --radius-md: var(--ui-radius-sm);
  --radius-lg: var(--ui-radius-md);
  --radius-xl: var(--ui-radius-lg);
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: var(--ui-shadow-pop);
  --shadow-neon-purple: none;
  --shadow-neon-cyan: none;
  --shadow-neon-spotify: none;
  --shadow-neon-pink: none;
  --shadow-neon-gold: none;

  --admin-bg: var(--ui-bg);
  --admin-surface: var(--ui-surface);
  --admin-card: var(--ui-surface);
  --admin-border: var(--ui-border);
  --admin-border-hover: var(--ui-border-strong);
  --admin-primary: var(--ui-primary);
  --admin-text-main: var(--ui-text);
  --admin-text-muted: var(--ui-text-muted);

  --ps-primary: var(--ui-primary-text);
  --ps-primary-glow: transparent;
  --ps-bg-deep: var(--ui-surface);
  --ps-bg-card: var(--ui-surface-2);
  --ps-bg-hover: var(--ui-surface-2);
  --ps-border: var(--ui-border);
  --ps-border-active: var(--ui-border-strong);
  --ps-text-dim: var(--ui-text-muted);
}

/* =======================================================
   COLOR PRINCIPAL ELEGIDO POR EL USUARIO
   js/theme.js pone <html data-accent="…"> antes de pintar la página.
   Texto sobre el color (on-primary) elegido para contraste ≥ 4.5:1.
   ======================================================= */
:root[data-accent="blue"] {
  --ui-primary: #2563eb; --ui-primary-hover: #1d4ed8; --ui-primary-text: #93c5fd;
  --ui-on-primary: #ffffff; --ui-primary-rgb: 37, 99, 235;
}
:root[data-accent="cyan"] {
  --ui-primary: #22d3ee; --ui-primary-hover: #06b6d4; --ui-primary-text: #67e8f9;
  --ui-on-primary: #0e0e10; --ui-primary-rgb: 34, 211, 238;
}
:root[data-accent="green"] {
  --ui-primary: #22c55e; --ui-primary-hover: #16a34a; --ui-primary-text: #86efac;
  --ui-on-primary: #0e0e10; --ui-primary-rgb: 34, 197, 94;
}
:root[data-accent="amber"] {
  --ui-primary: #f59e0b; --ui-primary-hover: #d97706; --ui-primary-text: #fcd34d;
  --ui-on-primary: #0e0e10; --ui-primary-rgb: 245, 158, 11;
}
:root[data-accent="orange"] {
  --ui-primary: #f97316; --ui-primary-hover: #ea580c; --ui-primary-text: #fdba74;
  --ui-on-primary: #0e0e10; --ui-primary-rgb: 249, 115, 22;
}
:root[data-accent="pink"] {
  --ui-primary: #db2777; --ui-primary-hover: #be185d; --ui-primary-text: #f9a8d4;
  --ui-on-primary: #ffffff; --ui-primary-rgb: 219, 39, 119;
}
:root[data-accent="red"] {
  --ui-primary: #dc2626; --ui-primary-hover: #b91c1c; --ui-primary-text: #fca5a5;
  --ui-on-primary: #ffffff; --ui-primary-rgb: 220, 38, 38;
}

/* =======================================================
   BASE
   ======================================================= */
html {
  -webkit-text-size-adjust: 100%;
}

body,
body.app-shell {
  font-family: var(--ui-font);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: var(--ui-text-md);
  line-height: 1.5;
}

.app-shell {
  background: var(--ui-bg);
  background-attachment: initial;
}

/* Foco del teclado: con outline (no box-shadow) para que ningún componente lo tape.
   !important porque muchos componentes antiguos ponen outline: none. */
:focus-visible {
  outline: 2px solid var(--ui-primary-text) !important;
  outline-offset: 2px;
}

::selection {
  background: rgba(var(--ui-primary-rgb), 0.35);
}

/* =======================================================
   CABECERA, CONTENEDOR Y PIE
   ======================================================= */
.app-header {
  background: var(--ui-bg);
  border-bottom: 1px solid var(--ui-border);
  backdrop-filter: none;
  padding: var(--ui-space-3) var(--ui-space-5);
  gap: var(--ui-space-4);
}

.header-brand {
  gap: var(--ui-space-3);
  min-width: 0;
}

.brand-icon,
.brand-icon-logo {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.brand-info h1 {
  font-size: var(--ui-text-md);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ui-text);
}

.brand-info p {
  font-size: var(--ui-text-xs);
  color: var(--ui-text-dim);
}

.layout-container {
  max-width: var(--ui-content);
  padding: var(--ui-space-6) var(--ui-space-5) var(--ui-space-8);
}

.app-footer {
  background: transparent;
  border-top: 1px solid var(--ui-border);
  color: var(--ui-text-dim);
  font-size: var(--ui-text-sm);
}

.app-footer p {
  color: var(--ui-text-dim);
}

/* Títulos de página heredados: izquierda, sin degradados ni pastillas brillantes */
.page-hero h2 {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--ui-text);
  text-shadow: none;
}

.hero-pill {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-muted);
  box-shadow: none;
}

/* =======================================================
   BOTONES
   ======================================================= */
.btn {
  min-height: 36px;
  padding: 0 var(--ui-space-4);
  font-size: var(--ui-text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--ui-radius-sm);
  border: 1px solid transparent;
  box-shadow: none;
  backdrop-filter: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
}

.btn:hover,
.btn:active {
  transform: none;
  box-shadow: none;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ui-primary);
  color: var(--ui-on-primary);
  border-color: transparent;
}

.btn-primary:hover {
  background: var(--ui-primary-hover);
}

.btn-secondary,
.btn-obs {
  background: var(--ui-surface-2);
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}

.btn-secondary:hover,
.btn-obs:hover {
  background: #2a2a30;
  color: var(--ui-text);
  border-color: #4a4a54;
}

.btn-spotify {
  background: #1db954;
  color: #000;
  border-color: transparent;
}

.btn-spotify:hover {
  background: #1ed760;
}

.btn-quiet {
  background: transparent;
  color: var(--ui-text-muted);
  border-color: transparent;
}

.btn-quiet:hover {
  color: var(--ui-text);
  background: var(--ui-surface-2);
}

.btn-sm {
  min-height: 30px;
  padding: 0 var(--ui-space-3);
  font-size: 0.8125rem;
  border-radius: var(--ui-radius-sm);
}

.btn-lg {
  min-height: 44px;
  padding: 0 var(--ui-space-5);
  font-size: var(--ui-text-md);
}

/* =======================================================
   CAMPOS
   ======================================================= */
.form-control {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  color: var(--ui-text);
  box-shadow: none;
}

.form-control::placeholder {
  color: var(--ui-text-dim);
}

.form-control:focus {
  outline: none;
  border-color: var(--ui-primary);
  box-shadow: 0 0 0 3px rgba(var(--ui-primary-rgb), 0.25);
}

.form-group label {
  color: var(--ui-text-muted);
  font-size: var(--ui-text-sm);
  font-weight: 500;
}

/* =======================================================
   BADGES Y ESTADO
   ======================================================= */
.badge,
.status-badge {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-muted);
  box-shadow: none;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.status-badge.live,
.status-badge.paused,
.status-badge.spotify {
  background: var(--ui-surface-2);
  border-color: var(--ui-border);
  color: var(--ui-text-muted);
}

.status-badge.live .status-dot { background: var(--ui-success); box-shadow: none; }
.status-badge.paused .status-dot { background: var(--ui-warning); box-shadow: none; }

/* =======================================================
   SUPERFICIES FLOTANTES
   ======================================================= */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: none;
}

.modal-window {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-pop);
}

.toast-notice {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border-strong);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-pop);
  backdrop-filter: none;
}

/* =======================================================
   CABECERA COMÚN: BUSCADOR Y CUENTA (inyectados por JS)
   ======================================================= */
.topbar-search-input-box {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-sm);
  box-shadow: none;
}

.topbar-search-input-box:hover,
.topbar-search-input-box:focus-within {
  border-color: var(--ui-border-strong);
  box-shadow: none;
}

.topbar-tools-dropdown {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  box-shadow: var(--ui-shadow-pop);
  backdrop-filter: none;
}

.topbar-tool-card {
  background: transparent;
  border-color: transparent;
  border-radius: var(--ui-radius-sm);
}

.topbar-tool-card:hover,
.topbar-tool-card.active {
  background: var(--ui-surface-2);
  border-color: var(--ui-border);
  transform: none;
  box-shadow: none;
}

/* "Abrir" en los resultados del buscador: con el color elegido por el usuario */
.btn-tool-open {
  background: var(--ui-primary);
  border-color: transparent;
  color: var(--ui-on-primary);
  box-shadow: none;
}

.btn-tool-open:hover {
  background: var(--ui-primary-hover);
  box-shadow: none;
}

.user-pill {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  box-shadow: none;
}

/* Botón lateral "Mi perfil" y cajón */
.profile-floating-trigger {
  background: var(--ui-surface);
  border-color: var(--ui-border-strong);
  box-shadow: none;
}

.profile-drawer-window {
  background: var(--ui-surface);
  border-left: 1px solid var(--ui-border);
}

/* =======================================================
   PÁGINAS DE HERRAMIENTA
   Ajustes solo donde la página chocaba con el sistema; el interior de cada
   herramienta conserva su maquetación.
   ======================================================= */

/* Cabecera de página: alineada a la izquierda, sin pastilla de versión */
.page-hero {
  text-align: left;
  padding-top: 0;
  margin-bottom: var(--ui-space-6) !important;
}

.page-hero .hero-pill {
  display: none;
}

.page-hero h2 {
  font-size: var(--ui-text-2xl);
  line-height: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  max-width: none;
}

.page-hero p {
  margin: var(--ui-space-2) 0 0;
  max-width: 65ch;
  font-size: var(--ui-text-md);
  color: var(--ui-text-muted);
}

/* Logotipo de la cabecera (todas las páginas usan el de IrlTools) */
.app-header .brand-icon-logo,
.dash-header .logo-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: transparent;
  border: none;
  box-shadow: none;
  animation: none;
  padding: 0;
}

/* Cabecera propia del Subathon */
.dash-header {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  backdrop-filter: none;
  box-shadow: none;
}

.logo-text h1 {
  font-size: var(--ui-text-lg);
  font-weight: 700;
  letter-spacing: 0;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--ui-text);
}

/* Paneles de cada herramienta: planos, con borde, sin brillo */
.card,
.dash-card,
.chat-card,
.roulette-card,
.counter-card,
.pred-card,
.spotify-card-panel {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  box-shadow: none;
  backdrop-filter: none;
}

.card:hover,
.dash-card:hover,
.counter-card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--ui-border-strong);
}

.pred-card.active-live {
  border-color: var(--ui-primary);
  box-shadow: none;
}

.config-section-title {
  color: var(--ui-text-muted);
}

.obs-link-box {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
}

.chat-card-header h3,
.roulette-card-header h3,
.counter-card-header h3,
.pred-card-header h3,
.card-title {
  color: var(--ui-text);
  font-size: var(--ui-text-md);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* Cabecera del panel de administración */
.admin-title {
  font-size: var(--ui-text-xl);
  font-weight: 700;
  letter-spacing: 0;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--ui-text);
}

.admin-logo-icon {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  background: transparent;
  box-shadow: none;
}

.btn-admin {
  min-height: 30px;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  color: var(--ui-text);
  font-size: 0.8125rem;
  font-weight: 600;
}

.btn-admin:hover {
  background: #2a2a30;
  transform: none;
}

.admin-tab.active {
  color: var(--ui-text);
  border-bottom-color: var(--ui-primary);
  background: transparent;
}

/* Cuenta del usuario en la cabecera (inyectada por auth-shared.js) */
.btn-admin-header {
  min-height: 30px;
  padding: 0 var(--ui-space-3);
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-sm);
  color: var(--ui-text);
  font-size: 0.8125rem;
  font-weight: 600;
}

.btn-admin-header:hover {
  background: #2a2a30;
  box-shadow: none;
  transform: none;
}

.admin-badge {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border-strong);
  color: var(--ui-text-muted);
  box-shadow: none;
  letter-spacing: 0;
}

#globalUserHeaderMount .user-pill {
  background: var(--ui-surface) !important;
  border: 1px solid var(--ui-border) !important;
  border-radius: var(--ui-radius-pill) !important;
}

#globalUserHeaderMount .user-name {
  font-weight: 600 !important;
  color: var(--ui-text) !important;
}

/* =======================================================
   RESPONSIVE
   ======================================================= */
/* Tablet: logo y cuenta en la primera fila, buscador debajo a todo el ancho
   (layout.css mandaba la cuenta a una fila propia y quedaban tres filas) */
@media (min-width: 561px) and (max-width: 860px) {
  .app-header .header-actions {
    width: auto;
    margin-left: auto;
    padding-bottom: 0;
  }
}

@media (max-width: 720px) {
  .app-header {
    padding: var(--ui-space-3) var(--ui-space-4);
  }

  .layout-container {
    padding: var(--ui-space-5) var(--ui-space-4) var(--ui-space-7);
  }

  .brand-info p {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
