/* =============================================================================
   components.css — tarjetas, tablas, formularios, botones, modales, avisos
   ============================================================================= */

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-head {
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.card-body { padding: 1.1rem; }
.card-body.tight { padding: .75rem; }

/* Tarjeta de indicador (KPI) */
.kpi { padding: 1.1rem; }
.kpi .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
              color: var(--text-muted); }
.kpi .value { font-size: 1.9rem; font-weight: 700; margin-top: .3rem;
              font-variant-numeric: tabular-nums; }
.kpi .hint  { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }
.kpi.accent { border-left: 4px solid var(--primary); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .55rem .95rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-sm { padding: .35rem .6rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* Botones de la barra lateral (fondo oscuro) */
.sidebar .btn {
  background: var(--bg-2);
  border-color: var(--border-dark);
  color: var(--text-invert);
}
.sidebar .btn:hover { background: var(--bg-3); }

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

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.field .help { font-size: .76rem; color: var(--text-muted); }

.input, .select, .textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgb(37 99 235 / .12);
}
.textarea { min-height: 84px; resize: vertical; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.radio-row { display: flex; gap: 1rem; }
.radio-row label { display: flex; align-items: center; gap: .35rem;
                   font-weight: 500; color: var(--text); }

.switch { display: flex; align-items: center; gap: .5rem; }

/* ---------- Selector de color (paleta fija) ---------- */

.palette { display: flex; gap: .5rem; flex-wrap: wrap; }

.palette button {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px rgb(15 23 42 / .1);
}
.palette button[aria-pressed="true"] {
  border-color: var(--text);
  transform: scale(1.06);
}

/* ---------- Selector de icono ---------- */

.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .35rem; }
.icon-grid button {
  aspect-ratio: 1;
  font-size: 1.15rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
}
.icon-grid button[aria-pressed="true"] {
  border-color: var(--primary);
  background: rgb(37 99 235 / .08);
}

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

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: .89rem; }
table.data th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Etiquetas de estado ---------- */

.tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.tag.ok      { background: #dcfce7; border-color: #86efac; color: #15803d; }
.tag.warn    { background: #fef3c7; border-color: #fcd34d; color: #a16207; }
.tag.danger  { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.tag.info    { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }

/* ---------- Estados vacíos y avisos ---------- */

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}
.empty .big { font-size: 2rem; margin-bottom: .5rem; }

.notice {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: .88rem;
}
.notice.info   { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.notice.warn   { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.notice.danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

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

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgb(15 23 42 / .55);
  display: grid; place-items: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(520px, 100%);
  max-height: 85vh;
  display: flex; flex-direction: column;
}
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot {
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .6rem;
}

/* ---------- Avisos flotantes ---------- */

.toast-stack {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 200; pointer-events: none;
}

.toast {
  background: var(--bg);
  color: #fff;
  padding: .7rem 1.1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .9rem;
  font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
  animation: toast-in .18s ease-out;
}
.toast.ok     { background: var(--success); }
.toast.err    { background: var(--danger); }
.toast.warn   { background: var(--warning); }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
