/* Personalets dashboard. Farverne står i :root, så udseendet kan ændres ét sted. */

:root {
  --text: #1a2233;
  --muted: #66718a;
  --faint: #98a1b5;
  --brand: #1f5bff;        /* koboltblå */
  --brand-dark: #1543c7;
  --border: #e0e5ef;
  --border-strong: #ccd4e4;
  --page-bg: #eef1f7;
  --inbox-bg: #f9fafd;
  --hover-bg: #f0f3fa;
  --selected-bg: #e5ebfa;
  --staff-bg: #e2eaff;
  --warn: #b85c1f;
  --warn-bg: #fdebd6;
  --warn-text: #9a4b12;
  --focus: #b87523;

  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--page-bg);
}

/* Nulstil browserens standardafstande */
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, p, ul { margin: 0; }
p { line-height: 1.5; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd { margin-left: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; opacity: .6; }
/* Kun for skærmlæsere */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Topbjælke */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: white;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 24px; color: var(--brand); text-decoration: none; }
.brand span { font-size: 17px; font-weight: 700; }
.topbar-label { font-size: 12px; color: var(--muted); }

/* To kolonner: indbakke til venstre, valgt sag til højre */
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100vh - 56px - 24px - 24px - 34px); /* fyld skærmen: topbjælke, padding, feedback-linje */
  min-height: 480px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
}

/* Indbakke */
.inbox { display: flex; flex-direction: column; min-height: 0; background: var(--inbox-bg); border-right: 1px solid var(--border); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.stat { padding: 12px 14px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 20px; font-weight: 650; letter-spacing: -0.5px; }
.stat span { font-size: 10.5px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.stat.warn b { color: var(--warn); }

.filters { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chip { padding: 4px 10px; font-size: 11.5px; color: var(--text); background: white; border: 1px solid var(--border-strong); border-radius: 999px; }
.chip:hover { background: var(--hover-bg); }
.chip[aria-pressed="true"] { color: white; background: #13307a; border-color: #13307a; }

.case-list { flex: 1; overflow: auto; padding: 0; list-style: none; }
.case-button {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.case-button:hover { background: var(--hover-bg); }
.case-button[aria-pressed="true"] { background: var(--selected-bg); border-left-color: var(--brand); }
.case-age { padding-top: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
.case-age.old { font-weight: 700; color: var(--warn); } /* har ventet længe */
.case-main { display: flex; flex-direction: column; min-width: 0; }
.case-phone { font-weight: 650; }
.case-body { margin-top: 2px; color: #55607a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-history { margin-top: 3px; font-size: 10.5px; color: var(--faint); }
.case-history:empty { display: none; }
.case-state { padding: 3px 7px; font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; border-radius: 4px; }
.case-state.waiting { color: var(--warn-text); background: var(--warn-bg); }
.case-state.answered { color: var(--brand); background: var(--staff-bg); }
.empty-list { padding: 40px 14px; text-align: center; color: var(--muted); }

/* Valgt sag */
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#case-detail { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.conversation-heading { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.conversation-heading h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.3px; }
.conversation-meta { flex: 1; font-size: 12px; color: var(--muted); }
.conversation-meta b { font-weight: 600; color: var(--text); }
#solve { padding: 7px 12px; font-size: 12px; font-weight: 600; color: var(--text); background: white; border: 1px solid var(--border-strong); border-radius: 6px; }
#solve:hover { background: var(--hover-bg); }

/* Tråden: forhistorie (gæst + AI), skillelinje, den ubesvarede SMS, personalets svar */
.messages { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow: auto; padding: 18px 20px; }
.message { max-width: 60%; padding: 10px 14px; line-height: 1.5; border-radius: 8px; }
.message-text { white-space: pre-wrap; }
.message-label { margin-bottom: 4px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.message.guest { align-self: flex-start; background: var(--hover-bg); border: 1px solid var(--border); }
.message.ai { align-self: flex-end; color: #3e4a66; background: white; border: 1px dashed #b7c2da; }
.message.ai .message-label::before { content: "✦ "; }
.message.staff { align-self: flex-end; background: var(--staff-bg); }
/* Den SMS, der venter på svar */
.message.current { background: white; border: 1px solid var(--brand); box-shadow: 0 0 0 3px var(--staff-bg); }
.message.current .message-label { color: var(--brand); }
.history-label { align-self: center; padding: 3px 10px; font-size: 11px; color: var(--muted); background: var(--hover-bg); border-radius: 999px; }
.handoff { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 11px; font-weight: 600; color: var(--warn-text); }
.handoff::before, .handoff::after { content: ""; flex: 1; height: 1px; background: #f0d7bd; }
.empty-detail { margin: auto; padding: 28px; text-align: center; color: var(--muted); }

/* Svarformular */
#reply-form { padding: 12px 20px 14px; border-top: 1px solid var(--border); }
textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  resize: vertical;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.sms-count { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
#reply-form button { padding: 7px 12px; font-size: 12px; font-weight: 600; color: white; background: var(--brand); border: 0; border-radius: 6px; }
#reply-form button:hover { background: var(--brand-dark); }
.feedback { min-height: 22px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }

/* Log ud-knappen i topbaren */
.logout { padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--brand); background: white; border: 1px solid var(--border-strong); border-radius: 6px; }
.logout:hover { background: var(--hover-bg); }

/* Login-skærmen (login.html): ét kort midt på siden, samme farver som dashboardet */
.login-page { display: grid; place-items: center; min-height: 100vh; margin: 0; }
.login-card { width: min(360px, calc(100vw - 32px)); padding: 28px; background: white; border: 1px solid var(--border); border-radius: 10px; }
.login-card h1 { margin: 16px 0 20px; font-size: 16px; font-weight: 600; }
.login-card label { display: block; margin: 12px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login-card input { width: 100%; padding: 9px 10px; font: inherit; color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; box-sizing: border-box; }
.login-card input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.login-card button { width: 100%; margin-top: 18px; padding: 9px 12px; font-size: 13px; font-weight: 600; color: white; background: var(--brand); border: 0; border-radius: 6px; }
.login-card button:hover { background: var(--brand-dark); }
.login-card button:disabled { opacity: .6; cursor: default; }
.login-error { margin: 12px 0 0; padding: 8px 10px; font-size: 12.5px; color: var(--warn-text); background: var(--warn-bg); border-radius: 6px; }

/* Smalle skærme: én kolonne */
@media (max-width: 700px) {
  .topbar { padding: 0 16px; }
  .topbar-label { display: none; }
  main { padding: 16px; }
  .workspace { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .inbox { border-right: 0; border-bottom: 1px solid var(--border); }
  .case-list { max-height: 280px; }
  .message { max-width: 85%; }
  .conversation-heading, .messages { padding: 14px 16px; }
  #reply-form { padding: 12px 16px; }
}
