/* ============================================================
   BT Pro*C Assistant — drop-in stylesheet
   Skinned to match the BT OracleEBS AI Workspace aesthetic:
   near-black canvas, cyan/teal accents with soft glow, IBM Plex
   type, monospace micro-labels, rounded dark panels.
   Replaces frontend/style.css — no markup changes required.
   (Optional: add IBM Plex fonts in <head>, see note at bottom.)
   ============================================================ */

:root {
  --bg:            #0a0c10;
  --sidebar:       #0c0f14;
  --panel:         #12161c;
  --panel-2:       #0e1319;
  --border:        #1e242d;
  --border-soft:   #1a212b;
  --accent:        #22d3ee;   /* cyan  */
  --accent-2:      #2dd4bf;   /* teal  */
  --accent-soft:   #10222b;
  --accent-line:   #1e4550;
  --accent-ink:    #06222b;   /* text on cyan fills */
  --text:          #dfe4ea;
  --text-strong:   #e2e7ee;
  --muted:         #8a94a3;
  --label:         #5a6675;
  --ok:            #34d399;
  --warn:          #f0a44a;
  --danger:        #f2685c;
  --user-bubble-a: #15323a;
  --user-bubble-b: #123038;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden; /* each panel scrolls internally */
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

@keyframes bt-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: 292px 1fr 380px;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns .2s ease;
}
/* collapsed states — toggle these classes on .app (see JS at bottom) */
.app.left-collapsed  { grid-template-columns: 0 1fr 380px; }
.app.right-collapsed { grid-template-columns: 292px 1fr 0; }
.app.left-collapsed.right-collapsed { grid-template-columns: 0 1fr 0; }
.app.left-collapsed  .sidebar   { display: none; }
.app.right-collapsed .code-pane { display: none; }
/* when the sidebar is collapsed, keep the mode tabs clear of the ☰ toggle */
.app.left-collapsed .mode-tabs { padding-left: 62px; }

.sidebar, .code-pane {
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--border-soft);
  padding: 20px 18px;
  overflow-y: auto;
}
.code-pane {
  border-right: none;
  border-left: 1px solid var(--border-soft);
}

/* ---------- panel toggle buttons ---------- */
/* Small floating buttons pinned to the top corners of the window.
   Add the two <button> elements from the snippet at the bottom of this
   file; these rules style + position them. */
.panel-toggle {
  position: fixed;
  top: 14px;
  z-index: 50;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: border-color .15s, color .15s;
}
.panel-toggle:hover { border-color: var(--accent); color: #4fd6e6; }
.panel-toggle.left  { left: 14px; }
.panel-toggle.right { right: 14px; }

/* ---------- brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  margin-bottom: 24px;
  padding-bottom: 18px;
  padding-left: 44px; /* clear the fixed ☰ panel-toggle in the corner */
  border-bottom: 1px solid var(--border-soft);
}
.brand::before {
  content: "BT";
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, #2bb8e6, #2ee6c8);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(46,214,200,.3);
}

/* ---------- panels & labels ---------- */
.panel { margin-bottom: 26px; }
.panel h3 {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--label);
  font-weight: 600;
  margin: 0 0 11px 0;
}

/* ---------- upload ---------- */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px;
  border: 1px dashed #2a3542;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  color: #4fd6e6;
  background: var(--accent-soft);
  margin-bottom: 10px;
  transition: border-color .15s, background .15s;
}
.upload-btn:hover { border-color: var(--accent); background: #10222b; }
.upload-btn input { display: none; }

/* ---------- file list ---------- */
.file-list { list-style: none; padding: 0; margin: 0 0 10px 0; display: flex; flex-direction: column; gap: 7px; }
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 11px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.file-list li .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-strong);
}
.file-list li button {
  background: none;
  border: none;
  color: var(--label);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
}
.file-list li button:hover { color: var(--danger); }

.file-meta {
  color: var(--label);
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 4px;
}

/* ---------- ghost / reset button ---------- */
.ghost-btn {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1px solid #2f323a;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  transition: .15s;
}
.ghost-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- status block ---------- */
.status {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 12px;
}
.status .ok  { color: var(--ok); }
.status .bad { color: var(--danger); }
.status code { color: var(--text-strong); }

/* ---------- text inputs (git import) ---------- */
.text-input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  margin-bottom: 8px;
}
.text-input::placeholder { color: #4a5460; }
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px rgba(34,211,238,.35); }
.input-row { display: flex; gap: 7px; }
.input-row .text-input { flex: 1; min-width: 0; }

/* ---------- primary (gradient) buttons ---------- */
.primary-btn {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: var(--accent-ink);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  box-shadow: 0 0 16px rgba(34,211,238,.22);
  transition: box-shadow .15s;
}
.primary-btn:hover:not(:disabled) { box-shadow: 0 0 22px rgba(34,211,238,.42); }
.primary-btn:disabled { opacity: .5; cursor: default; box-shadow: none; }

