/* ============================================================
   LEGENDARY KINGDOMS — BASE CSS
   Reset · Variables · Tipografía · Utilidades globales
   ============================================================ */

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
  background-color: var(--lk-bg-base);
  color: var(--lk-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--lk-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* ── Variables de diseño ──────────────────────────────────── */
:root {
  /* Paleta base — tema oscuro por defecto */
  --lk-bg-base:        #0f0f0f;
  --lk-bg-surface:     #161616;
  --lk-bg-elevated:    #1e1e1e;
  --lk-bg-hover:       #252525;
  --lk-bg-active:      #2c2c2c;

  /* Bordes */
  --lk-border-subtle:  rgba(255, 255, 255, 0.06);
  --lk-border-default: rgba(255, 255, 255, 0.10);
  --lk-border-strong:  rgba(255, 255, 255, 0.18);

  /* Texto */
  --lk-text-primary:   #e8e6e0;
  --lk-text-secondary: #9b9790;
  --lk-text-muted:     #5c5a56;
  --lk-text-inverse:   #0f0f0f;

  /* Acento — ámbar dorado, evoca pergamino y fantasía sin ser kitsch */
  --lk-accent:         #c9963a;
  --lk-accent-dim:     rgba(201, 150, 58, 0.15);
  --lk-accent-hover:   #dba94a;

  /* Semánticos */
  --lk-danger:         #c0392b;
  --lk-danger-dim:     rgba(192, 57, 43, 0.15);
  --lk-danger-text:    #e57368;
  --lk-success:        #27ae60;
  --lk-success-dim:    rgba(39, 174, 96, 0.15);
  --lk-success-text:   #5dba7e;
  --lk-warning:        #e67e22;
  --lk-warning-dim:    rgba(230, 126, 34, 0.15);
  --lk-warning-text:   #f0a05a;
  --lk-info:           #2980b9;
  --lk-info-dim:       rgba(41, 128, 185, 0.15);
  --lk-info-text:      #5daadc;

  /* Salud */
  --lk-hp-hi:   #27ae60;
  --lk-hp-mid:  #e67e22;
  --lk-hp-lo:   #c0392b;
  --lk-hp-dead: #444444;

  /* Tipografía */
  --lk-font-sans:      'Inter', system-ui, -apple-system, sans-serif;
  --lk-font-serif:     'Crimson Text', 'Georgia', serif;
  --lk-font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  --lk-text-xs:    0.75rem;
  --lk-text-sm:    0.875rem;
  --lk-text-base:  1rem;
  --lk-text-md:    1.125rem;
  --lk-text-lg:    1.25rem;
  --lk-text-xl:    1.5rem;
  --lk-text-2xl:   1.875rem;
  --lk-text-3xl:   2.25rem;

  /* Espaciado */
  --lk-space-1:  0.25rem;
  --lk-space-2:  0.5rem;
  --lk-space-3:  0.75rem;
  --lk-space-4:  1rem;
  --lk-space-5:  1.25rem;
  --lk-space-6:  1.5rem;
  --lk-space-8:  2rem;
  --lk-space-10: 2.5rem;
  --lk-space-12: 3rem;

  /* Radios */
  --lk-radius-sm:   4px;
  --lk-radius-md:   8px;
  --lk-radius-lg:   12px;
  --lk-radius-xl:   16px;
  --lk-radius-full: 9999px;

  /* Sombras */
  --lk-shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --lk-shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --lk-shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  /* Transiciones */
  --lk-transition-fast:   100ms ease;
  --lk-transition-base:   200ms ease;
  --lk-transition-slow:   350ms ease;

  /* Layout */
  --lk-sidebar-width:      240px;
  --lk-sidebar-collapsed:  52px;
  --lk-topbar-height:      52px;
  --lk-bottombar-height:   48px;
}

/* ── Tema claro (por si se añade en el futuro) ────────────── */
[data-theme="light"] {
  --lk-bg-base:        #f5f4f0;
  --lk-bg-surface:     #ffffff;
  --lk-bg-elevated:    #fafaf8;
  --lk-bg-hover:       #f0efe9;
  --lk-bg-active:      #e8e7e0;

  --lk-border-subtle:  rgba(0, 0, 0, 0.05);
  --lk-border-default: rgba(0, 0, 0, 0.10);
  --lk-border-strong:  rgba(0, 0, 0, 0.20);

  --lk-text-primary:   #1a1917;
  --lk-text-secondary: #5c5a56;
  --lk-text-muted:     #9b9790;
  --lk-text-inverse:   #e8e6e0;

  --lk-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --lk-shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --lk-shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
}

/* ── Scrollbar personalizada ──────────────────────────────── */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--lk-border-strong); border-radius: var(--lk-radius-full); }
::-webkit-scrollbar-thumb:hover  { background: var(--lk-text-muted); }

