/* ============================================================
   Componentes reutilizables — glassmorphism refinado
   ============================================================ */

/* Icono SVG base */
.ic {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.14em;
  flex-shrink: 0;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-4);
  background: var(--surface-3);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  color: var(--text);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--dur-press) var(--ease-out),
    border-color var(--dur-press) var(--ease-out),
    transform var(--dur-press) var(--ease-out),
    box-shadow var(--dur-press) var(--ease-out);
  user-select: none;
  letter-spacing: 0.005em;
}
.btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--border-strong);
}
.btn:active {
  transform: scale(0.965);
}
.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}
.btn svg, .btn .ic {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: transparent;
  box-shadow: 0 4px 20px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-success {
  background: var(--success);
  border-color: transparent;
  color: #03130a;
  box-shadow: 0 2px 12px rgba(29,233,155,0.25);
}
.btn-success:hover {
  box-shadow: 0 4px 20px rgba(29,233,155,0.38);
}
.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #1a020a;
  box-shadow: 0 2px 12px rgba(255,77,114,0.25);
}
.btn-danger:hover {
  box-shadow: 0 4px 20px rgba(255,77,114,0.38);
}
.btn-warn {
  background: var(--warn);
  border-color: transparent;
  color: #1c1100;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  border-color: transparent;
}
.btn-sm {
  height: 28px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}
.btn-icon {
  width: 34px;
  padding: 0;
}
.btn-icon.btn-sm {
  width: 28px;
}
.btn-block { width: 100%; }

.btn.loading {
  color: transparent !important;
  position: relative;
  pointer-events: none;
}
.btn.loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: var(--text-md);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast);
}
.input::placeholder, .textarea::placeholder {
  color: var(--text-subtle);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(124,92,255,0.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea {
  resize: vertical;
  min-height: 64px;
  line-height: var(--leading-normal);
}
.field { margin-bottom: var(--space-4); }
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  letter-spacing: 0.01em;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* Search con icono */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search svg, .search .ic {
  position: absolute;
  left: 11px;
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
  pointer-events: none;
}
.search .input {
  padding-left: 32px;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface-2);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card-pad-0 {
  padding: 0;
  overflow: hidden;
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  font-family: var(--font-sans);
}
.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.pill.pending   { background: var(--warn-soft);    color: var(--warn); }
.pill.approved  { background: var(--success-soft); color: var(--success); }
.pill.denied    { background: var(--danger-soft);  color: var(--danger); }
.pill.scheduled { background: var(--info-soft);    color: var(--info); }
.pill.posted    { background: var(--accent-soft);  color: var(--accent-text); }
.pill.failed    { background: var(--danger-soft);  color: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-bold);
  box-shadow: 0 0 8px var(--accent-soft);
}
.badge.muted {
  background: var(--surface-3);
  color: var(--text-muted);
  box-shadow: none;
}

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  background: rgba(255,255,255,0.04);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ---------- Tabla ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-md);
}
.table th, .table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-subtle);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--weight-semibold);
  font-family: var(--font-sans);
}
.table tbody tr {
  transition: background var(--transition-fast);
}
.table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}
.table tr:last-child td {
  border-bottom: none;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-6);
  animation: fade-in 0.18s var(--ease);
}
.modal {
  background: var(--surface-elevated);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-2xl);
  width: min(880px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.04) inset;
  position: relative;
  animation: pop-in 0.26s var(--ease-spring);
}
.modal-narrow {
  width: min(460px, 100%);
  padding: var(--space-6);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  z-index: 2;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.modal-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}
.modal-close .ic { width: 14px; height: 14px; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
  align-items: center;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-elevated);
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  border: 1px solid var(--border-glass);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition:
    opacity    var(--dur-menu) var(--ease-out),
    transform  var(--dur-menu) var(--ease-out);
}
@starting-style {
  .toast {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
}
.toast[data-leaving] {
  opacity: 0;
  transform: translateY(6px) scale(0.97);
}
.toast.ok  { border-color: rgba(29,233,155,0.4); }
.toast.err { border-color: rgba(255,77,114,0.4); }
.toast::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  flex-shrink: 0;
}
.toast.ok::before  { background: var(--success); box-shadow: 0 0 6px rgba(29,233,155,0.5); }
.toast.err::before { background: var(--danger);  box-shadow: 0 0 6px rgba(255,77,114,0.5); }

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 37%,
    rgba(255,255,255,0.04) 63%
  );
  background-size: 960px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}
.empty-icon {
  display: inline-flex;
  margin-bottom: var(--space-4);
  color: var(--text-subtle);
  opacity: 0.5;
}
.empty-icon .ic { width: 42px; height: 42px; stroke-width: 1.2; }
.empty-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

/* ---------- Switch ---------- */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
  cursor: pointer;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition-fast);
}
.switch input:checked + .slider {
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 0 10px var(--accent-soft);
}
.switch input:checked + .slider::before {
  transform: translateX(16px);
  background: #fff;
}

/* ---------- Checkbox ---------- */
.checkbox {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
  flex-shrink: 0;
}
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}
.checkbox.checked::after {
  content: "";
  width: 10px;
  height: 6px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translateY(-1px);
  border-radius: 1px;
}