.git-result {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- main column ---------- */
.main {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ---------- mode tabs ---------- */
.mode-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 14px 22px 0 22px;
}
.mode-tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--sans);
  transition: color .15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active {
  color: var(--accent-ink);
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* one-line description of the active tab */
.mode-desc {
  flex: 0 0 auto;
  padding: 8px 22px 10px 22px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
}
.app.left-collapsed .mode-desc { padding-left: 62px; }

/* ---------- chat scroll region ---------- */
.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- message bubbles ---------- */
.bubble {
  max-width: 80%;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  border-radius: 12px;
}
/* Only the user's plain-text bubble should preserve its own newlines. The
   assistant bubble is rendered markdown (HTML), where pre-wrap would turn the
   whitespace between block tags into spurious blank lines. */
.bubble.user {
  align-self: flex-end;
  white-space: pre-wrap;
  background: linear-gradient(135deg, var(--user-bubble-a), var(--user-bubble-b));
  border: 1px solid var(--accent-line);
  color: #e6f6f8;
  border-bottom-right-radius: 4px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble.error { border-color: var(--danger); color: var(--danger); background: #1a1015; }

/* "thinking" heartbeat bubble shown while awaiting /api/chat */
.bubble.thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}
.think-label { font-size: 12.5px; }
.think-secs { color: var(--label); font-family: var(--mono); font-size: 11.5px; }
.think-dots { display: inline-flex; gap: 4px; }
.think-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: think-blink 1.2s infinite ease-in-out both;
}
.think-dots span:nth-child(2) { animation-delay: .2s; }
.think-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes think-blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40%           { opacity: 1;   transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .think-dots span { animation: none; opacity: .6; }
}

/* live caret while an answer is streaming in */
.bubble.streaming .md::after {
  content: "▍";
  color: var(--accent);
  margin-left: 1px;
  animation: caret-blink 1s step-end infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .bubble.streaming .md::after { animation: none; }
}

/* citation chips inside a bubble */
.bubble .cites {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  font-size: 11.5px;
}
.bubble .cites span {
  display: inline-block;
  font-family: var(--mono);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  color: #4fd6e6;
  transition: background .15s;
}
.bubble .cites span:hover { background: #10222b; }

/* ---------- chat composer (Claude-style: chips row + attach + input) ---------- */
/* starter-prompt template chips above the composer */
.prompt-templates {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 22px 10px 22px;
}
.tmpl-chip {
  max-width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s, border-color .15s;
}
.tmpl-chip::before { content: "＋ "; color: var(--accent); }
.tmpl-chip:hover { border-color: var(--accent); color: var(--text); }

.chat-form {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin: 0 22px 18px 22px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s;
}
.chat-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(34,211,238,.25); }

/* attachment chips row (shown only when there are files) */
.composer-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.composer-chips:not(:empty) { margin-bottom: 10px; }
.attach-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 240px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 9px;
  padding: 7px 9px 7px 10px;
}
.attach-chip .ico {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.attach-chip .fname { font-family: var(--mono); font-size: 12px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .fsize { font-family: var(--mono); font-size: 10.5px; color: var(--label); }
.attach-chip button { flex: 0 0 auto; background: none; border: none; color: var(--label); cursor: pointer; font-size: 13px; padding: 2px; }
.attach-chip button:hover { color: var(--danger); }

/* input row: attach button + textarea + send */
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  outline: none;
  padding-top: 9px;
}
.chat-form textarea::placeholder { color: #4a5460; }

/* attach ("+") button */
.chat-form .attach-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
  box-shadow: none;
}
.chat-form .attach-btn:hover { border-color: var(--accent); color: #4fd6e6; }

/* send (submit) button */
.chat-form button[type="submit"] {
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: var(--accent-ink);
  padding: 10px 18px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 0 16px rgba(34,211,238,.25);
  transition: box-shadow .15s;
}
.chat-form button[type="submit"]:hover:not(:disabled) { box-shadow: 0 0 22px rgba(34,211,238,.45); }
.chat-form button[type="submit"]:disabled { opacity: .5; cursor: default; box-shadow: none; }
/* Stop state while a stream is in flight */
.chat-form button[type="submit"].stop {
  background: var(--danger);
  color: #fff;
}
.chat-form button[type="submit"].stop:hover:not(:disabled) { box-shadow: 0 0 22px rgba(242,104,92,.45); }

/* ---------- cited-code pane ---------- */
.code-pane h3 {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--label);
  font-weight: 600;
  margin: 0 0 14px 0;
}
.code-view .snippet-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: #4fd6e6;
  margin-bottom: 6px;
}
.code-view pre {
  margin: 0 0 16px 0;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  overflow-x: auto;
}
.hint { color: var(--muted); font-family: var(--mono); font-size: 12px; }

/* ---------- scrollbars ---------- */
.chat::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.code-pane::-webkit-scrollbar { width: 10px; }
.chat::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.code-pane::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.code-pane::-webkit-scrollbar-thumb {
  background: #212936;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.chat::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.code-pane::-webkit-scrollbar-thumb:hover { background: #2f3a4a; background-clip: content-box; }

/*
  Requires the IBM Plex font <link> in index.html <head> (already added).
  Collapsible side panels + Claude-style composer attach are wired in
  index.html (markup) and app.js (behavior) — this file only styles them.
*/

/* ---------- markdown content inside bubbles / modal ---------- */
.md h1, .md h2, .md h3, .md h4 {
  color: var(--text-strong);
  margin: 14px 0 6px;
  line-height: 1.3;
}
.md h1 { font-size: 17px; }
.md h2 { font-size: 15.5px; }
.md h3 { font-size: 14px; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li > p { margin: 2px 0; }
.md strong { color: var(--text-strong); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border-soft); margin: 14px 0; }
.md a { color: var(--accent); }
.md blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--accent-line);
  color: var(--muted);
}
.md code {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 12px;
}
.md pre {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.md pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.6;
}
.md table { border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
.md th, .md td { border: 1px solid var(--border-soft); padding: 6px 10px; }
.md th { color: var(--text-strong); background: var(--panel-2); }

/* ---------- per-message action row (copy / expand) ---------- */
.bubble-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.bubble-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--mono);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.bubble-actions button:hover { border-color: var(--accent); color: #4fd6e6; }

.truncated-note {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--warn);
  border: 1px solid #4a3620;
  background: #1c1710;
  border-radius: 8px;
  padding: 7px 10px;
}

/* ---------- "canvas" modal for viewing a full response ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,6,9,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-backdrop[hidden] { display: none; }
.modal-box {
  width: min(920px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.6;
}
