/* UKPaintball AI Engagement — dashboard styles */
:root {
  --bg: #0f1512;
  --panel: #ffffff;
  --panel-2: #f4f6f5;
  --ink: #16211c;
  --ink-2: #5a6b63;
  --line: #e4e9e6;
  --green: #00a884;
  --green-dark: #008f70;
  --green-soft: #e7f7f2;
  --orange: #ff6b35;
  --orange-soft: #fff0ea;
  --red: #e5484d;
  --amber: #f5a524;
  --blue: #3b82f6;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 20, 15, .06), 0 8px 24px rgba(10, 20, 15, .07);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--ink-2); font-weight: 400; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: .85em; }

/* ---------- login ---------- */
.login-screen {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(0,168,132,.25), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(255,107,53,.18), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px; background: var(--panel); border-radius: 20px; padding: 38px 34px;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 22px; margin: 10px 0 2px; font-weight: 800; }
.login-card h1 span { color: var(--green); }
.login-sub { color: var(--ink-2); margin: 0 0 22px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px; border: 1.5px solid var(--line);
  border-radius: 10px; font: inherit;
}
.login-card input:focus { outline: none; border-color: var(--green); }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- buttons / chips / pills ---------- */
.btn {
  font: inherit; font-weight: 600; border: none; border-radius: 10px;
  padding: 9px 16px; cursor: pointer; background: var(--panel-2); color: var(--ink);
  transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); filter: none; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); }
