/* ============================================================================
 * components.css — DEMO v2 · UI components (Cofoundy)
 * ----------------------------------------------------------------------------
 * All class names from v1 preserved (JS contracts). Visual layer rebuilt
 * with refined typography, glass surfaces, brand color system.
 * ============================================================================ */

/* ============================================================================
 * BADGE — etiquetas de estado, tier, canal
 * ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Tier variants */
.badge--tier-a {
  background: rgba(139, 92, 246, 0.14);
  color: #C4B5FD;
  border-color: rgba(139, 92, 246, 0.32);
}
.badge--tier-b {
  background: rgba(70, 160, 208, 0.14);
  color: var(--cofoundy-primary-hi);
  border-color: rgba(70, 160, 208, 0.32);
}
.badge--tier-c {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.32);
}

/* Status variants (morosidad) */
.badge--status-regular {
  background: rgba(16, 185, 129, 0.14);
  color: #34D399;
  border-color: rgba(16, 185, 129, 0.32);
}
.badge--status-amarillo {
  background: rgba(245, 158, 11, 0.14);
  color: #FBBF24;
  border-color: rgba(245, 158, 11, 0.32);
}
.badge--status-rojo {
  background: rgba(239, 68, 68, 0.14);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.32);
}

/* With dot prefix */
.badge--status-regular::before,
.badge--status-amarillo::before,
.badge--status-rojo::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Channel variants */
.badge--whatsapp {
  background: rgba(37, 211, 102, 0.12);
  color: var(--channel-whatsapp);
  border-color: rgba(37, 211, 102, 0.32);
}
.badge--email {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.28);
}

/* Decision variants */
.badge--accepted {
  background: rgba(16, 185, 129, 0.14);
  color: #34D399;
  border-color: rgba(16, 185, 129, 0.32);
}
.badge--rejected {
  background: rgba(239, 68, 68, 0.14);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.32);
}
.badge--pending {
  background: rgba(245, 158, 11, 0.14);
  color: #FBBF24;
  border-color: rgba(245, 158, 11, 0.32);
}

/* Soft / outline variants */
.badge--soft {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-accent);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-mono);
  font-weight: 500;
}

.badge--lg {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
}

/* ============================================================================
 * CARD
 * ============================================================================ */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  transition: border-color var(--t-base), background var(--t-base), transform var(--t-base), box-shadow var(--t-base);
  position: relative;
}

.card--elevated {
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-elevated);
}

.card--clickable { cursor: pointer; }
.card--clickable:hover {
  border-color: rgba(70, 160, 208, 0.32);
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
}

.card--accent {
  position: relative;
  overflow: hidden;
}
.card--accent::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--cofoundy-primary), var(--cofoundy-primary-lo));
}

.card--success::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--status-regular); }
.card--warning::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--status-amarillo); }
.card--danger::before  { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--status-rojo); }
.card--success, .card--warning, .card--danger { position: relative; overflow: hidden; }

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.card__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.card__body {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
}

.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================================
 * BTN
 * ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(180deg, var(--cofoundy-primary-hi), var(--cofoundy-primary));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 4px 12px rgba(70, 160, 208, 0.28);
}
.btn--primary:hover {
  background: linear-gradient(180deg, var(--cofoundy-primary), var(--cofoundy-primary-lo));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 6px 20px rgba(70, 160, 208, 0.4);
  color: #fff;
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-accent);
}
.btn--secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-muted);
}

.btn--success {
  background: linear-gradient(180deg, #34D399, var(--status-regular));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 4px 12px rgba(16, 185, 129, 0.28);
}
.btn--success:hover { filter: brightness(1.06); color: #fff; }

.btn--danger {
  background: linear-gradient(180deg, #F87171, var(--status-rojo));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 4px 12px rgba(239, 68, 68, 0.28);
}
.btn--danger:hover { filter: brightness(1.06); color: #fff; }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.btn--sm { padding: 6px var(--space-3); font-size: var(--fs-xs); }
.btn--lg { padding: 12px var(--space-5); font-size: var(--fs-md); }
.btn--block { width: 100%; }

/* Icon-only variant */
.btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

/* ============================================================================
 * TABLE
 * ============================================================================ */
.table-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table thead th {
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-weight: 600;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 10px;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-strong);
}

.table tbody td {
  padding: var(--space-4);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.table--striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.012);
}
.table--striped tbody tr:nth-child(even):hover {
  background: rgba(255, 255, 255, 0.035);
}

.table .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  letter-spacing: -0.01em;
}

.table tr.is-active {
  background: rgba(70, 160, 208, 0.08);
}

/* ============================================================================
 * MODAL
 * ============================================================================ */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 11, 27, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  padding: var(--space-5);
  animation: fadeIn var(--t-base);
}

