/**
 * Sophia STARS — shared components (roadmap Phase 1, §1.1 / Appendix C)
 *
 * Buttons, cards, tables, badges, empty states, skeletons. Page-specific
 * styles belong in css/pages/<page>.css, not here.
 *
 * .unified-action-btn* is kept as an alias of .btn* — that's the class
 * name existing page markup (e.g. timeout.html's "Refresh"/"Return to
 * Dashboard" buttons) already uses. Its only previous definition lived
 * in dark-mode-unified.css despite that file being theme-override-only
 * by name, which is exactly the kind of misfiled rule this consolidation
 * exists to fix.
 */

/* ===== Buttons ===== */
.btn,
.unified-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.55rem 1.1rem;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.btn:disabled,
.unified-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn:focus-visible,
.unified-action-btn:focus-visible {
  outline: 3px solid var(--blue-500);
  outline-offset: 2px;
}

.btn-primary,
.unified-action-btn-primary {
  background: var(--navy-800);
  color: #fff;
}
.btn-primary:hover:not(:disabled),
.unified-action-btn-primary:hover:not(:disabled) {
  background: var(--navy-700);
}

.btn-secondary,
.unified-action-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled),
.unified-action-btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--err-500);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(0.92);
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: var(--sp-5);
}
.card--hover {
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.card--hover:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}

/* ===== Badge / chip ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.15rem 0.6rem;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge--ok {
  background: color-mix(in srgb, var(--ok-500) 14%, transparent);
  color: var(--ok-500);
}
.badge--warn {
  background: color-mix(in srgb, var(--warn-500) 14%, transparent);
  color: var(--warn-500);
}
.badge--err {
  background: color-mix(in srgb, var(--err-500) 14%, transparent);
  color: var(--err-500);
}

/* ===== Empty state ===== */
.empty {
  display: grid;
  place-items: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4);
  text-align: center;
  color: var(--text-2);
}
.empty__icon {
  font-size: 2.5rem;
}
.empty__title {
  font-weight: 600;
  color: var(--text);
}

/* ===== Skeleton ===== */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: sophia-shimmer 1.4s linear infinite;
  }
  @keyframes sophia-shimmer {
    to {
      background-position: -200% 0;
    }
  }
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-weight: 700;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-raised);
}
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.table tbody tr:nth-child(even) {
  background: var(--surface-2);
}
.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== Forms (generic defaults — deliberately plain type selectors so
   page-specific classes like .to-input always win without needing
   !important; a :not([type=checkbox]) form of this rule would outrank
   a single class and silently override page-specific styling, the same
   specificity trap this whole consolidation exists to avoid) ===== */
input,
select,
textarea {
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
}
input[type="checkbox"],
input[type="radio"] {
  padding: 0;
  border: none;
  background: none;
  width: auto;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-500) 20%, transparent);
}

/* ===== Modal overlay ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  max-width: min(90vw, 640px);
  max-height: 85vh;
  overflow-y: auto;
}
