/* Mysa Support portal (and, with staff.css, the staff views). The only stylesheet: no preprocessors,
   no third-party CSS. CSP is default-src 'self', so no inline styles anywhere; add classes here instead.

   Look and feel follow getmysa.com's design system (warm whites, charcoal type, Mysa blue, Inter,
   soft rounded cards). Every colour is a token below, written as light-dark(light, dark): the theme
   follows the device unless <html data-theme="light|dark"> is set from the theme cookie (app/theme.py). */

@font-face {
  font-family: "InterVariable";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --text: light-dark(#2c2c2c, #f0ede9);
  --text-strong: light-dark(#0f0f0f, #fbfaf9);
  --muted: light-dark(#5f5f5c, #a9a7a3);
  --border: light-dark(#e8e4df, #34332f);
  --border-strong: light-dark(#cfcac3, #4a4945);
  --surface: light-dark(#ffffff, #1f1f1e);
  --surface-raised: light-dark(#ffffff, #262625);
  --background: light-dark(#fbfaf9, #141413);
  --sunken: light-dark(#f0ede9, #2a2a28);

  /* Mysa blue. accent is for borders, focus rings and fills behind white text; accent-strong is for
     text and links, so both themes meet WCAG AA (4.5:1). */
  --accent: light-dark(#1567d4, #3d84e6);
  --accent-strong: light-dark(#0f56b3, #8db8f2);
  --accent-hover: light-dark(#0b3d82, #5b98ea);
  --accent-tint: light-dark(#ecf3fd, #15253d);
  --accent-tint-border: light-dark(#c8ddfa, #27426b);
  --on-accent: #ffffff;

  --danger: light-dark(#f51854, #ff5c85);
  --danger-strong: light-dark(#9b0c33, #ff9db5);
  --danger-fill: light-dark(#c4103f, #d42c57);
  --danger-tint: light-dark(#fff0f4, #3a1019);
  --success: light-dark(#026a30, #7ee2a8);
  --success-border: light-dark(#03a64a, #2f8f58);
  --success-tint: light-dark(#ebfbf2, #0f2a1c);
  --warning: light-dark(#9e4a0c, #ffc58a);
  --warning-border: light-dark(#f57818, #b8641f);
  --warning-tint: light-dark(#fff4ea, #2f2110);

  --brand-gradient: linear-gradient(90deg, #fe0727 0%, #d8aef5 45%, #5f86ec 72%, #245ce9 100%);

  --font: "InterVariable", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-card: 20px;
  --radius: 14px;
  --radius-small: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --shadow: light-dark(0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.4));
  --shadow-raised: light-dark(0 4px 10px rgba(0, 0, 0, 0.08), 0 4px 14px rgba(0, 0, 0, 0.5));
  --focus: 0 0 0 3px light-dark(rgba(21, 103, 212, 0.35), rgba(141, 184, 242, 0.45));
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text-strong); line-height: 1.2; margin: 0 0 var(--space-3); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: clamp(26px, 22px + 1.2vw, 34px); }
h2 { font-size: 21px; line-height: 1.3; }
h3 { font-size: 17px; line-height: 1.3; }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }
code { font-family: var(--mono); font-size: 13px; background: var(--sunken); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere; }

a { color: var(--accent-strong); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-small); }

.muted { color: var(--muted); }

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-small);
  z-index: 10;
}
.skip-link:focus { top: var(--space-3); }

/* Layout */

.container { width: 100%; max-width: 920px; margin: 0 auto; padding: 0 var(--space-5); }
main.container { flex: 1; padding-top: var(--space-7); padding-bottom: var(--space-7); }
.main--narrow { max-width: 540px; }

.site-header { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: saturate(1.4) blur(10px); }
.site-header::before { content: ""; display: block; height: 3px; background: var(--brand-gradient); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 64px; flex-wrap: wrap; }
.wordmark { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-strong); text-decoration: none; font-weight: 650; font-size: 18px; letter-spacing: -0.02em; }
.wordmark:hover { color: var(--text-strong); }
.wordmark__mark { width: 30px; height: 30px; border-radius: 8px; display: block; }
.wordmark__product { color: var(--muted); font-weight: 500; }
.site-header__end { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.site-nav { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.site-nav__link { color: var(--muted); text-decoration: none; font-weight: 550; font-size: 15px; padding: 6px 12px; border-radius: 999px; }
.site-nav__link:hover { color: var(--text-strong); background: var(--sunken); }
.site-nav__link--active { color: var(--text-strong); background: var(--sunken); }
.site-nav__form { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 0 var(--space-3); }
.site-nav__email { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

.theme-toggle { margin: 0; display: flex; }
.theme-toggle__button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.theme-toggle__button:hover { color: var(--text-strong); border-color: var(--border-strong); }
.theme-toggle__icon { width: 15px; height: 15px; display: block; }
.theme-toggle__button--to-light { display: none; }
:root[data-theme="dark"] .theme-toggle__button--to-light { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle__button--to-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle__button--to-light { display: inline-flex; }
  :root:not([data-theme]) .theme-toggle__button--to-dark { display: none; }
}

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; background: var(--surface); }
.site-footer__inner { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding-top: var(--space-5); padding-bottom: var(--space-5); flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text-strong); }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-header__title { margin: 0; overflow-wrap: anywhere; }
.page-header__subtitle { color: var(--muted); margin: var(--space-2) 0 0; font-size: 17px; }
.page-header__eyebrow { color: var(--muted); font-size: 13px; font-weight: 550; letter-spacing: 0.02em; margin: 0 0 var(--space-2); font-variant-numeric: tabular-nums; }
.breadcrumb { margin-bottom: var(--space-4); font-size: 14px; }
.breadcrumb a { color: var(--muted); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { color: var(--text-strong); }
.breadcrumb a::before { content: "\2190\00a0"; }
.link-list { margin: 0; padding-left: var(--space-5); columns: 2; }
.form-footnote { margin-top: var(--space-4); font-size: 14px; color: var(--muted); }

/* Surfaces */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
}
.card__title { font-size: 18px; }

.empty-state { text-align: center; padding: var(--space-7) var(--space-4); }
.empty-state__title { color: var(--text-strong); font-weight: 600; font-size: 18px; margin-bottom: var(--space-2); }
.empty-state__text { color: var(--muted); margin-bottom: var(--space-5); }

/* Alerts */

.alert { border: 1px solid; border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.alert__title { font-weight: 600; margin-bottom: var(--space-1); }
.alert__list { margin: 0; padding-left: var(--space-5); }
.alert--info { background: var(--accent-tint); border-color: var(--accent-tint-border); }
.alert--success { background: var(--success-tint); border-color: var(--success-border); color: var(--success); }
.alert--warning { background: var(--warning-tint); border-color: var(--warning-border); color: var(--warning); }
.alert--danger { background: var(--danger-tint); border-color: var(--danger); color: var(--danger-strong); }

/* Badges */

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; line-height: 1; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge--info { background: var(--accent-tint); color: var(--accent-strong); }
.badge--success { background: var(--success-tint); color: var(--success); }
.badge--warning { background: var(--warning-tint); color: var(--warning); }
.badge--neutral { background: var(--sunken); color: var(--muted); }
.badge-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 20px;
  border: 2px solid transparent;
  border-radius: var(--radius-small);
  font: inherit;
  font-size: 15px;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.button--primary { background: var(--accent); color: var(--on-accent); }
.button--primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.button--secondary { background: transparent; color: var(--accent-strong); border-color: var(--accent); }
.button--secondary:hover { background: var(--accent-tint); color: var(--accent-strong); }
.button--danger { background: var(--danger-fill); color: #ffffff; }
.button--danger:hover { background: var(--danger-strong); color: var(--surface); }
.button--link { background: none; border: 0; min-height: 0; padding: 0; color: var(--accent-strong); font-size: inherit; font-weight: 550; text-decoration: underline; text-underline-offset: 3px; }
.button--link:hover { color: var(--accent-hover); }
.button-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Forms */

.form { display: flex; flex-direction: column; gap: var(--space-5); }
.form__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-weight: 600; color: var(--text-strong); font-size: 15px; }
.field__optional { color: var(--muted); font-weight: 400; }
.field__hint { color: var(--muted); font-size: 13px; margin: 0; }
.field__error { color: var(--danger-strong); font-size: 13px; font-weight: 600; margin: 0; }
.input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-small);
  padding: 10px 14px;
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input:not(.input--textarea):not(.input--file) { height: 46px; }
.input--textarea { resize: vertical; min-height: 150px; line-height: 1.5; }
.input--file { padding: 9px; }
select.input { cursor: pointer; }
.field--error .input { border-color: var(--danger); }

/* Tickets */

.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-list__item + .ticket-list__item { border-top: 1px solid var(--border); }
.ticket-list__link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3);
  margin: 0 calc(-1 * var(--space-3));
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.ticket-list__link:hover { background: var(--sunken); color: var(--text); }
.ticket-list__ref { color: var(--muted); font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }
.ticket-list__subject { color: var(--text-strong); font-weight: 600; overflow-wrap: anywhere; }
.ticket-list__meta { display: flex; align-items: center; gap: var(--space-3); color: var(--muted); font-size: 13px; }

.thread { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-6); }
.bubble { max-width: 85%; border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--space-4) var(--space-5); }
.bubble--customer { align-self: flex-end; background: var(--accent-tint); border-color: var(--accent-tint-border); border-bottom-right-radius: 6px; }
.bubble--mysa { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; box-shadow: var(--shadow); position: relative; }
.bubble--mysa::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 3px; border-radius: 3px; background: var(--brand-gradient); }
.bubble__header { display: flex; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.bubble__author { color: var(--text-strong); font-weight: 600; }
.bubble__tag { display: inline-block; margin-left: var(--space-1); padding: 2px 8px; border-radius: 999px; background: var(--accent-tint); color: var(--accent-strong); font-size: 11px; font-weight: 600; }
.bubble__body { white-space: pre-wrap; overflow-wrap: anywhere; }

.attachments { margin: var(--space-3) 0 0; padding: var(--space-3) 0 0; border-top: 1px solid var(--border); list-style: none; font-size: 14px; }
.attachments__item { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.flashes { margin-bottom: var(--space-3); }

.filter-tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; margin: 0 0 var(--space-4); padding: 4px; list-style: none; background: var(--sunken); border-radius: 999px; width: fit-content; }
.filter-tabs a { display: block; color: var(--muted); text-decoration: none; font-weight: 550; font-size: 14px; padding: 6px 14px; border-radius: 999px; }
.filter-tabs a:hover { color: var(--text-strong); }
.filter-tabs a[aria-current] { color: var(--text-strong); background: var(--surface); box-shadow: var(--shadow); }

.pagination { display: flex; gap: var(--space-2); margin-top: var(--space-5); }
.pagination [rel="next"] { margin-left: auto; }

/* Error page */

.error-page { text-align: center; padding: var(--space-7) var(--space-6); }
.error-page__code { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.error-page__actions { margin: var(--space-5) 0; }

/* Style guide swatches */

.swatches { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-2); }
.swatch { border: 1px solid var(--border); border-radius: var(--radius-small); padding: var(--space-5) var(--space-3) var(--space-2); font-size: 13px; font-family: var(--mono); }
.swatch--text { background: var(--text); color: var(--background); }
.swatch--muted { background: var(--muted); color: var(--background); }
.swatch--border { background: var(--border); }
.swatch--surface { background: var(--surface); }
.swatch--background { background: var(--background); }
.swatch--accent { background: var(--accent); color: var(--on-accent); }
.swatch--accent-strong { background: var(--accent-strong); color: var(--background); }
.swatch--danger { background: var(--danger); color: var(--text-strong); }
.swatch--danger-strong { background: var(--danger-strong); color: var(--background); }

@media (max-width: 640px) {
  .container { padding: 0 var(--space-4); }
  main.container { padding-top: var(--space-5); }
  .card { padding: var(--space-5) var(--space-4); border-radius: var(--radius); }
  .ticket-list__link { grid-template-columns: 1fr; gap: var(--space-1); }
  .bubble { max-width: 100%; }
  .site-nav__email { display: none; }
  .link-list { columns: 1; }
  .theme-toggle__label { display: none; }
}

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