/* BETHNI Operator Portal */
:root {
  --bg: #0f1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --bethni-bg: #161b22;
  --op-bg: #2563eb;
  --radius: 12px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem 2rem; text-align: center; width: 320px;
}
.login-logo { font-size: 1.8rem; font-weight: 700; letter-spacing: 0.1em; color: var(--text); }
.login-sub { color: var(--text-muted); font-size: 0.85rem; margin: 0.25rem 0 1.5rem; }
.btn-google {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: #fff; color: #3c4043; border: 1px solid #dadce0;
  padding: 0.6rem 1.2rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background 0.15s;
}
.btn-google:hover { background: #f8f9fa; }
.login-note { margin-top: 1.2rem; font-size: 0.75rem; color: var(--text-muted); }

/* ── Portal Layout ── */
.portal-body { overflow: hidden; }
.portal-layout { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px; min-width: 220px; background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-weight: 700; font-size: 1rem; letter-spacing: 0.08em; }
.btn-new-conv {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  width: 28px; height: 28px; font-size: 1.2rem; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.btn-new-conv:hover { background: var(--accent-hover); }
.conv-list { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
.conv-list-loading, .conv-list-empty {
  padding: 1rem; font-size: 0.82rem; color: var(--text-muted); text-align: center;
}
.conv-item {
  padding: 0.7rem 1rem; cursor: pointer; border-radius: var(--radius-sm);
  margin: 0 0.4rem 0.2rem; transition: background 0.1s;
}
.conv-item:hover { background: var(--bg3); }
.conv-item.active { background: var(--bg3); border-left: 2px solid var(--accent); }
.conv-preview {
  font-size: 0.82rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-ts { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.topbar-title { font-weight: 600; font-size: 0.95rem; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.82rem; color: var(--text-muted); }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 0.25rem 0.65rem; border-radius: var(--radius-sm); font-size: 0.78rem;
  cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-logout:hover { border-color: var(--text-muted); color: var(--text); }

/* Thread */
.message-thread {
  flex: 1; overflow-y: auto; padding: 1.5rem 2rem; display: flex; flex-direction: column; gap: 1rem;
}
.empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.empty-state-text { color: var(--text-muted); font-size: 0.9rem; }
.msg-row { display: flex; }
.msg-operator { justify-content: flex-end; }
.msg-bethni { justify-content: flex-start; }
.msg-bubble {
  max-width: 72%; padding: 0.7rem 1rem; border-radius: var(--radius);
  font-size: 0.9rem; line-height: 1.55; position: relative;
}
.msg-operator .msg-bubble { background: var(--op-bg); color: #fff; border-bottom-right-radius: 4px; }
.msg-bethni .msg-bubble { background: var(--bethni-bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.msg-ts {
  display: none; font-size: 0.7rem; color: var(--text-muted);
  position: absolute; bottom: -1.2rem; white-space: nowrap;
}
.msg-operator .msg-ts { right: 0; }
.msg-bethni .msg-ts { left: 0; }
.msg-row:hover .msg-ts { display: block; }

/* Markdown in BETHNI messages */
.msg-markdown p { margin-bottom: 0.5rem; }
.msg-markdown p:last-child { margin-bottom: 0; }
.msg-markdown code {
  background: var(--bg3); padding: 0.1em 0.35em;
  border-radius: 3px; font-size: 0.85em; font-family: 'SF Mono', Consolas, monospace;
}
.msg-markdown pre {
  background: var(--bg3); padding: 0.75rem; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 0.5rem 0;
}
.msg-markdown pre code { background: none; padding: 0; }
.msg-markdown ul, .msg-markdown ol { padding-left: 1.4rem; margin: 0.4rem 0; }
.msg-markdown h1,.msg-markdown h2,.msg-markdown h3 { margin: 0.6rem 0 0.3rem; font-size: 1em; }

/* Typing indicator */
.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots span { display: inline-block; width: 5px; height: 5px; background: var(--text-muted);
  border-radius: 50%; animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Input bar */
.input-bar {
  padding: 1rem 1.25rem; border-top: 1px solid var(--border);
  background: var(--bg); display: flex; gap: 0.75rem; align-items: flex-end;
}
.msg-input {
  flex: 1; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 0.6rem 0.85rem;
  font-size: 0.9rem; font-family: inherit; resize: none; line-height: 1.5;
  max-height: 160px; outline: none; transition: border-color 0.15s;
}
.msg-input:focus { border-color: var(--accent); }
.btn-send {
  background: var(--accent); color: #fff; border: none;
  padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); font-size: 0.88rem;
  cursor: pointer; transition: background 0.15s; white-space: nowrap;
}
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