.modal.modal--open { display: flex; }

.modal__dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn var(--t-slow);
}

.modal__dialog--lg { max-width: 760px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.modal__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.modal__close {
  background: transparent;
  border: 1px solid var(--border-accent);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.modal__close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.modal__body {
  padding: var(--space-5);
  color: var(--text-secondary);
  line-height: var(--lh-loose);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ============================================================================
 * TOAST
 * ============================================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-4));
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: rgba(10, 20, 38, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--cofoundy-primary);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  font-size: var(--fs-sm);
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  animation: toastIn var(--t-slow), toastOut var(--t-slow) 4s forwards;
  pointer-events: auto;
}

.toast--success { border-left-color: var(--status-regular); }
.toast--warning { border-left-color: var(--status-amarillo); }
.toast--danger  { border-left-color: var(--status-rojo); }
.toast--info    { border-left-color: var(--cofoundy-primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ============================================================================
 * INPUT / SELECT / TEXTAREA
 * ============================================================================ */
.input, .select, .textarea {
  display: block;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px var(--space-3);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.5;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}

.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--cofoundy-primary);
  background: rgba(70, 160, 208, 0.06);
  box-shadow: 0 0 0 3px rgba(70, 160, 208, 0.18);
}

.textarea { resize: vertical; min-height: 88px; font-family: inherit; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%2394a3b8'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-7);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}

/* ============================================================================
 * TABS
 * ============================================================================ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-strong);
  margin-bottom: var(--space-5);
  padding: 0 var(--space-1);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
  margin-bottom: -1px;
  letter-spacing: -0.005em;
}

.tab:hover { color: var(--text-primary); }

.tab--active {
  color: var(--cofoundy-primary-hi);
  border-bottom-color: var(--cofoundy-primary);
}

.tab__count {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tab--active .tab__count {
  background: rgba(70, 160, 208, 0.2);
  color: var(--cofoundy-primary-hi);
}

/* ============================================================================
 * KPI CARD — número grande + label + sparkline (legacy class, kept)
 * ============================================================================ */
.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.kpi-card__label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tighter);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.kpi-card__unit {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-card__delta {
  font-size: var(--fs-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.kpi-card__delta--up   { color: var(--status-regular); }
.kpi-card__delta--down { color: var(--status-rojo); }

.kpi-card__meta {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin-top: var(--space-1);
}

.kpi-card__sparkline {
  margin-top: var(--space-3);
  height: 40px;
}

.kpi-card--success { border-top: 3px solid var(--status-regular); }
.kpi-card--warning { border-top: 3px solid var(--status-amarillo); }
.kpi-card--danger  { border-top: 3px solid var(--status-rojo); }
.kpi-card--info    { border-top: 3px solid var(--cofoundy-primary); }

/* ============================================================================
 * PROGRESS BAR
 * ============================================================================ */
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cofoundy-primary), var(--cofoundy-primary-hi));
  border-radius: var(--radius-pill);
  transition: width var(--t-slow);
  box-shadow: 0 0 8px rgba(70, 160, 208, 0.4);
}

.progress-bar__fill--success { background: linear-gradient(90deg, var(--status-regular), #34D399); box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }
.progress-bar__fill--warning { background: linear-gradient(90deg, var(--status-amarillo), #FBBF24); box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.progress-bar__fill--danger  { background: linear-gradient(90deg, var(--status-rojo), #F87171); box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }

/* ============================================================================
 * SPARKLINE
 * ============================================================================ */
.sparkline { width: 100%; height: 100%; display: block; }
.sparkline__line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline__area { opacity: 0.18; }

/* ============================================================================
 * AVATAR
 * ============================================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cofoundy-primary), var(--cofoundy-deep));
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(70, 160, 208, 0.25);
}

.avatar--sm { width: 28px; height: 28px; font-size: 10px; }
.avatar--lg { width: 48px; height: 48px; font-size: var(--fs-md); }

/* ============================================================================
 * DIVIDER
 * ============================================================================ */
.divider {
  height: 1px;
  background: var(--border-subtle);
  border: none;
  margin: var(--space-4) 0;
}

/* ============================================================================
 * EMPTY STATE
 * ============================================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-9) var(--space-4);
  color: var(--text-muted);
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-3);
  color: var(--text-faint);
  opacity: 0.6;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  letter-spacing: var(--tracking-tight);
}

.empty-state__body { font-size: var(--fs-sm); max-width: 360px; margin: 0 auto; line-height: var(--lh-loose); }
