/* Salon Pilot — shared foundation: tokens, base elements, shared components, utilities, print.
   Page-specific rules live in booking.css (public booking + manage pages) and workspace.css
   (staff workspace, sign-in, calendar). All three are linked from index.html in that order. */

@font-face {
  font-family: 'Salon Display';
  src:
    url('/fonts/space-grotesk-bold.woff2') format('woff2'),
    url('/fonts/space-grotesk-bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* Colour */
  --bg: #eef2ef;
  --surface: #fff;
  --surface-2: #f4f6f5;
  --surface-hover: #f0f4f2;
  --neutral: #dde6e1;
  --neutral-soft: #e8ecea;
  --ink: #15302a;
  --ink-2: #3f504a;
  --muted: #55665f;
  --line: #d6ded9;
  --line-soft: #e4eae7;
  --line-strong: #839690;
  --line-hover: #9fb3aa;
  --brand: #1e6b58;
  --brand-deep: #174f42;
  --brand-soft: #e1eee8;
  --brand-tint: #dcefe5;
  --brass: #b9832b;
  --brass-soft: #f6ebd6;
  --brass-faint: #fbf3e3;
  --brass-line: #e6d2ad;
  --brass-ink: #6d4c14;
  --danger: #a33a2c;
  --danger-soft: #f8e3df;
  --danger-line: #efc8c0;
  --danger-ink: #8a2f22;
  --info-soft: #dde8f6;
  --info-ink: #2c4d7a;
  --on-brand: #fff;
  --on-ink: #e9f1ed;
  --on-ink-muted: #b9cbc4;
  --on-ink-accent: #9fd2c2;
  --disabled-bg: #c9d3ce;
  --disabled-ink: #4d5d57;
  --hatch-a: #f4f6f5;
  --hatch-b: #e8edea;
  --grid-half: #f1f4f2;
  --grid-hour: #e1e7e4;
  /* Staff calendar colours (bar, background) */
  --cal-0: var(--brand);
  --cal-0-bg: var(--brand-tint);
  --cal-1: var(--brass);
  --cal-1-bg: #f6ead3;
  --cal-2: #5865a8;
  --cal-2-bg: #e2e6f6;
  --cal-3: #b45c4a;
  --cal-3-bg: #f6e1dc;

  /* Type */
  --display: 'Salon Display', 'Segoe UI', system-ui, sans-serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 15px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  --text-3xl: 26px;

  /* Space (4px scale) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;
  --sp-9: 36px;
  --sp-10: 40px;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-1: 0 1px 3px #0b1f1a12;
  --shadow-bar: 0 -8px 20px #0b1f1a10;
  --shadow-toast: 0 8px 35px #0b1f1a33;
  --shadow-modal: 0 30px 90px #0d201b3d;
  --backdrop: #15302a66;

  /* Layout */
  --hour-h: 76px;
  --focus: var(--brand);

  color-scheme: light;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--text-base) / 1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button,
a {
  touch-action: manipulation;
}
button {
  color: inherit;
  cursor: pointer;
}
button:disabled,
button[aria-disabled='true']:not([aria-busy='true']) {
  cursor: not-allowed;
  opacity: 0.55;
}
[aria-busy='true'] {
  cursor: progress;
}
a {
  color: inherit;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
h1,
h2 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.025em;
}
h1 {
  font-size: clamp(30px, 3.4vw, 44px);
  line-height: 1.1;
}
h2 {
  font-size: 24px;
  line-height: 1.2;
}
h3 {
  font-size: var(--text-lg);
  font-weight: 650;
  line-height: 1.4;
}
p {
  color: var(--muted);
}
svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
/* Dark surfaces get a brass ring so focus stays visible. */
.on-ink,
.auth-story,
#toast,
#toast-error {
  --focus: var(--brass);
}

