/* Controles del rediseño: formularios, SearchInput, botones, pestañas, toast, diálogos y estados vacío/carga/error. */
/* =====================================================================================
   Componentes del rediseño (sobrescriben los estilos de módulo anteriores)
   ===================================================================================== */

/* ---------- Formularios y SearchInput ---------- */
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  font: inherit; font-size: var(--fs-body); color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-field); padding: 9px 12px; min-height: 40px; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text-muted) 45%, var(--border)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--text); font-weight: 500; }
label.inline { flex-direction: row; align-items: center; gap: var(--s2); color: var(--text-muted); }
label.check { flex-direction: row; align-items: center; gap: var(--s2); color: var(--text); font-size: var(--fs-body); font-weight: 400; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue); }
.help { font-size: var(--fs-label); color: var(--text-muted); font-weight: 400; }
.search { position: relative; flex: 1; min-width: 220px; display: flex; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search input { width: 100%; padding-left: 38px; }

/* ---------- Botones ---------- */
.btn { font: inherit; font-weight: 600; font-size: var(--fs-body); display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 8px 16px; border-radius: var(--r-btn); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, filter .15s; }
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--blue); color: var(--accent-contrast); border-color: var(--blue); }
.btn.primary:hover:not(:disabled) { background: var(--blue); filter: brightness(1.08); }
.btn.navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--sev-critical-ink); }
.btn.danger.solid { background: var(--sev-critical); border-color: var(--sev-critical); color: #fff; }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: var(--fs-sm); }
.btn.big { min-height: 46px; padding: 10px 20px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--r-btn);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.menu-btn { display: none; }
.sidebar .brand-logo { height: 30px; }
a.btn { display: inline-flex; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.tabs button { font: inherit; font-weight: 600; border: 0; background: none; color: var(--text-muted); padding: 7px 14px; border-radius: var(--r-btn); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; min-height: 36px; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- ToastNotification ---------- */
.toast { position: fixed; bottom: 24px; right: 24px; display: flex; align-items: center; gap: var(--s2); background: var(--navy); color: #fff;
  padding: 12px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow-lg); max-width: min(440px, calc(100vw - 32px)); }

/* ---------- ConfirmationDialog y Ayuda ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 70; display: flex; align-items: center; justify-content: center; padding: var(--s4); }
.dialog { background: var(--surface); color: var(--text); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(480px, 100%); padding: var(--s6); border: 1px solid var(--border); }
.dialog.wide { width: min(760px, 100%); max-height: calc(100vh - 48px); overflow: auto; }
.dialog-head { display: flex; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s3); }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-ico { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  background: color-mix(in srgb, var(--sev-critical) 12%, transparent); color: var(--sev-critical-ink); }
.dialog-ico.info { background: var(--blue-soft); color: var(--blue); }
.dialog p { margin: 0 0 var(--s3); color: var(--text-muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s6); flex-wrap: wrap; }
.help-body h3 { margin-top: var(--s6); }
.help-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.help-body dt { font-weight: 600; }
.help-body dd { margin: 0; color: var(--text-muted); }

/* ---------- EmptyState · LoadingState · ErrorState ---------- */
.empty { text-align: center; padding: var(--s12) var(--s6); display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.empty-ico { width: 56px; height: 56px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; background: var(--blue-soft); color: var(--blue); margin-bottom: var(--s2); }
.empty-ico .icon svg { width: 26px; height: 26px; }
.empty h2, .empty h3 { margin: 0; font-size: 18px; }
.empty p { margin: 0; color: var(--text-muted); max-width: 56ch; }
.empty-actions { display: flex; gap: var(--s2); justify-content: center; flex-wrap: wrap; margin-top: var(--s3); }
.empty-logo { height: 80px; width: auto; display: block; margin: 0 auto var(--s3); }
.empty-inline { text-align: center; padding: var(--s6) var(--s2); }
.error-state { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); border-radius: var(--r-card);
  background: color-mix(in srgb, var(--sev-critical) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--sev-critical) 30%, var(--border)); margin-bottom: var(--s4); }
.error-state .icon { color: var(--sev-critical-ink); margin-top: 2px; }
.error-state strong { display: block; }
.error-state p { margin: 2px 0 var(--s2); color: var(--text-muted); }
.error { color: var(--sev-critical-ink); width: 100%; margin: 0; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in srgb, var(--surface-2) 40%, var(--surface)) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 8px; }
.skeleton.line { height: 14px; margin: 8px 0; } .skeleton.block { height: 96px; } .skeleton.kpi-sk { height: 120px; border-radius: var(--r-card); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading { display: flex; align-items: center; gap: var(--s2); color: var(--text-muted); padding: var(--s4) 0; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spin svg { animation: none; } * { transition: none !important; } }

/* ---------- Banner ---------- */
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-card); margin-bottom: var(--s4); }
.banner.warn { background: color-mix(in srgb, var(--sev-medium) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--sev-medium) 45%, var(--border)); }
.banner.info { background: var(--blue-soft); border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--border)); }
label.btn { flex-direction: row; align-items: center; color: inherit; font-size: var(--fs-body); }
label.btn.primary { color: var(--accent-contrast); }
