/* ═══════════════════════════════════════════════════════════════
   PDLJ v2 — Base / Reset / Utilidades globales
   ═══════════════════════════════════════════════════════════════ */
@import url('tokens.css');

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100dvh;
  transition: background var(--dur-base), color var(--dur-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--r-full); }

/* ── Tipografía ── */
h1, h2, h3, h4, h5 {
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--text-primary);
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { color: var(--text-secondary); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

small { font-size: var(--text-xs); color: var(--text-muted); }
strong { font-weight: 700; color: var(--text-primary); }
code { font-family: var(--font-mono); font-size: .875em; background: var(--bg-muted); padding: 2px 5px; border-radius: 4px; }

/* ── Imágenes ── */
img, svg { display: block; max-width: 100%; }

/* ── Formularios base ── */
input, textarea, select, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea, select { outline: none; }

/* ── Focus visible accesible ── */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ── Separador ── */
hr { border: none; border-top: 1px solid var(--border); }

/* ══════════════════════════════════════════
   LAYOUT HELPERS
   ══════════════════════════════════════════ */
.container {
  width: 100%;
  max-width: 480px;      /* Mobile-first max */
  margin: 0 auto;
  padding: 0 var(--sp-4);
}
@media (min-width: 768px) {
  .container { max-width: 720px; }
}
@media (min-width: 1024px) {
  .container { max-width: 1024px; }
}

.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.overflow-hidden { overflow: hidden; }

/* ══════════════════════════════════════════
   COMPONENTES BASE
   ══════════════════════════════════════════ */

/* Card */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.card-body { padding: var(--sp-5) var(--sp-5); }
.card-sm .card-body { padding: var(--sp-4); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--r-full);
  white-space: nowrap;
}
.badge-brand   { background: var(--brand-soft);   color: var(--brand);   border: 1px solid var(--brand-border); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--bg-muted); color: var(--text-secondary); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--r-lg);
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.btn:disabled { opacity: .45; pointer-events: none; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--brand-500);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(99,102,241,0);
}
.btn-primary:hover {
  background: var(--brand-600);
  box-shadow: 0 4px 20px rgba(99,102,241,.35);
}
.btn-ghost {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(248,113,113,.25); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: var(--text-xs); border-radius: var(--r-md); }
.btn-lg { padding: 14px 24px; font-size: var(--text-base); border-radius: var(--r-xl); }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--r-md); }

/* Inputs */
.input {
  width: 100%;
  padding: 11px 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-overlay);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast);
}
.input::placeholder { color: var(--text-muted); }
.input:focus { border-color: var(--brand-400); background: var(--bg-raised); }
.input-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.input-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.input-error { font-size: var(--text-xs); color: var(--danger); margin-top: 2px; }

/* Avatar */
.avatar {
  border-radius: var(--r-full);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-muted);
}
.avatar-sm  { width: 28px; height: 28px; }
.avatar-md  { width: 36px; height: 36px; }
.avatar-lg  { width: 48px; height: 48px; }
.avatar-xl  { width: 64px; height: 64px; }
.avatar-ini {
  border-radius: var(--r-full);
  background: var(--brand-soft);
  border: 1.5px solid var(--brand-border);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

/* Divider with text */
.divider {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text-muted); font-size: var(--text-xs);
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast / Alert */
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
}
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border: 1px solid rgba(248,113,113,.2); }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(74,222,128,.2); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(251,191,36,.2); }

/* Text utilities */
.text-xs  { font-size: var(--text-xs); }
.text-sm  { font-size: var(--text-sm); }
.text-lg  { font-size: var(--text-lg); }
.text-xl  { font-size: var(--text-xl); }
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-brand     { color: var(--brand); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fw-900 { font-weight: 900; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Spacing */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.p-4  { padding: var(--sp-4); }
.p-5  { padding: var(--sp-5); }
.p-6  { padding: var(--sp-6); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }

/* Hidden */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