.skip {
  position: fixed;
  z-index: 99;
  left: 14px;
  top: -60px;
  padding: 10px;
  background: var(--ink);
  color: var(--on-brand);
}
.skip:focus {
  top: 14px;
}

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: var(--ink);
}
.brandmark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: var(--on-brand);
  font: 700 26px/1 var(--display);
}
.brand-light {
  font-weight: 700;
  color: var(--brand);
}
.brand-dot {
  display: none;
}
.eyebrow {
  margin-bottom: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--brand);
  border-radius: var(--r-sm);
  background: var(--brand);
  color: var(--on-brand);
  font-size: var(--text-md);
  font-weight: 650;
  text-decoration: none;
  transition:
    background 0.15s,
    transform 0.15s;
}
.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.button.small {
  min-height: 40px;
  padding: 7px 13px;
  font-size: var(--text-sm);
}
.button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-brand);
}
.button:is(:disabled, [aria-disabled='true']):not([aria-busy='true']) {
  cursor: not-allowed;
  opacity: 1;
  background: var(--disabled-bg);
  border-color: var(--disabled-bg);
  color: var(--disabled-ink);
}
.button:not(:disabled, [aria-disabled='true']):active,
.icon-button:not(:disabled, [aria-disabled='true']):active {
  transform: translateY(1px);
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: var(--text-md);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.text-button.as-block {
  display: flex;
  width: fit-content;
}
.text-button:active {
  color: var(--brand-deep);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 22px;
}
.icon-button[aria-busy='true'] svg {
  display: none;
}

/* Busy: keep the button's own colours and show a spinner (static under reduced motion). */
button[aria-busy='true']::after,
.button[aria-busy='true']::after {
  content: '';
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sp-spin 0.7s linear infinite;
}
@keyframes sp-spin {
  to {
    transform: rotate(1turn);
  }
}

@media (hover: hover) {
  .button:not(:disabled, [aria-disabled='true']):hover {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
  }
  .button.secondary:not(:disabled, [aria-disabled='true']):hover {
    background: var(--brand-soft);
    border-color: var(--line-hover);
  }
  .button.danger:not(:disabled, [aria-disabled='true']):hover {
    background: var(--danger-ink);
    border-color: var(--danger-ink);
  }
  .text-button:hover {
    color: var(--brand-deep);
    text-decoration-thickness: 2px;
  }
  .icon-button:not(:disabled, [aria-disabled='true']):hover {
    background: var(--brand-soft);
  }
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.field > span,
.field > label,
.field-label {
  font-size: var(--text-sm);
  font-weight: 650;
  color: var(--ink);
}
.field-optional {
  font-weight: 400;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-base);
}
.field textarea {
  min-height: 96px;
  resize: vertical;
}
.field :is(input, select, textarea):disabled {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}
.field [aria-invalid='true'],
.field :is(input, select, textarea):user-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}
.field small,
.hint {
  font-size: var(--text-sm);
  color: var(--muted);
}
.field-error {
  display: flex;
  gap: 6px;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--danger-ink);
}
.field-error:empty,
.field-error[hidden] {
  display: none;
}
.field-error::before {
  content: '!';
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--on-brand);
  font-size: 12px;
  font-weight: 700;
}
@media (hover: hover) {
  .field :is(input, select, textarea):not(:disabled, [aria-invalid='true']):hover {
    border-color: var(--ink-2);
  }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}
.span-2 {
  grid-column: 1/-1;
}
.stack {
  display: grid;
  gap: 18px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--text-md);
  cursor: pointer;
}
.check input {
  flex: none;
  width: 17px;
  height: 17px;
  margin: 2px 0;
  accent-color: var(--brand);
}
.check small {
  display: block;
  margin-top: 4px;
  font-size: var(--text-sm);
  color: var(--muted);
}
.check:has(input:disabled) {
  cursor: not-allowed;
  color: var(--muted);
}

/* ---------- Pills, status, avatars ---------- */
.test-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--brass-line);
  border-radius: var(--r-pill);
  background: var(--brass-soft);
  color: var(--brass-ink);
  font-size: var(--text-xs);
  font-weight: 650;
  white-space: nowrap;
}
.test-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brass);
}
.status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--neutral-soft);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 650;
  white-space: nowrap;
}
.status.confirmed,
.status.paid,
.status.completed,
.status.succeeded,
.status.submitted {
  background: var(--brand-tint);
  color: var(--brand-deep);
}
.status.pending,
.status.awaiting_payment,
.status.pending_external_action,
.status.captured,
.status.needs_review,
.status.partially_refunded {
  background: var(--brass-soft);
  color: var(--brass-ink);
}
.status.cancelled,
.status.no_show,
.status.failed,
.status.expired,
.status.paid_unresolved {
  background: var(--danger-soft);
  color: var(--danger-ink);
}
.status.checked_in,
.status.scheduled {
  background: var(--info-soft);
  color: var(--info-ink);
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--neutral);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 700;
}
.avatar.peach {
  background: var(--brass-soft);
  color: var(--brass-ink);
}

/* ---------- Feedback ---------- */
.empty {
  padding: 54px 20px;
  text-align: center;
}
.empty-mark {
  display: block;
  margin-bottom: 14px;
  color: var(--brand);
  font-size: 36px;
}
.empty p {
  max-width: 340px;
  margin: 8px auto 20px;
  font-size: var(--text-md);
}
.notice {
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--ink-2);
  font-size: var(--text-md);
}
.notice.warning {
  background: var(--brass-soft);
  border-color: var(--brass-line);
  color: var(--brass-ink);
}
.notice.error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-ink);
}
.error-inline {
  margin-top: 10px;
  color: var(--danger);
  font-size: var(--text-md);
}
.error-inline[hidden] {
  display: none;
}
.test-banner {
  padding: 7px 16px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  text-align: center;
  font-size: var(--text-sm);
}

