/**
 * CSS Modules — Components
 * Buttons, Badges, Toasts, Modals, Tooltips, Dropdowns
 * Check Pro v12.44.782 — Minimalista Premium
 */

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 8px 16px; font-size: var(--text-sm); font-weight: 500;
  border-radius: var(--radius-md); border: 1px solid transparent;
  transition: all var(--duration-normal) var(--ease);
  white-space: nowrap; user-select: none;
  min-height: 36px; line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .material-symbols-outlined { font-size: 18px; }

/* Primary */
.btn-primary {
  background: var(--accent); color: var(--text-inverse); border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

/* Secondary / Ghost */
.btn-secondary {
  background: var(--bg-card); color: var(--text-primary); border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

/* Ghost */
.btn-ghost {
  background: transparent; color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Danger */
.btn-danger {
  background: var(--error); color: #fff; border-color: var(--error);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

/* Sizes */
.btn-sm { padding: 4px 10px; font-size: var(--text-xs); min-height: 28px; border-radius: var(--radius-sm); }
.btn-lg { padding: 10px 20px; font-size: var(--text-base); min-height: 44px; border-radius: var(--radius-lg); }
.btn-icon { padding: 8px; min-width: 36px; }
.btn-icon.btn-sm { padding: 4px; min-width: 28px; }
.btn-icon.btn-lg { padding: 10px; min-width: 44px; }

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: var(--text-xs); font-weight: 500;
  border-radius: var(--radius-full); white-space: nowrap;
}
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-elevated); color: var(--text-secondary); }

.badge-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.badge-dot-accent { background: var(--accent); }
.badge-dot-success { background: var(--success); }
.badge-dot-warning { background: var(--warning); }
.badge-dot-error { background: var(--error); }

/* Status pulse */
.badge-pulse { position: relative; }
.badge-pulse::before {
  content: ''; position: absolute; inset: -2px;
  border-radius: var(--radius-full); opacity: 0.4;
  animation: pulse 2s var(--ease) infinite;
}
.badge-pulse.badge-success::before { background: var(--success); }
.badge-pulse.badge-warning::before { background: var(--warning); }
.badge-pulse.badge-error::before { background: var(--error); }

/* ═══ TOASTS ═══ */
.toast-container {
  position: fixed; bottom: var(--space-6); right: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: var(--z-toast); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); min-width: 300px; max-width: 420px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: slideInRight var(--duration-slow) var(--ease-out);
  pointer-events: auto;
}
.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: 2px; }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.4; }
.toast-close {
  padding: 2px; color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius-sm); transition: color var(--duration-fast);
}
.toast-close:hover { color: var(--text-primary); }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }

/* ═══ MODALS ═══ */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--bg-modal); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); animation: fadeIn var(--duration-normal) var(--ease);
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  animation: scaleIn var(--duration-slow) var(--ease-spring);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: var(--text-lg); font-weight: 600; }
.modal-close {
  padding: var(--space-1); color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius-sm); transition: all var(--duration-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: var(--space-6); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border);
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

/* ═══ TOOLTIPS ═══ */
.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); padding: 4px 8px;
  background: var(--text-primary); color: var(--text-inverse);
  font-size: var(--text-xs); font-weight: 500;
  border-radius: var(--radius-sm); white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease);
  z-index: var(--z-tooltip);
}
.tooltip:hover::after { opacity: 1; }

/* ═══ DROPDOWNS ═══ */
.dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 180px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: var(--z-dropdown);
  animation: fadeInDown var(--duration-normal) var(--ease-out);
  padding: var(--space-1);
}
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 8px 12px; font-size: var(--text-sm); color: var(--text-secondary);
  border-radius: var(--radius-md); cursor: pointer;
  transition: all var(--duration-fast);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.active { background: var(--accent-light); color: var(--accent); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--space-1) 0; }

/* ═══ CARDS ═══ */
.card {
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-lg); transition: all var(--duration-normal) var(--ease);
}
.card-hover:hover { border-color: var(--border-hover); box-shadow: var(--shadow-sm); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.card-body { padding: var(--space-5); }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border);
}

/* ═══ PROGRESS ═══ */
.progress { height: 4px; background: var(--bg-elevated); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: var(--radius-full); transition: width var(--duration-slow) var(--ease); }

/* ═══ AVATARS ═══ */
.avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); font-weight: 600;
  background: var(--accent-light); color: var(--accent); flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }

/* ═══ DIVIDERS ═══ */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }

/* ═══ TAGS ═══ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: var(--text-xs); font-weight: 500;
  background: var(--bg-elevated); color: var(--text-secondary);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}

/* ═══ STAT CARDS ═══ */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-lg); padding: var(--space-5);
}
.stat-card-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-2); }
.stat-card-value { font-size: var(--text-3xl); font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: var(--space-1); }
.stat-card-change { font-size: var(--text-xs); font-weight: 500; }
.stat-card-change.positive { color: var(--success); }
.stat-card-change.negative { color: var(--error); }

