/* ═══════════════════════════════════════════
   COMPONENTES REUTILIZABLES — Domo
   Diseño: Premium Minimalist SaaS
═══════════════════════════════════════════ */

/* ── Botones ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: -0.005em;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    opacity var(--transition-fast),
    transform 60ms var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-sm  { height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg  { height: 44px; padding: 0 var(--space-6); font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-xl  { height: 52px; padding: 0 var(--space-8); font-size: var(--text-lg); border-radius: var(--radius-lg); }

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  box-shadow: 0 1px 2px var(--color-primary-glow), inset 0 1px 0 rgba(255,255,255,0.10);
}
.btn-primary:hover  {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 2px 8px var(--color-primary-glow), var(--shadow-glow-primary), inset 0 1px 0 rgba(255,255,255,0.10);
}
.btn-primary:active { background: var(--color-primary-active); box-shadow: none; }

/* Secondary */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border-color: var(--color-danger);
  box-shadow: 0 1px 2px rgba(255, 77, 109, 0.25);
}
.btn-danger:hover { background: var(--color-danger); filter: brightness(1.15); }

.btn-full { width: 100%; }

/* ── Inputs y formularios ────────────────── */
.form-group   { display: flex; flex-direction: column; gap: var(--space-2); }
.form-section { display: flex; flex-direction: column; gap: var(--space-5); }

.form-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
  height: 38px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast);
  width: 100%;
  box-shadow: var(--shadow-xs);
}

.form-textarea {
  height: auto;
  padding: var(--space-3);
  resize: vertical;
  min-height: 88px;
  line-height: var(--leading-relaxed);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--color-text-subtle); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle), var(--shadow-xs);
  outline: none;
}

.form-input.is-error,
.form-select.is-error  { border-color: var(--color-danger); }
.form-input.is-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1), var(--shadow-xs);
}

.form-helper          { font-size: var(--text-xs); color: var(--color-text-subtle); }
.form-helper.is-error { color: var(--color-danger); }

.input-wrapper  { position: relative; }
.input-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-subtle);
  pointer-events: none;
}
.input-icon ~ .form-input { padding-left: 36px; }

.input-action {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  padding: 2px;
  display: flex;
  transition: color var(--transition-fast);
}
.input-action:hover { color: var(--color-text-muted); }

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card-compact { padding: var(--space-4); }

.card-clickable {
  cursor: pointer;
  transition:
    box-shadow var(--transition-base),
    transform var(--transition-base),
    border-color var(--transition-base);
}
.card-clickable:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--color-border-strong);
  transform: translateY(-2px);
}

/* ── Modales ─────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: backdrop-in 180ms var(--ease-out);
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--color-surface-raised);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  animation: modal-in 220ms var(--ease-out);
}

.modal-md { max-width: 680px; }
.modal-lg { max-width: 920px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}
.modal-close:hover { color: var(--color-text); background: var(--color-surface-alt); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* ── Toasts ──────────────────────────────── */
.alert {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: 13px;
}

.alert-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-warning);
}

.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 340px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toast-in 200ms var(--ease-out);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-icon    { flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; min-width: 0; }
.toast-title   { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.toast-message { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 2px; line-height: var(--leading-snug); }

.toast-success { border-left: 3px solid var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-danger); }
.toast-error .toast-icon   { color: var(--color-danger); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info    { border-left: 3px solid var(--color-info); }
.toast-info .toast-icon    { color: var(--color-info); }

/* ── Badges ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}

.badge-success { background: var(--color-success-light); color: var(--color-success-fg); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning-fg); }
.badge-danger  { background: var(--color-danger-light);  color: var(--color-danger-fg); }
.badge-info    { background: var(--color-info-light);    color: var(--color-info-fg); }
.badge-neutral { background: var(--color-surface-alt);   color: var(--color-text-muted); }
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }

/* ── Avatares ────────────────────────────── */
.avatar {
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
  color: white;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}

.avatar-xs { width: 24px;  height: 24px;  font-size: 9px; }
.avatar-sm { width: 30px;  height: 30px;  font-size: 11px; }
.avatar-md { width: 38px;  height: 38px;  font-size: 13px; }
.avatar-lg { width: 48px;  height: 48px;  font-size: 15px; }
.avatar-xl { width: 64px;  height: 64px;  font-size: 20px; }

.avatar-group { display: flex; }
.avatar-group .avatar          { margin-left: -8px; box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 3px rgba(0,0,0,0.06); }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ── Barra de progreso ───────────────────── */
.progress-bar {
  height: 5px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width var(--transition-slow);
}

/* ── Spinner ─────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton ────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-alt) 25%,
    var(--color-surface-raised) 50%,
    var(--color-surface-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-md);
  color: transparent;
  user-select: none;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Medidor contraseña ──────────────────── */
.password-strength { display: flex; gap: 4px; margin-top: var(--space-2); }

.strength-segment {
  flex: 1;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  transition: background var(--transition-base);
}

.strength-segment.active-1 { background: var(--color-danger); }
.strength-segment.active-2 { background: var(--color-warning); }
.strength-segment.active-3 { background: var(--color-info); }
.strength-segment.active-4 { background: var(--color-success); }

/* ── Tabs ────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  gap: 0;
}

.tab-item {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

.tab-item:hover { color: var(--color-text); }
.tab-item.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: var(--weight-semibold);
}

/* ── Empty state ─────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  gap: var(--space-3);
  color: var(--color-text-muted);
}

.empty-state-icon        { color: var(--color-text-subtle); margin-bottom: var(--space-2); }
.empty-state-title       { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-text); letter-spacing: -0.015em; }
.empty-state-description { font-size: var(--text-sm); max-width: 300px; line-height: var(--leading-relaxed); }

/* ── Tablas ──────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }

thead {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

thead th {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
}

tbody tr:hover td        { background: var(--color-surface-alt); }
tbody tr:last-child td   { border-bottom: none; }

/* ── Dropdown ────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  animation: dropdown-in 150ms var(--ease-out);
  padding: var(--space-1) 0;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}
.dropdown-item:hover        { background: var(--color-surface-alt); }
.dropdown-item.danger       { color: var(--color-danger); }
.dropdown-item.danger:hover { background: var(--color-danger-light); }

.dropdown-divider { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }

/* ── Breadcrumbs ─────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.breadcrumb-item:not(:last-child)::after {
  content: '/';
  margin-left: var(--space-1);
  color: var(--color-text-subtle);
}

.breadcrumb-item a             { color: var(--color-text-muted); }
.breadcrumb-item a:hover       { color: var(--color-text); text-decoration: none; }
.breadcrumb-item:last-child    { color: var(--color-text); font-weight: var(--weight-medium); }

/* ── Kbd ─────────────────────────────────── */
kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-strong);
  box-shadow: 0 1px 0 var(--color-border-strong);
  line-height: 1.6;
  letter-spacing: 0;
}