#toast,
#toast-error {
  position: fixed;
  z-index: 100;
  bottom: 24px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(520px, calc(100% - 32px));
  padding: 13px 19px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--on-brand);
  box-shadow: var(--shadow-toast);
  font-size: var(--text-md);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: 0.2s;
}
#toast.show,
#toast-error.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#toast-error.show {
  pointer-events: auto;
}
#toast.error,
#toast-error {
  background: var(--danger);
}
#toast-error:not(.show) {
  visibility: hidden;
}
.toast-close {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin: -6px -10px -6px 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
}
@media (hover: hover) {
  .toast-close:hover {
    background: #ffffff26;
  }
}

/* ---------- Dialog ---------- */
dialog {
  width: min(600px, calc(100% - 28px));
  max-height: 90vh;
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-modal);
}
dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(4px);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 25px;
}
.modal-head .icon-button {
  flex: none;
}
.modal-head h2 {
  font-size: var(--text-3xl);
}
.modal-head h2:focus {
  outline: none;
}
.modal-head h2:focus-visible {
  outline: 3px solid var(--focus);
}
#modal-error {
  margin: -9px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--danger-line);
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger-ink);
  font-weight: 600;
}
.modal-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.modal-section h3 {
  margin-bottom: 12px;
}

/* ---------- Layout pieces ---------- */
.card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 23px;
}
.section-head h2 {
  font-size: var(--text-2xl);
}
.section-head p {
  margin-top: 7px;
  font-size: var(--text-md);
}
.table-scroll {
  overflow: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--text-md);
  white-space: nowrap;
}
.card .data-table {
  white-space: normal;
}
.data-table th {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
}
.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.card .data-table td {
  vertical-align: top;
}
.data-table tr:last-child td {
  border: 0;
}
.data-table td strong {
  display: block;
  font-size: var(--text-md);
}
.data-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--text-sm);
}
.details-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 18px 0;
}
.details-list dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: var(--text-sm);
}
.details-list dd {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
}
.divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.row.center {
  justify-content: center;
}
.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 100vh;
  padding: 30px;
  text-align: center;
}
.loading h1 {
  max-width: 600px;
}
.loading p {
  max-width: 480px;
}

/* ---------- Utilities ---------- */
.muted {
  color: var(--muted);
}
.small-text {
  font-size: var(--text-sm);
}
.money {
  font-variant-numeric: tabular-nums;
}
.mt-8 {
  margin-top: var(--sp-2);
}
.mt-12 {
  margin-top: var(--sp-3);
}
.mt-16 {
  margin-top: var(--sp-4);
}
.mt-20 {
  margin-top: var(--sp-5);
}
.mt-24 {
  margin-top: var(--sp-6);
}
.mb-0 {
  margin-bottom: 0;
}
.mb-12 {
  margin-bottom: var(--sp-3);
}
.mb-24 {
  margin-bottom: var(--sp-6);
}
.stack-8,
.stack-12 {
  display: grid;
  gap: var(--sp-2);
}
.stack-12 {
  gap: var(--sp-3);
}
.is-inactive {
  opacity: 0.65;
}
.fieldset-reset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.sr-only,
.visually-hidden-focusable:not(:focus, :focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 650px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: auto;
  }
  .card {
    padding: 18px;
  }
  .section-head {
    flex-direction: column;
    gap: 13px;
  }
  .section-head > .button {
    align-self: flex-start;
  }
  dialog {
    padding: 21px;
  }
  .form-actions {
    flex-wrap: wrap;
  }
  .details-list {
    gap: 12px;
  }
}

/* Windows High Contrast: selection is shown with colour only, so add an outline. */
@media (forced-colors: active) {
  [aria-pressed='true'],
  [aria-current]:not([aria-current='false']),
  .active,
  .selected {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .status,
  .test-pill {
    border: 1px solid CanvasText;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Print (generic) ---------- */
@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body {
    background: #fff;
    font-size: 12pt;
  }
  .skip,
  #toast,
  #toast-error,
  .test-banner,
  .button,
  .icon-button,
  .text-button,
  .toast-close {
    display: none !important;
  }
  .card,
  .notice,
  .details-list > div {
    break-inside: avoid;
  }
  a[href^='http']::after {
    content: ' (' attr(href) ')';
    font-size: 9pt;
    color: var(--muted);
  }
}