/* ── Tipografía ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  line-height: 1.3;
  color: var(--lk-text-primary);
}
h1 { font-size: var(--lk-text-2xl); }
h2 { font-size: var(--lk-text-xl); }
h3 { font-size: var(--lk-text-lg); }
h4 { font-size: var(--lk-text-md); }
h5 { font-size: var(--lk-text-base); }
h6 { font-size: var(--lk-text-sm); }

.lk-heading-serif {
  font-family: var(--lk-font-serif);
  letter-spacing: 0.02em;
}

p { margin-bottom: var(--lk-space-4); }
p:last-child { margin-bottom: 0; }

.lk-text-xs      { font-size: var(--lk-text-xs); }
.lk-text-sm      { font-size: var(--lk-text-sm); }
.lk-text-base    { font-size: var(--lk-text-base); }
.lk-text-md      { font-size: var(--lk-text-md); }
.lk-text-lg      { font-size: var(--lk-text-lg); }
.lk-text-xl      { font-size: var(--lk-text-xl); }
.lk-text-muted   { color: var(--lk-text-secondary); }
.lk-text-accent  { color: var(--lk-accent); }
.lk-text-danger  { color: var(--lk-danger-text); }
.lk-text-success { color: var(--lk-success-text); }
.lk-text-warning { color: var(--lk-warning-text); }
.lk-mono         { font-family: var(--lk-font-mono); }

/* ── Componentes base ─────────────────────────────────────── */

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--lk-space-2);
  padding: var(--lk-space-2) var(--lk-space-4);
  border-radius: var(--lk-radius-md);
  border: 1px solid var(--lk-border-default);
  background: transparent;
  color: var(--lk-text-primary);
  font-size: var(--lk-text-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: background var(--lk-transition-fast),
              border-color var(--lk-transition-fast),
              color var(--lk-transition-fast);
}
.btn:hover   { background: var(--lk-bg-hover); border-color: var(--lk-border-strong); }
.btn:active  { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* Variantes */
.btn-p, .btn-primary {
  background: var(--lk-accent);
  border-color: var(--lk-accent);
  color: var(--lk-text-inverse);
}
.btn-p:hover, .btn-primary:hover {
  background: var(--lk-accent-hover);
  border-color: var(--lk-accent-hover);
}
.btn-g, .btn-ghost {
  border-color: transparent;
}
.btn-g:hover, .btn-ghost:hover {
  background: var(--lk-bg-hover);
  border-color: var(--lk-border-subtle);
}
.btn-d {
  background: var(--lk-danger-dim);
  border-color: var(--lk-danger);
  color: var(--lk-danger-text);
}
.btn-d:hover { background: var(--lk-danger); color: #fff; border-color: var(--lk-danger); }

/* Tamaños */
.btn-sm {
  padding: var(--lk-space-1) var(--lk-space-3);
  font-size: var(--lk-text-xs);
  border-radius: var(--lk-radius-sm);
}
.btn-ico {
  padding: 0;
  width: 28px;
  height: 28px;
  justify-content: center;
  border-radius: var(--lk-radius-md);
}

/* Estado activo (filtros, tabs) */
.btn.active {
  background: var(--lk-accent-dim);
  border-color: var(--lk-accent);
  color: var(--lk-accent);
}

/* Botones de acción pequeños (icono) */
.icon-act {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--lk-radius-sm);
  border: 1px solid var(--lk-border-default);
  background: transparent;
  color: var(--lk-text-secondary);
  cursor: pointer;
  font-size: 0.8125rem;
  line-height: 1;
  font-family: inherit;
  flex-shrink: 0;
  transition: background var(--lk-transition-fast),
              color var(--lk-transition-fast),
              border-color var(--lk-transition-fast);
}
.icon-act:hover    { background: var(--lk-bg-hover); color: var(--lk-text-primary); }
.icon-act-d        { color: var(--lk-danger-text); border-color: var(--lk-danger-dim); }
.icon-act-d:hover  { background: var(--lk-danger); color: #fff; border-color: var(--lk-danger); }

/* Inputs */
.lk-input, .inp {
  width: 100%;
  padding: var(--lk-space-2) var(--lk-space-3);
  background: var(--lk-bg-elevated);
  border: 1px solid var(--lk-border-default);
  border-radius: var(--lk-radius-md);
  color: var(--lk-text-primary);
  font-size: var(--lk-text-sm);
  transition: border-color var(--lk-transition-fast);
  outline: none;
  font-family: inherit;
}
.lk-input:focus, .inp:focus  { border-color: var(--lk-accent); }
.lk-input:hover, .inp:hover  { border-color: var(--lk-border-strong); }

.lk-select, select.inp {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239b9790' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: var(--lk-space-8);
  cursor: pointer;
}
select.inp option {
  background: var(--lk-bg-elevated);
  color: var(--lk-text-primary);
}

textarea.lk-input, textarea.inp {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

/* Labels */
.lk-label, .lbl {
  display: block;
  font-size: var(--lk-text-xs);
  font-weight: 500;
  color: var(--lk-text-secondary);
  margin-bottom: var(--lk-space-1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Ocultar spinners en inputs numéricos */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Tarjetas */
.lk-card {
  background: var(--lk-bg-surface);
  border: 1px solid var(--lk-border-subtle);
  border-radius: var(--lk-radius-lg);
  padding: var(--lk-space-5);
}
.lk-card-elevated {
  background: var(--lk-bg-elevated);
  border-color: var(--lk-border-default);
  box-shadow: var(--lk-shadow-sm);
}

/* Badges */
.lk-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--lk-space-1);
  padding: 2px var(--lk-space-2);
  border-radius: var(--lk-radius-full);
  font-size: var(--lk-text-xs);
  font-weight: 500;
  white-space: nowrap;
}
.lk-badge-accent  { background: var(--lk-accent-dim);   color: var(--lk-accent); }
.lk-badge-danger  { background: var(--lk-danger-dim);   color: var(--lk-danger-text); }
.lk-badge-success { background: var(--lk-success-dim);  color: var(--lk-success-text); }
.lk-badge-warning { background: var(--lk-warning-dim);  color: var(--lk-warning-text); }
.lk-badge-info    { background: var(--lk-info-dim);     color: var(--lk-info-text); }
.lk-badge-muted   { background: var(--lk-bg-hover);     color: var(--lk-text-secondary); }

/* Divisores */
.lk-divider {
  border: none;
  border-top: 1px solid var(--lk-border-subtle);
  margin: var(--lk-space-4) 0;
}

/* Paneles colapsables */
.lk-collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--lk-space-3) var(--lk-space-4);
  background: var(--lk-bg-elevated);
  border: 1px solid var(--lk-border-subtle);
  border-radius: var(--lk-radius-md);
  cursor: pointer;
  user-select: none;
  font-size: var(--lk-text-sm);
  font-weight: 500;
  transition: background var(--lk-transition-fast);
}
.lk-collapsible-header:hover { background: var(--lk-bg-hover); }
.lk-collapsible-header .lk-chevron {
  transition: transform var(--lk-transition-base);
}
.lk-collapsible-header.open .lk-chevron {
  transform: rotate(180deg);
}
.lk-collapsible-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--lk-transition-slow);
}
.lk-collapsible-body.open {
  max-height: 2000px;
}

