/* Ansökshjälpen — chattfrontend (steg 3)
   Layout och komponenter enligt design/ (Claude Design), byggt statiskt
   ovanpå designtokens i colors_and_type.css. Kopplat till /api/turn (SSE). */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  overflow: hidden;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--input); }

/* WCAG: alla interaktiva element minst 44×44 och tydlig fokusring */
button, a, textarea, input { font-family: inherit; }

/* Ikonstorlekar i knappar (inlinade SVG saknar egen width/height) */
.btn-primary svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-ghost svg { width: 16px; height: 16px; flex-shrink: 0; }
.mode svg { width: 14px; height: 14px; flex-shrink: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.composer__attach svg,
.composer__send svg { width: 18px; height: 18px; }
button:focus-visible, a:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--ring);
  border-radius: var(--radius-sm);
}

/* Synligt dolt men läsbart för skärmläsare */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Applayout: sidofält + huvudkolumn ── */
.app { display: flex; height: 100vh; }

/* ── Sidofält ── */
.sidebar {
  width: 280px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; flex-direction: column;
}
.sidebar__brand {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
/* Varumärket är en knapp (tillbaka till startsidan) — nollställ knappstil */
button.sidebar__brand {
  border: 0; background: transparent; font-family: inherit; color: inherit;
  cursor: pointer; text-align: left; width: 100%;
}
button.sidebar__brand:hover { background: var(--bg-muted); }
.sidebar__brand-name { font-size: 14px; font-weight: 600; }
.sidebar__brand-sub { font-size: 11px; color: var(--fg-muted-2); }
.sidebar__new { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.sidebar__save-btn { width: 100%; justify-content: flex-start; font-size: 12.5px; }
.save-form { display: flex; flex-direction: column; gap: 8px; }
.save-form[hidden] { display: none; } /* display:flex vinner annars över hidden-attributet */
.save-form input {
  min-height: 44px; padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--input); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--fg);
}
.save-form input:focus { outline: none; border-color: var(--brand-primary); }
.save-form__msg { font-size: 11.5px; color: var(--fg-muted); min-height: 1em; }
.sidebar__steps { flex: 1; overflow-y: auto; padding: 0 12px 20px; }
.training-tips {
  list-style: none; display: flex; flex-direction: column; gap: 12px;
  padding: 4px 10px; font-size: 12.5px; line-height: 1.5; color: var(--fg-muted);
}
.training-tips strong { color: var(--fg); }

