/* ═══════════════════════════════════════════════════════════════
 * ui-components.css — Componentes modernizados · Structura Pro 2026
 * v1.0 · 2026-05-23
 *
 * Reemplaza estilos viejos de buttons, cards, inputs, badges, modals
 * con look 2026 (microinteractions, transiciones suaves, shadows graduales).
 *
 * Depende de design-tokens.css.
 *
 * Uso:
 *   <link rel="stylesheet" href="/design-tokens.css?v=...">
 *   <link rel="stylesheet" href="/ui-components.css?v=...">
 * ═══════════════════════════════════════════════════════════════ */

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:active   { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* Primary · CTA principal */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-gold) 0%, var(--brand-gold-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { box-shadow: var(--shadow-md), var(--shadow-accent), inset 0 1px 0 rgba(255,255,255,.18); }

/* Secondary · acciones neutras */
.btn-secondary,
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover,
.btn-ghost:hover { background: var(--surface2); border-color: var(--border2); }

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-danger:hover { background: #d33731; }

/* Sizes */
.btn-sm { padding: 6px 12px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--text-md); }
.btn-block { width: 100%; }

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}
.card-hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border2);
}
.card-elevated {
  box-shadow: var(--shadow-md);
  border-color: transparent;
}
.card-accent {
  border-left: 3px solid var(--brand-gold);
}

/* ─── INPUTS ─────────────────────────────────────────────── */
.input,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="time"],
select,
textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.input:hover,
input:hover,
select:hover,
textarea:hover { border-color: var(--text3); }

.input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-gold);
  box-shadow: var(--shadow-focus);
}

textarea { resize: vertical; min-height: 80px; }

label {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── BADGES + PILLS ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.5;
  white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger);  }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info);    }
.badge-purple  { background: var(--color-purple-bg);  color: var(--color-purple);  }
.badge-neutral { background: var(--surface2);         color: var(--text2);          }

/* ─── MODALS modernos ────────────────────────────────────── */
/* #S2D2-B4-bug · DESACTIVADO 2026-06-06 · estas reglas competían con el sistema
   de modal de index.html (línea 1985) que usa transition + opacity.
   La animación modalFadeIn quedaba stuck en currentTime:0 → modal invisible
   permanente. El sistema en index.html funciona correctamente.
   Si se quiere reactivar, hay que migrar TODO el modal-system a animation
   en un solo lugar. */

/*
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(13,17,23,.65);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: none;
  animation: modalFadeIn var(--duration-fast) var(--ease-out);
}
.modal-bg.open { display: flex; }
.modal { animation: modalSlideUp var(--duration-normal) var(--ease-spring); }
@keyframes modalFadeIn { from {opacity:0} to {opacity:1} }
@keyframes modalSlideUp { ... }
*/

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text);
  margin-bottom: var(--space-xs);
}

/* ─── TOOLTIPS ───────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--brand-navy);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  z-index: var(--z-tooltip);
  pointer-events: none;
  animation: tooltipFadeIn var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-md);
}
@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to   { opacity: 1; transform: translate(-50%, 0);    }
}

/* ─── EMPTY STATES ───────────────────────────────────────── */
.empty-state {
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius-lg);
}
.empty-state .empty-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: var(--space-md);
  display: block;
}
.empty-state .empty-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text);
  margin-bottom: var(--space-xs);
}
.empty-state .empty-desc {
  font-size: var(--text-sm);
  color: var(--text3);
  max-width: 380px;
  margin: 0 auto var(--space-lg);
  line-height: var(--leading-normal);
}

/* ─── SKELETON LOADERS unificados ────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface2) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s var(--ease-in-out) infinite;
  border-radius: var(--radius-sm);
  display: block;
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 22px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); margin-bottom: var(--space-md); }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── DIVIDERS sutiles ───────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
  border: none;
}
.divider-strong { background: var(--border2); }

/* ─── TOAST notifications (mejor estilo) ─────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  padding: 12px 18px;
  color: var(--text);
  font-size: var(--text-sm);
  z-index: var(--z-toast);
  animation: toastSlideIn var(--duration-normal) var(--ease-spring);
  max-width: 340px;
}
.toast-success { border-left: 3px solid var(--color-success); }
.toast-danger  { border-left: 3px solid var(--color-danger);  }
.toast-info    { border-left: 3px solid var(--color-info);    }
@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── HOVER LIFT (utility) ───────────────────────────────── */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* ─── RESPONSIVE helpers ─────────────────────────────────── */
@media (max-width: 640px) {
  .modal { padding: var(--space-lg); border-radius: var(--radius-lg); }
  .btn { padding: 11px 16px; }
  .btn-lg { padding: 14px 22px; }
}

/* ─── ANIMACIONES de entrada para listas ────────────────── */
.fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out) backwards;
}
.fade-in:nth-child(1) { animation-delay: 0ms; }
.fade-in:nth-child(2) { animation-delay: 50ms; }
.fade-in:nth-child(3) { animation-delay: 100ms; }
.fade-in:nth-child(4) { animation-delay: 150ms; }
.fade-in:nth-child(5) { animation-delay: 200ms; }
.fade-in:nth-child(6) { animation-delay: 250ms; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);    }
}

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

/* Visually hidden pero accesible para screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