/* Tabs */
.lk-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--lk-border-subtle);
  overflow-x: auto;
}
.lk-tab {
  padding: var(--lk-space-2) var(--lk-space-4);
  font-size: var(--lk-text-sm);
  font-weight: 500;
  color: var(--lk-text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--lk-transition-fast), border-color var(--lk-transition-fast);
  margin-bottom: -1px;
}
.lk-tab:hover  { color: var(--lk-text-primary); }
.lk-tab.active {
  color: var(--lk-accent);
  border-bottom-color: var(--lk-accent);
}

/* Barra de salud */
.lk-health-bar {
  width: 100%;
  height: 6px;
  background: var(--lk-bg-active);
  border-radius: var(--lk-radius-full);
  overflow: hidden;
}
.lk-health-bar-fill {
  height: 100%;
  border-radius: var(--lk-radius-full);
  transition: width var(--lk-transition-base), background-color var(--lk-transition-base);
}

/* Avatar circular de personaje */
.lk-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--lk-radius-full);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--lk-bg-active);
}
.lk-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lk-avatar-ring {
  position: absolute;
  inset: -3px;
  border-radius: var(--lk-radius-full);
  border: 3px solid var(--lk-health-high);
  pointer-events: none;
}

/* Spinner */
.lk-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--lk-border-default);
  border-top-color: var(--lk-accent);
  border-radius: var(--lk-radius-full);
  animation: lk-spin 0.7s linear infinite;
}
@keyframes lk-spin { to { transform: rotate(360deg); } }