/* ── Markdown i bubblor: rubriker, avdelare, citat ── */
.bubble .md-h { font-weight: 700; margin: 10px 0 2px; }
.bubble .md-h1, .bubble .md-h2 { font-size: 15px; }
.bubble .md-h3, .bubble .md-h4 { font-size: 13.5px; }
.bubble .md-hr { border: 0; border-top: 1px solid currentColor; opacity: .25; margin: 10px 0; }
.bubble .md-quote {
  border-left: 3px solid var(--brand-primary); opacity: .9;
  margin: 6px 0; padding: 2px 10px; font-style: italic;
}
.step-group { margin-bottom: 22px; }
.step-group__title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  color: var(--fg-muted-2); letter-spacing: 0.06em; padding: 0 10px 6px;
}
.step-list { display: flex; flex-direction: column; gap: 1px; }
.step {
  padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px;
  color: var(--fg-muted); display: flex; align-items: center; gap: 8px;
}
.step--active { background: var(--bg-muted); color: var(--fg); font-weight: 600; }
.step--done { color: var(--fg-muted); }
.step__mark {
  width: 16px; height: 16px; border-radius: 999px; flex-shrink: 0;
  background: var(--bg-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.step--active .step__mark { background: var(--bg-card); border: 2px solid var(--brand-primary); }
.step--done .step__mark { background: var(--brand-primary); }
.step__mark svg { width: 10px; height: 10px; color: #fff; }
.sidebar__user {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar__avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--bg-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--fg-muted); flex-shrink: 0;
}
.sidebar__user-name { font-size: 13px; font-weight: 500; }
.sidebar__user-sub { font-size: 11px; color: var(--fg-muted-2); }

/* ── Huvudkolumn ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.header {
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.header__progress { flex: 1; max-width: 420px; }
/* Design-import 2 (2026-07-04): mörkare etiketter, högre mätare, ellipsis */
.progress__labels {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12px; color: var(--fg-muted); margin-bottom: 8px;
}
.progress__labels span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress__labels span:last-child { white-space: nowrap; flex-shrink: 0; }
.progress__track { height: 8px; background: var(--bg-muted); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--brand-primary); width: 0; transition: width .4s; }
.header__actions { display: flex; align-items: center; gap: 12px; }

/* Lägesväxlare */
.modes { display: inline-flex; background: var(--bg-muted); border-radius: 8px; padding: 4px; gap: 2px; }
.mode {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 0; cursor: pointer; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; background: transparent; color: var(--fg-muted);
  min-height: 36px;
}
.mode--active { background: var(--bg-card); color: var(--brand-primary); box-shadow: var(--shadow-xs); }
.mode--soon { cursor: default; opacity: 0.65; }
.mode__soon-tag {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--brand-secondary); color: var(--fg); padding: 2px 5px; border-radius: 999px;
}
.icon-btn {
  min-width: 44px; min-height: 44px; border: 0; background: transparent; cursor: pointer;
  color: var(--fg-muted); border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-muted); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px; border: 0; background: transparent;
  color: var(--fg-muted); cursor: pointer; border-radius: var(--radius-sm); font-size: 13px;
}
.btn-ghost:hover { background: var(--bg-muted); }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 8px 14px; border: 0; cursor: pointer;
  background: var(--brand-primary); color: var(--fg-on-primary);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--brand-primary-hover); }

/* ── Startsida ── */
.welcome { display: flex; justify-content: center; padding: 48px 20px; }
.welcome[hidden] { display: none; }
.welcome__card { max-width: 620px; text-align: center; }
.welcome__card h1 { font-size: 28px; font-weight: 700; margin: 16px 0 8px; }
.welcome__lead { font-size: 15px; color: var(--fg-muted); margin: 0 auto 28px; max-width: 46ch; }
.welcome__choices { display: flex; gap: 14px; margin-bottom: 28px; }
.welcome__choice {
  flex: 1; text-align: left; cursor: pointer;
  padding: 18px; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--fg); font-family: inherit;
  display: flex; flex-direction: column; gap: 6px; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.welcome__choice:hover { border-color: var(--brand-primary); box-shadow: var(--shadow-xs); }
