/*
 * GroupsMESSENGER console. Hand-written CSS on purpose: the console is a handful
 * of screens, and a build step would only stand between us and a fix.
 * Palette follows GroupsSUITE (navy + teal) and adapts to the operator's theme.
 */

:root {
  --ground: #f7f9fb;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --ink: #182430;
  --muted: #5b6875;
  --faint: #8a96a2;
  --navy: #0f2a4a;
  --teal: #0e7e7b;
  --teal-soft: #e3f3f2;
  --line: #e4e9ef;
  --alert: #b4791b;
  --alert-soft: #f8efdd;
  --shadow: 0 1px 2px rgba(15, 42, 74, 0.05), 0 8px 24px rgba(15, 42, 74, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0b1520;
    --surface: #111e2c;
    --surface-2: #16273a;
    --ink: #e6edf4;
    --muted: #9dabba;
    --faint: #6c7c8d;
    --navy: #0a1524;
    --teal: #4fc7c0;
    --teal-soft: #123433;
    --line: #22344a;
    --alert: #e0b461;
    --alert-soft: #33280f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); }

/* --- top bar --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--navy);
  color: #eaf1f8;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .brand small {
  font-weight: 500;
  color: #9db6d1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
}

.topbar a, .topbar button {
  color: #eaf1f8;
  background: none;
  border: 1px solid rgba(234, 241, 248, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
}

.topbar a:hover, .topbar button:hover { border-color: rgba(234, 241, 248, 0.6); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--teal);
  color: #04211f;
  font-size: 12px;
  font-weight: 700;
}

.badge[hidden] { display: none; }

/* --- layout ---------------------------------------------------------------- */

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}

.chip.active { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.chip .count { color: var(--alert); font-weight: 700; }

/* --- inbox list ------------------------------------------------------------ */

.threads { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }

.thread {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.thread:last-child { border-bottom: none; }
.thread:hover { background: var(--surface-2); }
.thread.unread { background: var(--teal-soft); }

.thread .who { font-weight: 650; }
.thread .snippet { color: var(--muted); font-size: 13.5px; grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62ch; }
.thread .when { color: var(--faint); font-size: 12.5px; text-align: right; }
.thread .marks { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}

.tag.origin { background: var(--teal-soft); border-color: var(--teal-soft); color: var(--teal); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--alert); display: inline-block; }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); }

/* --- thread view ----------------------------------------------------------- */

.thread-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.thread-head h1 { font-size: 21px; margin: 0; letter-spacing: -0.01em; }

.context {
  margin: 10px 0 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
}

.context dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.context dt { color: var(--muted); font-weight: 600; }
.context dd { margin: 0; overflow-wrap: anywhere; }

.transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 18px;
}

.bubble {
  max-width: min(72ch, 78%);
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

/* Line breaks the sender typed are kept — but only inside the text, never for the
   template's own indentation around it. */
.bubble .text { white-space: pre-wrap; }

.bubble.from-team { align-self: flex-end; background: var(--teal-soft); border-color: var(--teal-soft); }
.bubble .meta { display: block; margin-top: 6px; color: var(--faint); font-size: 11.5px; }

.composer { display: flex; gap: 10px; align-items: flex-end; }

.composer textarea {
  flex: 1;
  min-height: 78px;
  resize: vertical;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.composer button {
  padding: 11px 20px;
  border: none;
  border-radius: 12px;
  background: var(--teal);
  color: #04211f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.composer button:disabled { opacity: 0.55; cursor: default; }

.flash {
  margin-bottom: 16px;
  padding: 11px 15px;
  border-radius: 12px;
  background: var(--alert-soft);
  color: var(--alert);
  font-size: 14px;
}

/* --- FAQ -------------------------------------------------------------------- */

.hint { color: var(--muted); font-size: 13.5px; max-width: 78ch; margin: 0 0 18px; }

.thread.faq .who { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }
.thread.faq .snippet { white-space: normal; max-width: none; }

.faq-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 760px;
}

.faq-form label { display: block; margin-bottom: 18px; font-weight: 650; font-size: 14px; }
.faq-form label.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.faq-form small { display: block; margin-top: 5px; color: var(--muted); font-weight: 400; font-size: 12.5px; }

.faq-form input[type="text"],
.faq-form textarea,
.faq-form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

.faq-form .row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.faq-form .row label { flex: 1; min-width: 180px; }

.faq-form .actions { display: flex; align-items: center; gap: 14px; }
.faq-form .actions input[type="submit"] {
  padding: 11px 20px; border: none; border-radius: 12px;
  background: var(--teal); color: #04211f; font: inherit; font-weight: 700; cursor: pointer;
}
.faq-form .actions .danger button {
  background: none; border: none; color: var(--alert); font: inherit; cursor: pointer; padding: 0;
}

/* --- front page ------------------------------------------------------------ */

.gate { max-width: 520px; margin: 12vh auto; padding: 0 20px; text-align: center; }
.gate h1 { font-size: 28px; letter-spacing: -0.02em; margin-bottom: 8px; }
.gate p { color: var(--muted); }

.gate button {
  margin-top: 18px;
  padding: 12px 22px;
  border: none;
  border-radius: 12px;
  background: var(--teal);
  color: #04211f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
