/* Sistema visual compartido (tienda + panel): estilo mina, dibujo animado y minimalista.
   Contornos gruesos, sombras duras desplazadas y colores de gemas sobre roca oscura. */

:root {
  --bg: #14100d;
  --bg-2: #1b1511;
  --surface: #241c16;
  --surface-2: #2d231b;
  --surface-3: #382b21;
  --line: #45362a;
  --outline: #0a0705;
  --ink: #fff4e2;
  --ink-2: #d4c4ab;
  --ink-3: #9a8975;

  --gold: #ffc23d;
  --gold-2: #ffd970;
  --gold-dark: #b9790c;
  --emerald: #3ddc97;
  --emerald-dark: #179765;
  --diamond: #7fe4ff;
  --diamond-dark: #2a9ec2;
  --amethyst: #b88cff;
  --ruby: #ff5f6d;
  --ruby-dark: #b8303d;
  --copper: #e98a4f;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --stroke: 2.5px;
  --shadow-hard: 0 4px 0 var(--outline);
  --shadow-hard-lg: 0 6px 0 var(--outline);
  --font-display: 'Fredoka', 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--diamond);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.muted {
  color: var(--ink-2);
}

.faint {
  color: var(--ink-3);
}

.hidden {
  display: none !important;
}

/* ---------- Botones ---------- */

.btn {
  --btn-bg: var(--surface-3);
  --btn-ink: var(--ink);
  --btn-edge: var(--outline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: var(--stroke) solid var(--outline);
  border-radius: 14px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--btn-edge);
  transform: translateY(0);
  transition: transform 0.12s var(--ease-bounce), box-shadow 0.12s, filter 0.15s;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--btn-edge);
  text-decoration: none;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-edge);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  cursor: not-allowed;
  filter: grayscale(1) brightness(0.7);
  transform: none;
  box-shadow: 0 4px 0 var(--btn-edge);
}

.btn-gold {
  --btn-bg: var(--gold);
  --btn-ink: #2a1a02;
}

.btn-emerald {
  --btn-bg: var(--emerald);
  --btn-ink: #062417;
}

.btn-diamond {
  --btn-bg: var(--diamond);
  --btn-ink: #062430;
}

.btn-danger {
  --btn-bg: var(--ruby);
  --btn-ink: #2b0408;
}

.btn-ghost {
  --btn-bg: transparent;
  box-shadow: none;
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--surface-2);
  box-shadow: none;
}

.btn-ghost:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.9rem;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: var(--stroke) solid var(--line);
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-2);
}

/* ---------- Formularios ---------- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span,
.label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

.hint {
  font-size: 0.82rem;
  color: var(--ink-3);
}

.input,
select.input,
textarea.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: var(--stroke) solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.input {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 194, 61, 0.18);
}

.input::placeholder {
  color: var(--ink-3);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

.form-error {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--ruby-dark);
  background: rgba(255, 95, 109, 0.12);
  color: #ffc3c8;
  font-weight: 600;
  font-size: 0.92rem;
}

/* ---------- Tarjetas, insignias ---------- */

.card {
  background: var(--surface);
  border: var(--stroke) solid var(--outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard-lg);
}

.panel {
  background: var(--surface);
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 2px solid var(--outline);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--ink);
}

.badge-gold {
  background: var(--gold);
  color: #2a1a02;
}

.badge-emerald {
  background: var(--emerald);
  color: #062417;
}

.badge-diamond {
  background: var(--diamond);
  color: #062430;
}

.badge-ruby {
  background: var(--ruby);
  color: #2b0408;
}

.badge-amethyst {
  background: var(--amethyst);
  color: #1d0b3a;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 25%, transparent);
}

.text-emerald {
  color: var(--emerald);
}

.text-ruby {
  color: var(--ruby);
}

.text-gold {
  color: var(--gold);
}

.text-diamond {
  color: var(--diamond);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 5, 3, 0.72);
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease-out;
}

.modal {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 26px;
  background: var(--surface);
  border: var(--stroke) solid var(--outline);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 0 var(--outline), 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop-in 0.32s var(--ease-bounce);
}

.modal-wide {
  width: min(760px, 100%);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.modal h2 {
  font-size: 1.45rem;
  margin-bottom: 6px;
  padding-right: 44px;
}

.modal-backdrop.closing {
  animation: fade-out 0.16s ease-in forwards;
}

.modal-backdrop.closing .modal {
  animation: pop-out 0.16s ease-in forwards;
}

/* ---------- Avisos (toasts) ---------- */

.toasts {
  position: fixed;
  z-index: 200;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: var(--stroke) solid var(--outline);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow-hard);
  font-weight: 600;
  animation: toast-in 0.35s var(--ease-bounce);
}

.toast.success {
  border-left: 8px solid var(--emerald);
}

.toast.error {
  border-left: 8px solid var(--ruby);
}

.toast.info {
  border-left: 8px solid var(--diamond);
}

.toast.leaving {
  animation: toast-out 0.25s ease-in forwards;
}

/* ---------- Tablas / listas ---------- */

.table-wrap {
  overflow-x: auto;
  border: var(--stroke) solid var(--line);
  border-radius: var(--radius);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--bg-2);
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-2);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}

/* ---------- Animaciones base ---------- */

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
}

@keyframes pop-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.9);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