.welcome__choice strong { font-size: 15px; color: var(--brand-primary); }
[data-theme="dark"] .welcome__choice strong { color: var(--fg); }
.welcome__choice span { font-size: 13px; color: var(--fg-muted); line-height: 1.5; }
.welcome__more { font-size: 13px; color: var(--fg-muted); margin: -12px 0 24px; }
.welcome__more a { color: var(--brand-primary); }
.welcome__facts {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: var(--fg-muted); margin-bottom: 24px; padding: 0;
}
.welcome__info {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  text-align: left; margin-bottom: 24px;
}
.winfo {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.winfo h2 { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.winfo p { font-size: 13px; color: var(--fg-muted); line-height: 1.55; margin: 0; }
.winfo__list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--fg-muted); line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
.winfo__list strong { color: var(--fg); }
/* FAQ på startsidan — inbyggda details/summary, inga skript */
.faq { text-align: left; margin-bottom: 28px; }
.faq h2 { font-size: 16px; font-weight: 700; margin-bottom: 10px; text-align: center; }
.faq details {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.faq summary {
  cursor: pointer; padding: 12px 16px; min-height: 44px;
  font-size: 14px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+'; margin-left: auto; flex-shrink: 0;
  font-size: 18px; font-weight: 400; color: var(--brand-primary);
}
.faq details[open] summary::after { content: '−'; }
.faq summary:hover { color: var(--brand-primary); }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq details p { padding: 12px 16px; margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--fg-muted); }
.faq a { color: var(--brand-primary); }
.welcome__footer { font-size: 12px; color: var(--fg-muted-2); line-height: 1.8; }
.welcome__footer a { color: var(--fg-muted); }
@media (max-width: 600px) {
  .welcome { padding: 24px 16px; }
  .welcome__choices { flex-direction: column; }
  .welcome__info { grid-template-columns: 1fr; }
}

/* ── Meddelandelista ── */
.scroll { flex: 1; overflow-y: auto; padding: 32px 0; }
.thread {
  max-width: 760px; margin: 0 auto; padding: 0 32px;
  display: flex; flex-direction: column; gap: 20px;
}
.msg { display: flex; gap: 10px; }
.msg--user { justify-content: flex-end; }
.msg--ai { justify-content: flex-start; }
.msg__avatar {
  width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0; margin-top: 2px;
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.msg__avatar svg { width: 14px; height: 14px; }
.msg__col { max-width: 72%; }
.bubble {
  padding: 11px 16px; font-size: 14px; line-height: 1.55;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg--user .bubble {
  background: var(--brand-primary); color: #fff;
  border-radius: 14px 2px 14px 14px;
}
.msg--ai .bubble {
  background: var(--brand-secondary); color: var(--fg);
  border-radius: 2px 14px 14px 14px;
}
/* Mörkt läge: frågetexten helvit på den mörkblå bubblan (11,4:1) —
   f2f2f2 i normal vikt upplevdes för dämpad (Fredrik 2026-07-04) */
[data-theme="dark"] .msg--ai .bubble { color: #fff; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .msg--ai .bubble { color: #fff; }
}
/* Ärv bubblans färg — designens globala p-regel (fg-muted) gav annars
   grå stycken/rubriker blandat med vita listor i mörkt läge */
.bubble p { margin: 0 0 8px; color: inherit; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { font-weight: 700; }
.bubble ul.md { list-style: disc; padding-left: 20px; margin: 6px 0; }
.bubble a { text-decoration: underline; }
.bubble__time { font-size: 11px; color: var(--fg-muted); margin-top: 4px; padding-inline: 4px; }
.msg--user .bubble__time { text-align: right; }

/* Kopierbart block (sammanställningen) */
.codeblock {
  margin: 6px 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); overflow: hidden;
}
.codeblock__bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px 6px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--fg-muted-2); background: var(--bg-muted);
}
.codeblock__count { font-variant-numeric: tabular-nums; }
.codeblock__count--over { color: #c62828; font-weight: 700; }
[data-theme="dark"] .codeblock__count--over { color: #ff8a80; }
.codeblock__copy {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 32px; padding: 4px 10px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--fg); border-radius: var(--radius-sm);
  font-size: 12px; cursor: pointer;
}
.codeblock__copy:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.codeblock pre {
  margin: 0; padding: 12px 14px; font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.5; color: var(--fg);
  white-space: pre-wrap; word-wrap: break-word;
}

/* Snabbsvarschips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-inline: 42px; }
.chip {
  padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12.5px; color: var(--fg); cursor: pointer;
  min-height: 44px; transition: all .15s;
}
.chip:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

/* Svarsalternativ (🔘-rader) inuti AI-bubblor — klickbara knappar */
.bubble__options { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 2px; }
.bubble__options .chip {
  text-align: left; border-radius: 10px; font-size: 13.5px;
  background: var(--bg-card); box-shadow: var(--shadow-xs);
}
.bubble__options .chip [aria-hidden] { margin-right: 2px; }

/* Mörkt läge: --bg-card är nästan svart och gjorde knapparna "döda" på
   den mörkblå bubblan — ge dem tydlig knappkänsla i stället */
[data-theme="dark"] .bubble__options .chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
}
[data-theme="dark"] .bubble__options .chip:hover {
  background: #fff; color: var(--brand-secondary); border-color: #fff;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .bubble__options .chip {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
  }
  html:not([data-theme="light"]) .bubble__options .chip:hover {
    background: #fff; color: var(--brand-secondary); border-color: #fff;
  }
}

