/* =====================================================================
   Patient Square — Shared Design System
   Tokens + primitives shared across Komodo, Launch Curves, and PTRS.
   Keep this file identical across apps; app-specific layout lives in
   each app's own styles.css.
   ===================================================================== */

:root {
  color-scheme: light;

  /* --- Brand palette --- */
  --psi-navy: #0f3455;
  --psi-navy-dark: #0a263f;
  --psi-blue: #2f6b95;
  --psi-blue-bright: #3d83b4;
  --psi-steel: #7da1bb;
  --psi-mist: #eaf2f8;
  --psi-warm: #c66a3d;
  --psi-teal: #126b5b;
  --psi-plum: #8b6aa6;

  /* --- Surfaces & lines --- */
  --psi-bg: #f4f7fb;
  --psi-bg-deep: #eef3f8;
  --psi-surface: #ffffff;
  --psi-surface-2: #f8fbfe;
  --psi-surface-3: #f1f6fb;
  --psi-border: #dde7ef;
  --psi-border-strong: #c6d5e1;

  /* --- Text --- */
  --psi-text: #16222d;
  --psi-text-soft: #3b4956;
  --psi-muted: #677886;
  --psi-faint: #93a2af;

  /* --- Status --- */
  --psi-good: #1f8a5b;
  --psi-warn: #c08a2e;
  --psi-bad: #b23b46;

  /* --- Categorical chart palette (on-brand) --- */
  --c1: #0f3455;
  --c2: #2f6b95;
  --c3: #7da1bb;
  --c4: #126b5b;
  --c5: #8b6aa6;
  --c6: #c66a3d;
  --c7: #4c7d8c;
  --c8: #9a7b3d;
  --c9: #5d6b9b;
  --c10: #a05a72;

  /* --- Radius scale --- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* --- Spacing scale --- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;

  /* --- Elevation (soft, navy-tinted) --- */
  --shadow-xs: 0 1px 2px rgba(15, 52, 85, 0.06);
  --shadow-sm: 0 2px 8px rgba(15, 52, 85, 0.07);
  --shadow-md: 0 12px 30px -12px rgba(15, 52, 85, 0.22);
  --shadow-lg: 0 24px 60px -20px rgba(15, 52, 85, 0.28);
  --ring: 0 0 0 3px rgba(47, 107, 149, 0.22);

  /* --- Motion --- */
  --ease: cubic-bezier(0.32, 0.72, 0.3, 1);
  --t-fast: 120ms var(--ease);
  --t-med: 200ms var(--ease);

  /* --- Type --- */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;

  font-family: var(--font-sans);
  background: var(--psi-bg);
  color: var(--psi-text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(47, 107, 149, 0.06), transparent 60%),
    radial-gradient(900px 500px at -5% 0%, rgba(15, 52, 85, 0.05), transparent 55%),
    var(--psi-bg);
  background-attachment: fixed;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ---------- Typography primitives ---------- */
.psi-eyebrow {
  margin: 0;
  color: var(--psi-blue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.psi-label {
  color: var(--psi-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Surfaces ---------- */
.psi-card {
  background: var(--psi-surface);
  border: 1px solid var(--psi-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------- Buttons ---------- */
.psi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition:
    transform var(--t-fast),
    box-shadow var(--t-fast),
    background var(--t-fast),
    border-color var(--t-fast),
    color var(--t-fast);
}

.psi-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.psi-btn:active {
  transform: translateY(1px);
}

.psi-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.psi-btn-primary {
  background: linear-gradient(180deg, var(--psi-blue) 0%, var(--psi-navy) 100%);
  border-color: var(--psi-navy-dark);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.psi-btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.psi-btn-secondary {
  background: var(--psi-surface);
  border-color: var(--psi-border-strong);
  color: var(--psi-text-soft);
}

.psi-btn-secondary:hover:not(:disabled) {
  border-color: var(--psi-steel);
  background: var(--psi-surface-2);
  color: var(--psi-navy);
}

.psi-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--psi-muted);
}

.psi-btn-ghost:hover:not(:disabled) {
  background: var(--psi-mist);
  color: var(--psi-navy);
}

.psi-btn-sm {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
}

/* ---------- Form controls ---------- */
.psi-input,
.psi-select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-sm);
  background: var(--psi-surface);
  color: var(--psi-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.psi-input::placeholder {
  color: var(--psi-faint);
}

.psi-input:focus,
.psi-select:focus {
  outline: none;
  border-color: var(--psi-blue);
  box-shadow: var(--ring);
}

/* ---------- Chips & pills ---------- */
.psi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 10px;
  border: 1px solid var(--psi-border-strong);
  border-radius: var(--r-pill);
  background: var(--psi-mist);
  color: var(--psi-navy);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Segmented control ---------- */
.psi-segment {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--psi-border);
  border-radius: var(--r-md);
  background: var(--psi-surface-3);
}

.psi-segment button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--psi-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}

.psi-segment button:hover {
  color: var(--psi-navy);
}

.psi-segment button.active {
  background: var(--psi-surface);
  color: var(--psi-navy);
  box-shadow: var(--shadow-xs);
}

/* ---------- Scrollbars ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--psi-border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--r-pill);
  background-clip: padding-box;
  background-color: var(--psi-border-strong);
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--psi-steel);
}

/* ---------- Utility ---------- */
.psi-muted {
  color: var(--psi-muted);
}

@keyframes psi-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes psi-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
