/* strateva.ai — chat UI (graphite theme: formal & elegant) */
:root {
  --bg: #141619;              /* deep graphite */
  --bg-elev: #1b1d21;
  --bg-elev-2: #24272d;
  --border: #31353d;
  --text: #e9eaec;
  --text-dim: #a6abb4;
  --text-faint: #70757e;
  --accent: #5b6b85;          /* refined slate accent */
  --accent-dark: #3a4760;     /* darker slate for gradients */
  --accent-soft: #20242b;
  --user-bubble: #24272d;
  --green: #4cae7a;
  --amber: #c9a44e;
  --red: #d9685f;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 12px; gap: 10px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
}
.brand-mark.sm { width: 22px; height: 22px; font-size: 13px; border-radius: 6px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; color: var(--text); text-decoration: none; }
.brand-name:hover { color: var(--accent); }

.new-chat-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--accent); color: #fff; border: none;
  padding: 10px 12px; border-radius: 10px; font-weight: 600; cursor: pointer;
  transition: filter .15s;
}
.new-chat-btn:hover { filter: brightness(1.07); }

.conv-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); margin-top: 6px; padding: 0 4px; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px;
  color: var(--text-dim); cursor: pointer; font-size: 14px; border: 1px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--bg-elev-2); color: var(--text); }
.conv-item.active { background: var(--bg-elev-2); color: var(--text); border-color: var(--border); }
.conv-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.conv-item .del { opacity: 0; color: var(--text-faint); }
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { color: var(--red); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.model-badge { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.ghost-btn:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Main ---------- */
#main { display: flex; flex-direction: column; min-width: 0; }
#topbar {
  height: 54px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: rgba(15,17,21,.7); backdrop-filter: blur(8px);
}
.topbar-title { display: flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 13px; }
.mobile-only { display: none; }

.thread { flex: 1; overflow-y: auto; padding: 26px 0 10px; }
.thread-inner, .msg-row, .composer, .welcome { max-width: 760px; margin: 0 auto; }

/* welcome */
.welcome { text-align: center; padding: 8vh 20px 0; }
.welcome-mark {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px;
  display: grid; place-items: center; font-size: 26px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); box-shadow: var(--shadow);
}
.welcome h1 { font-size: 26px; margin: 0 0 8px; }
.welcome p { color: var(--text-dim); margin: 0 auto 26px; max-width: 460px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suggestion {
  text-align: left; background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim); padding: 13px 14px; border-radius: 12px; cursor: pointer;
  font-size: 14px; transition: all .15s;
}
.suggestion:hover { color: var(--text); border-color: var(--accent); background: var(--bg-elev-2); }