/* Tooltips */
.lk-tooltip {
  position: relative;
}
.lk-tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--lk-bg-active);
  color: var(--lk-text-primary);
  font-size: var(--lk-text-xs);
  padding: var(--lk-space-1) var(--lk-space-2);
  border-radius: var(--lk-radius-sm);
  border: 1px solid var(--lk-border-default);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--lk-transition-fast);
  z-index: 100;
}
.lk-tooltip:hover::after { opacity: 1; }

/* ── Utilidades de layout ─────────────────────────────────── */
.lk-flex        { display: flex; }
.lk-flex-col    { display: flex; flex-direction: column; }
.lk-items-center   { align-items: center; }
.lk-justify-between{ justify-content: space-between; }
.lk-gap-1  { gap: var(--lk-space-1); }
.lk-gap-2  { gap: var(--lk-space-2); }
.lk-gap-3  { gap: var(--lk-space-3); }
.lk-gap-4  { gap: var(--lk-space-4); }
.lk-gap-6  { gap: var(--lk-space-6); }
.lk-w-full { width: 100%; }
.lk-hidden { display: none !important; }
.hidden    { display: none !important; }
.lk-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ── Estado de personaje muerto ───────────────────────────── */
.lk-char-dead {
  filter: grayscale(1);
  opacity: 0.5;
  pointer-events: none;
}
.lk-char-dead::after {
  content: 'CAÍDO';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--lk-text-lg);
  font-weight: 500;
  color: var(--lk-danger-text);
  letter-spacing: 0.2em;
  background: rgba(0,0,0,0.45);
  border-radius: inherit;
  pointer-events: none;
}

/* ── Animaciones de entrada ───────────────────────────────── */
@keyframes lk-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lk-fade-in { animation: lk-fade-in 200ms ease forwards; }

/* Fuentes cargadas desde el <head> del HTML */