.btn-danger { background: #fdecec; color: var(--red); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.chip {
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-warn.active { background: var(--amber); border-color: var(--amber); }
.chip-hot.active { background: var(--orange); border-color: var(--orange); }

.pill {
  display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2);
}
.pill-green { background: var(--green-soft); color: var(--green-dark); }
.pill-orange { background: var(--orange-soft); color: var(--orange); }
.pill-red { background: #fdecec; color: var(--red); }
.pill-blue { background: #e8f1fe; color: var(--blue); }
.pill-amber { background: #fef5e0; color: #a06c00; }

/* ---------- app frame ---------- */
.app { display: flex; height: 100vh; }
.rail {
  width: 68px; background: #0c110e; display: flex; flex-direction: column; align-items: center;
  padding: 14px 0; gap: 6px; flex-shrink: 0;
}
.rail-logo { font-size: 26px; margin-bottom: 14px; }
.rail-btn {
  position: relative; width: 46px; height: 46px; border-radius: 13px; border: none; cursor: pointer;
  background: transparent; color: #7d8c84; display: flex; align-items: center; justify-content: center;
}
.rail-btn svg { width: 23px; height: 23px; }
.rail-btn:hover { background: rgba(255,255,255,.06); color: #cfe0d8; }
.rail-btn.active { background: var(--green); color: #fff; }
.rail-badge {
  position: absolute; top: 4px; right: 4px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; font-style: normal; padding: 1px 5px; border-radius: 999px;
}
.rail-spacer { flex: 1; }

.view { flex: 1; min-width: 0; display: flex; }

/* ---------- chat list ---------- */
.view-inbox { background: var(--panel-2); }
.chatlist {
  width: 360px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.chatlist-header { padding: 18px 18px 8px; display: flex; align-items: baseline; justify-content: space-between; }
.chatlist-header h2 { margin: 0; font-size: 21px; font-weight: 800; }
.stats-strip { font-size: 12px; color: var(--ink-2); display: flex; gap: 10px; }
.stats-strip b { color: var(--ink); }
.chatlist-search { padding: 6px 14px 10px; }
.chatlist-search input {
  width: 100%; padding: 10px 14px; border: none; background: var(--panel-2);
  border-radius: 10px; font: inherit;
}
.chatlist-search input:focus { outline: 2px solid var(--green-soft); }
.chatlist-filters { display: flex; gap: 6px; padding: 0 14px 12px; flex-wrap: wrap; }
.chatlist-items { flex: 1; overflow-y: auto; }

.chat-item {
  display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid #f0f3f1;
  transition: background .1s;
}
.chat-item:hover { background: #f7faf8; }
.chat-item.selected { background: var(--green-soft); }
.chat-item .avatar { flex-shrink: 0; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 11.5px; color: var(--ink-2); flex-shrink: 0; }
.chat-item-preview {
  font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-item-preview .you { color: var(--green-dark); font-weight: 600; }
.chat-item-badges { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.attention-dot {
  width: 9px; height: 9px; background: var(--red); border-radius: 50%; display: inline-block;
  margin-left: 6px; box-shadow: 0 0 0 3px #fdecec;
}

.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #1f3d33, #00a884);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 15px;
}

/* ---------- thread ---------- */
.thread { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.thread-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #9db1a7;
}
.thread-empty-art { font-size: 54px; margin-bottom: 8px; }
.thread-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.thread-header {
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.thread-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thread-name { font-weight: 750; }
.thread-sub { font-size: 12.5px; color: var(--ink-2); }
.thread-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.attention-banner {
  background: #fff7ed; border-bottom: 1px solid #fde3c8; color: #9a4b00; padding: 9px 18px; font-size: 13.5px;
}

.messages {
  flex: 1; overflow-y: auto; padding: 22px 8%;
  background:
    radial-gradient(circle at 30% 20%, rgba(0,168,132,.05), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,107,53,.05), transparent 40%),
    #eef2ef;
}
.msg-row { display: flex; margin-bottom: 8px; }
.msg-row.out { justify-content: flex-end; }
.bubble {
  max-width: 68%; padding: 9px 13px; border-radius: 12px; font-size: 14.2px; line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0,0,0,.05); white-space: pre-wrap; word-wrap: break-word; position: relative;
}
.msg-row.in .bubble { background: var(--bubble-in); border-top-left-radius: 4px; }
.msg-row.out .bubble { background: var(--bubble-out); border-top-right-radius: 4px; }
.msg-row.out.admin .bubble { background: #d6e8ff; }
.bubble-meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 3px; font-size: 10.5px; color: #6d7d75; }
.bubble-meta .who { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.bubble.failed { opacity: .55; border: 1px dashed var(--red); }
.msg-system { text-align: center; margin: 14px 0; }
.msg-system span {
  background: #dfe7e2; color: #4c5c54; font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 999px;
}
.msg-system.warn span { background: #fde8cf; color: #9a4b00; }

.email-card {
  max-width: 78%; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--blue);
  border-radius: 10px; padding: 11px 14px; font-size: 13.5px;
}
.email-card .email-head { font-weight: 700; margin-bottom: 4px; display:flex; gap:8px; align-items:center; }
.email-card .email-body { color: var(--ink-2); white-space: pre-wrap; max-height: 130px; overflow: hidden; }
.email-card.expanded .email-body { max-height: none; }
.email-card .email-toggle { color: var(--blue); font-size: 12px; cursor: pointer; font-weight: 600; margin-top: 4px; }

.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px 12px; }
.ai-status-line { font-size: 12px; color: var(--ink-2); padding: 0 2px 6px; }
.ai-status-line .on { color: var(--green-dark); font-weight: 700; }
.ai-status-line .off { color: var(--orange); font-weight: 700; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font: inherit; max-height: 140px;
}
.composer textarea:focus { outline: none; border-color: var(--green); }

/* ---------- info panel ---------- */
.info-panel {
  width: 320px; flex-shrink: 0; background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 18px;
}
.info-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); margin: 18px 0 8px; }
.info-panel h3:first-child { margin-top: 0; }
.info-block { background: var(--panel-2); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.kv .k { color: var(--ink-2); flex-shrink: 0; }
.kv .v { font-weight: 600; text-align: right; word-break: break-word; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 8px 0 4px; }
.info-panel select, .info-panel input {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
.likelihood { margin-top: 12px; }
.likelihood-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); }
.likelihood-top strong { color: var(--ink); font-size: 15px; }
.meter { height: 8px; background: #e2e8e4; border-radius: 999px; margin: 6px 0; overflow: hidden; }
.meter-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--amber), var(--green)); transition: width .4s; }
.likelihood-reason { font-size: 12px; color: var(--ink-2); font-style: italic; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-top: 10px; cursor: pointer; }
.mini-note { font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.info-events { max-height: 300px; overflow-y: auto; }
.event-row { padding: 5px 0; border-bottom: 1px solid #e9eeeb; font-size: 12.5px; }
.event-row:last-child { border-bottom: none; }
.event-row .when { color: var(--ink-2); font-size: 11px; }

/* ---------- generic pages (templates/settings/test) ---------- */
.view-page { background: var(--panel-2); flex-direction: column; overflow-y: auto; padding: 26px 34px; }
.page-header h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.page-header { margin-bottom: 18px; max-width: 1100px; }
.page-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 1100px; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tpl-list .tpl-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer;
}
.tpl-list .tpl-row:hover { border-color: var(--green); }
.tpl-row .tpl-name { font-weight: 700; font-size: 14px; }
.tpl-row .tpl-preview { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.tpl-editor { max-width: 1100px; }
.tpl-editor input, .tpl-editor textarea, .card input, .card textarea, .card select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 9px; font: inherit; background: #fff;
}
.card input[type="checkbox"], .info-panel input[type="checkbox"] {
  width: 17px; height: 17px; padding: 0; accent-color: var(--green); flex-shrink: 0;
}
.switch-row { justify-content: flex-start; }
.switch-row span { flex: 1; }
.tpl-editor textarea:focus, .tpl-editor input:focus { outline: none; border-color: var(--green); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.ladder-row {
  display: grid; grid-template-columns: 60px 90px 1fr 1fr 34px; gap: 8px; align-items: center; margin-bottom: 8px;
}
.ladder-row input, .ladder-row select { padding: 7px 9px; }
.ladder-row .x { background: none; border: none; color: var(--red); font-size: 16px; cursor: pointer; }
.ladder-head { font-size: 11.5px; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

.quick-personas { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }

.engine-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.engine-opt {
  font: inherit; text-align: left; padding: 12px 14px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; display: flex; flex-direction: column; gap: 3px;
}
.engine-opt span { font-size: 12px; color: var(--ink-2); }
.engine-opt.active { border-color: var(--green); background: var(--green-soft); }
.engine-opt.active strong { color: var(--green-dark); }
.engine-opt[data-mode="live"].active { border-color: var(--orange); background: var(--orange-soft); }
.engine-opt[data-mode="live"].active strong { color: var(--orange); }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row input { flex: 1; }

@media (max-width: 1250px) { .info-panel { display: none; } }