/* messages */
.msg-row { padding: 6px 20px; display: flex; gap: 14px; }
.msg-row .avatar {
  flex: 0 0 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; margin-top: 2px;
}
.msg-row.user .avatar { background: var(--user-bubble); color: var(--text); }
.msg-row.assistant .avatar { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }
.msg-body { flex: 1; min-width: 0; padding-top: 3px; line-height: 1.6; }
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: #fff; font-weight: 600; }
.msg-body code { font-family: var(--mono); background: var(--bg-elev-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.msg-row.user .msg-body { color: var(--text); }

/* tool status chip */
.tool-status {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim);
  background: var(--bg-elev); border: 1px solid var(--border); padding: 7px 12px; border-radius: 999px;
  margin: 2px 0;
}
.spinner {
  width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dots::after { content: "…"; animation: dots 1.2s steps(4,end) infinite; }
@keyframes dots { 0%{content:""} 25%{content:"."} 50%{content:".."} 75%{content:"..."} }

/* result card */
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 10px 0; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.card-title { font-weight: 600; font-size: 15px; }
.card-tag { font-family: var(--mono); font-size: 11px; color: var(--text-faint); background: var(--bg-elev-2); padding: 3px 8px; border-radius: 6px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric { background: var(--bg-elev-2); border-radius: 10px; padding: 10px 12px; }
.metric .label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .4px; }
.metric .value { font-size: 20px; font-weight: 700; margin-top: 2px; font-family: var(--mono); }
.metric .sub { font-size: 11px; color: var(--text-dim); }
.metric.accent .value { color: var(--accent); }
.metric.red .value { color: var(--red); }
.chart-box { position: relative; height: 260px; }

/* range bars (HAR) */
.range-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }
.range-row .lbl { width: 46px; color: var(--text-dim); font-family: var(--mono); }
.range-bar { flex: 1; height: 26px; position: relative; background: var(--bg-elev-2); border-radius: 7px; overflow: hidden; }
.range-fill { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, rgba(143,156,182,.3), rgba(143,156,182,.6)); }
.range-row .vals { width: 150px; text-align: right; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

/* regime / vrp pills */
.pill-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 10px; }
.pill { background: var(--bg-elev-2); border-radius: 10px; padding: 12px; border-left: 3px solid var(--text-faint); }
.pill .sym { font-weight: 700; font-size: 15px; }
.pill .regime { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.pill .small { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.pill.green { border-left-color: var(--green); } .pill.green .regime { color: var(--green); }
.pill.amber { border-left-color: var(--amber); } .pill.amber .regime { color: var(--amber); }
.pill.red { border-left-color: var(--red); } .pill.red .regime { color: var(--red); }
.pill.err { color: var(--text-faint); }

/* composer */
.composer-wrap { padding: 10px 20px 16px; border-top: 1px solid transparent; }
.composer {
  display: flex; align-items: flex-end; gap: 8px; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 16px; padding: 8px 8px 8px 16px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--accent); }
#input {
  flex: 1; background: transparent; border: none; color: var(--text); resize: none;
  font-family: inherit; font-size: 15px; line-height: 1.5; max-height: 180px; padding: 7px 0;
  outline: none;
}
#input::placeholder { color: var(--text-faint); }
.send-btn {
  flex: 0 0 38px; height: 38px; border-radius: 11px; border: none; cursor: pointer;
  background: var(--accent); color: #fff; display: grid; place-items: center; transition: filter .15s;
}
.send-btn:hover { filter: brightness(1.08); }
.send-btn:disabled { background: var(--bg-elev-2); color: var(--text-faint); cursor: not-allowed; }
.disclaimer { text-align: center; color: var(--text-faint); font-size: 11px; margin-top: 8px; }

/* error */
.error-banner { color: var(--red); background: rgba(248,81,73,.08); border: 1px solid rgba(248,81,73,.3); padding: 8px 12px; border-radius: 9px; font-size: 13px; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #333a4a; }

/* auth gate */
.auth-gate {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(1200px 600px at 50% -10%, #20242b, var(--bg));
  display: grid; place-items: center; padding: 20px;
}
.auth-gate[hidden] { display: none; }
.auth-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px;
  padding: 34px 30px; max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow);
}
.auth-card .welcome-mark { margin: 0 auto 18px; }
.auth-card h2 { margin: 0 0 8px; font-size: 21px; }
.auth-card p { color: var(--text-dim); margin: 0 0 22px; font-size: 14px; }
.google-btn {
  display: inline-flex; align-items: center; gap: 10px; width: 100%; justify-content: center;
  background: #fff; color: #1f2937; border: none; border-radius: 11px; padding: 12px 16px;
  font-weight: 600; font-size: 15px; cursor: pointer; transition: filter .15s;
}
.google-btn:hover { filter: brightness(.96); }
.auth-error { color: var(--red); font-size: 13px; margin-top: 14px; }
.auth-error[hidden] { display: none; }

/* sidebar user area */
.user-area { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-area[hidden] { display: none; }
.user-email { flex: 1; font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: 6px; }

/* tap-outside backdrop for the mobile sidebar */
.sidebar-backdrop { display: none; }

/* mobile */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; z-index: 30; width: 280px; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .suggestions { grid-template-columns: 1fr; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 25; }
}