/* ═══ TABS ═══ */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tab {
  padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: all var(--duration-fast); cursor: pointer;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ═══ CHIP / FILTER ═══ */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; font-size: var(--text-xs); font-weight: 500;
  border-radius: var(--radius-full); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--duration-fast);
}
.chip:hover { border-color: var(--border-hover); color: var(--text-primary); }
.chip.active { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   F-UX UNIFICACIÓN (v12.44.787)
   El markup usa variantes btn-* SIN la clase base .btn → cada variante
   lleva ahora su propia base. Además se formalizan clases que el
   markup consumía y que nunca fueron definidas.
   ══════════════════════════════════════════════════════════════ */

/* Base compartida para TODAS las variantes (con o sin .btn) */
.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 8px 16px; min-height: 36px;
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-lg);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all var(--duration-fast) var(--ease);
}
.btn:disabled, .btn-primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.08); }

/* Tamaños semánticos usados en el markup */
.btn-standard { padding: 8px 14px; font-size: var(--text-sm); min-height: 38px; }
.btn-xl { padding: 12px 24px; font-size: var(--text-base); min-height: 48px; border-radius: var(--radius-xl); }
.btn-py2 { padding-top: 6px; padding-bottom: 6px; }
.btn-py3 { padding-top: 9px; padding-bottom: 9px; }
.btn-py4 { padding-top: 12px; padding-bottom: 12px; }
.btn-px4 { padding-left: 16px; padding-right: 16px; }
.btn-px5 { padding-left: 20px; padding-right: 20px; }
.btn-px6 { padding-left: 24px; padding-right: 24px; }
.btn-row { display: flex; gap: var(--space-3); align-items: center; }

/* Barra de acciones de las cabeceras de sección */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-xl); margin-bottom: var(--space-4);
}
.action-bar-group { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* Cabeceras sticky de sección */
.sticky-header { position: sticky; top: 0; z-index: 20; background: var(--bg-app); padding-bottom: var(--space-2); }
.sticky-header-container { position: sticky; top: 0; z-index: 20; background: var(--bg-app); }
.sticky-header-custom { top: 8px; }

/* Títulos de sección */
.section-title { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.section-subtitle { font-size: var(--text-sm); color: var(--text-muted); }

/* Tabs secundarias (config / sistema) */
.sub-nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  transition: all var(--duration-fast) var(--ease); white-space: nowrap;
}
.sub-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sub-nav-btn.active { background: var(--accent-light); color: var(--accent); border-color: rgba(16,185,129,0.25); }

/* Inputs select genéricos de filtro */
.filter-select, .form-select {
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 8px 12px; font-size: var(--text-sm);
}

/* Contenedor de tabs de configuración/sistema: una fila, scroll horizontal */
.config-tabs, .system-tabs {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; flex-wrap: nowrap;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
}
.config-tabs .sub-nav-btn, .system-tabs .sub-nav-btn { flex-shrink: 0; }

/* ═══ MENÚ DE SECCIONES AGRUPADO (F-UX v12.44.789) ═══ */
.tabs-groups {
  display: flex; align-items: center; gap: var(--space-1);
  flex-wrap: wrap; margin-bottom: var(--space-2);
  padding: var(--space-1); background: var(--bg-card);
  border: 1px solid var(--border-card); border-radius: var(--radius-xl);
}
.tabs-group-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
  background: transparent; border: none; cursor: pointer;
  transition: all var(--duration-fast) var(--ease); white-space: nowrap;
}
.tabs-group-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tabs-group-btn.active { background: var(--accent-light); color: var(--accent); }
.tabs-children-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: var(--space-2) var(--space-1);
}
.tabs-children-row.hidden { display: none; }

/* ═══ MÓVIL: Touch targets + Bottom-sheet modales + Safe area (Fase Responsive 12.44.798) ═══ */
@media (max-width: 640px) {
  .btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success,
  .sub-nav-btn, .tabs-group-btn, .chip, .tab {
    min-height: 44px; min-width: 44px;
  }
  .btn-icon { min-width: 44px; min-height: 44px; }
  .modal { position: fixed; bottom: 0; left: 0; right: 0; top: auto; max-width: 100%; max-height: 85vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; margin: 0; }
  .modal-overlay { align-items: flex-end; padding: 0; padding-bottom: env(safe-area-inset-bottom); }
  .card.max-w-md, .card.max-w-lg { max-width: 100%; margin-left: 0; margin-right: 0; }
}
@media (max-width: 768px) {
  .toast-container { left: var(--space-3); right: var(--space-3); bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); }
}
