/* HelixPing PWA — dark theme matching the HelixComm portal family. */

:root {
  --bg: #0b1220;
  --bg2: #111a2e;
  --card: #16213a;
  --card2: #1c2a4a;
  --line: #24345c;
  --text: #e8eefc;
  --muted: #8fa3c8;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--red); margin: 8px 0 0; }
[hidden] { display: none !important; }

.view { display: flex; flex-direction: column; height: 100dvh; }

/* --- login --- */
#view-login { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px;
}
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.logo-row { display: flex; align-items: center; gap: 10px; }

input, textarea {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent2); }

.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; font: inherit; cursor: pointer;
}
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #04121f; font-weight: 600; }
.btn.warn { background: var(--amber); border-color: var(--amber); color: #211600; font-weight: 600; }
.btn.wide { width: 100%; }
.btn:active { transform: translateY(1px); }
.iconbtn {
  background: none; border: none; color: var(--text); font-size: 1.2rem;
  cursor: pointer; padding: 6px 8px; border-radius: 8px;
}
.iconbtn:hover { background: var(--card2); }
.iconbtn.on { color: var(--accent); }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; }

/* --- top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.chat-title { flex: 1; min-width: 0; margin-left: 2px; }
.chat-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-row { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.live { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.asleep { background: #5a6c93; }

/* --- channel list --- */
.channel-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.channel-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; color: var(--text); font: inherit;
}
.channel-card:hover { background: var(--card2); }
.channel-main { flex: 1; min-width: 0; }
.channel-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.channel-prev { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.channel-meta { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.channel-time { color: var(--muted); font-size: 0.75rem; }
.badge {
  background: var(--accent2); color: #04121f; font-size: 0.75rem; font-weight: 700;
  border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.agent-chip { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.empty-hint { text-align: center; color: var(--muted); margin-top: 40px; padding: 0 30px; }

.footnote {
  display: flex; gap: 16px; justify-content: center; padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg2); font-size: 0.85rem;
}

/* --- chat --- */
.nudge-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #2b2410; border-bottom: 1px solid #4a3d12; color: var(--amber);
  padding: 8px 14px; font-size: 0.85rem;
}
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; border-radius: 14px; padding: 9px 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.agent { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.operator { align-self: flex-end; background: var(--accent2); color: #04121f; border-bottom-right-radius: 4px; }
.msg time { display: block; font-size: 0.68rem; opacity: 0.65; margin-top: 4px; }
.day-sep { text-align: center; color: var(--muted); font-size: 0.75rem; margin: 8px 0 2px; }

.composer {
  display: flex; gap: 8px; padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--bg2); border-top: 1px solid var(--line);
}
.composer textarea { flex: 1; resize: none; max-height: 120px; }

/* --- modal / toast --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50;
}
.modal {
  width: 100%; max-width: 560px; max-height: 86dvh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px;
}
.modal input { width: 100%; margin-top: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.prompt-pre {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 0.72rem; white-space: pre-wrap; word-break: break-word;
  max-height: 44dvh; overflow-y: auto;
}
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line);
  color: var(--text); border-radius: 12px; padding: 10px 16px; z-index: 100;
  max-width: 90vw; text-align: center;
}