/* Skrivindikator */
.typing { display: flex; gap: 10px; align-items: center; }
.typing__dots {
  background: var(--brand-secondary); border-radius: 2px 14px 14px 14px;
  padding: 14px 16px; display: inline-flex; gap: 4px;
}
.typing__dots span {
  width: 6px; height: 6px; border-radius: 999px; background: var(--fg);
  opacity: 0.4; animation: blink 1.2s infinite;
}
.typing__dots span:nth-child(2) { animation-delay: .15s; }
.typing__dots span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,60%,100%{opacity:.3} 30%{opacity:.9} }

/* Felmeddelande */
.sysmsg {
  align-self: center; max-width: 80%; text-align: center;
  font-size: 12.5px; color: var(--destructive);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
}

/* ── Komponator ── */
.composer-wrap { padding: 20px 32px 28px; background: var(--bg); border-top: 1px solid var(--border); }
.composer-inner { max-width: 760px; margin: 0 auto; }
.composer {
  border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card);
  padding: 8px; display: flex; align-items: flex-end; gap: 8px;
  box-shadow: var(--shadow-sm); transition: border-color .15s;
}
.composer:focus-within { border-color: var(--brand-primary); }
.composer__attach {
  width: 44px; height: 44px; border-radius: 8px; border: 0; background: transparent;
  color: var(--fg-muted-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer__attach:hover { background: var(--bg-muted); }
.composer textarea {
  flex: 1; border: 0; resize: none; font-size: 14px; line-height: 1.5;
  padding: 10px 4px; background: transparent; color: var(--fg);
  min-height: 24px; max-height: 200px; outline: none;
}
.composer__send {
  width: 44px; height: 44px; border-radius: 8px; border: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-muted); color: var(--fg-muted-2); cursor: not-allowed;
}
.composer__send.is-ready { background: var(--brand-primary); color: #fff; cursor: pointer; }
.composer__hint {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 10px; font-size: 11px; color: var(--fg-muted-2);
}
.composer__hint svg { width: 12px; height: 12px; vertical-align: middle; margin-right: 4px; }

/* ── Snabbknappar (Paus/Klar i intervjuträningen) ── */
.quick-actions { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.quick-actions[hidden] { display: none; }
.quick-chip {
  min-height: 44px; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card); color: var(--fg);
  font-size: 13px; font-weight: 500;
}
.quick-chip:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

/* ── Menyknapp + bakgrundsskugga (bara smala skärmar) ── */
.menu-btn { display: none; }
.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.35);
}
.backdrop[hidden] { display: none; }

/* ── Responsivt: sidofältet blir utfällbar panel på smala skärmar ── */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(300px, 85vw);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg, 0 8px 30px rgba(0,0,0,0.25));
  }
  .sidebar.sidebar--open { transform: translateX(0); }
  .menu-btn { display: inline-flex; flex-shrink: 0; }
  .header { padding: 12px 16px; gap: 12px; }
  .mode span.mode__label { display: none; }
  .thread, .composer-inner { padding-left: 16px; padding-right: 16px; }
  .chips { padding-inline: 16px; }
  .msg__col { max-width: 82%; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* ── Mobil: rubrikraden får inte trängas, tips för tangentbord göms ── */
@media (max-width: 600px) {
  .progress__labels span:first-child { display: none; } /* stegets namn krockade med räknaren */
  .progress__labels { justify-content: flex-end; }
  .header__progress { min-width: 88px; }
  .header__actions { gap: 4px; }
  #exit { min-width: 44px; padding: 8px; }
  #exit .exit__label { display: none; }          /* bara krysset på mobil */
  .composer__hint { flex-direction: column; gap: 4px; }
  .composer__hint span:last-child { display: none; } /* Enter-tips saknar mening på pekskärm */
}
