/* ============================================================================
   COMPONENTES
   ============================================================================ */

/* ---------------- BOTONES ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all .15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--brand);
  color: var(--brand-text);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) { background: var(--brand-2); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }

.btn--danger {
  background: var(--danger);
  color: white;
}
.btn--danger:hover:not(:disabled) { filter: brightness(0.95); }

.btn--sm { padding: 6px 12px; font-size: 0.8rem; }
.btn--icon { padding: 8px; }

/* ---------------- TARJETAS ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: all .2s ease;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card__title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.card__action { color: var(--text-muted); font-size: 0.8rem; }
.card__action:hover { color: var(--brand); }

/* ---------------- KPI CARD ---------------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: all .2s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }

.kpi__label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 8px;
}
.kpi__value {
  font-family: 'Manrope', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
.kpi__sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 0.7rem;
}
.kpi__delta--up   { color: var(--success); background: var(--success-soft); }
.kpi__delta--down { color: var(--danger);  background: var(--danger-soft); }

.kpi__icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid; place-items: center;
}
:root[data-theme="dark"] .kpi__icon { color: var(--brand-2); }
.kpi__icon svg { width: 17px; height: 17px; }

/* Acento lateral por tipo */
.kpi--success::before, .kpi--danger::before, .kpi--warning::before, .kpi--info::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.kpi--success::before { background: var(--success); }
.kpi--danger::before  { background: var(--danger); }
.kpi--warning::before { background: var(--warning); }
.kpi--info::before    { background: var(--brand); }

/* ---------------- TABLAS ---------------- */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- INPUTS ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.9rem;
  color: var(--text);
  transition: all .15s ease;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder { color: var(--text-dim); }

/* ---------------- BADGES ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge--success { color: var(--success); background: var(--success-soft); }
.badge--danger  { color: var(--danger);  background: var(--danger-soft); }
.badge--warning { color: var(--warning); background: var(--warning-soft); }
.badge--info    { color: var(--brand);   background: var(--brand-soft); }
.badge--neutral { color: var(--text-muted); background: var(--surface-3); }

/* ---------------- MODAL ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 14, 24, 0.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in .25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal__title { font-size: 1.1rem; font-weight: 700; }
.modal__close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-muted);
}
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal__body { display: grid; gap: 14px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------------- TOASTS ---------------- */
.toast-container {
  position: fixed; top: 80px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  font-size: 0.875rem;
  animation: toast-in .25s ease;
  pointer-events: auto;
}
.toast--success { border-left-color: var(--success); }
.toast--danger  { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------------- SPINNER ---------------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- EMPTY STATE ---------------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* ---------------- THEME TOGGLE ---------------- */
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all .15s ease;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

/* ---------------- PROGRESS BAR ---------------- */
.progress {
  height: 8px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 99px;
  transition: width .5s ease;
}

/* ---------------- LOGIN ---------------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(1200px 400px at 80% -10%, var(--brand-soft) 0%, transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-card__brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
}
.login-card h2 { margin-bottom: 6px; }
.login-card p { color: var(--text-muted); margin-bottom: 24px; font-size: 0.875rem; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn--primary { width: 100%; justify-content: center; }
