/* shell.css — split-shell layout + theme tokens (no framework) */

:root {
  /* LogiCash palette (DECISIONS 19): iOS system palette, light */
  --bg: #F2F2F7;
  --surface: #ffffff;
  --border: #d8d8de;
  --text: #1C1C1E;
  --dim: #6b6b73;
  --accent: #007AFF;
  --accent2: #30B0C7;
  --success: #34C759;
  --danger: #FF3B30;
  --warning: #FF9500;
  --bar-h: 38px;
  --split-ratio: 62%;
  --resizer-w: 6px;
}

html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1C1C1E;
  --border: #38383A;
  --text: #F2F2F7;
  --dim: #98989F;
  --accent: #0A84FF;
  --accent2: #40C8E0;
  --success: #30D158;
  --danger: #FF453A;
  --warning: #FF9F0A;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1C1C1E;
    --border: #38383A;
    --text: #F2F2F7;
    --dim: #98989F;
    --accent: #0A84FF;
    --accent2: #40C8E0;
    --success: #30D158;
    --danger: #FF453A;
    --warning: #FF9F0A;
  }
}

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

html, body {
  height: 100%;
  overflow: hidden;
}
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
body.resizing { cursor: col-resize; user-select: none; }
/* During a divider drag the pointer passes over the EBX/chat iframes; without this they
   capture mousemove and the drag stalls (most noticeable dragging LEFT over the EBX frame).
   Disabling iframe pointer-events for the drag keeps every mousemove flowing to the parent. */
body.resizing iframe { pointer-events: none !important; }

.config-error {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--danger);
  color: #fff;
  padding: 24px;
  white-space: pre-wrap;
  font: 13px/1.5 ui-monospace, Menlo, monospace;
  overflow: auto;
}

/* ── Split shell grid ───────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--split-ratio) var(--resizer-w) 1fr;
  height: 100vh;
  width: 100vw;
}
.shell[data-chat-visible="false"] {
  grid-template-columns: 1fr 0 0;
}
.shell[data-chat-visible="false"] .resizer,
.shell[data-chat-visible="false"] .chat-pane {
  display: none;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  overflow: hidden;
}
.ebx-pane { border-right: 1px solid var(--border); }
.chat-pane { border-left: 1px solid var(--border); }

.pane-bar {
  flex-shrink: 0;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.pane-title { font-weight: 700; font-size: 13px; }
.pane-spacer { flex: 1; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  width: 28px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Floating "show chat" button — only appears when the chat pane is hidden, so the
   toggle is never lost together with the (now header-less) chat pane. */
/* right offset = 10px + 3.5 icon-widths (3.5 × 28px) so it clears the EBX user avatar. */
.chat-show-fab { position: fixed; top: 3px; right: 86px; z-index: 80; display: none; box-shadow: none; }
.shell[data-chat-visible="false"] .chat-show-fab { display: inline-flex; align-items: center; justify-content: center; }

/* ── Chat header: LogiCash primary bar + flat white icons ── */
:root { --ebx-blue: var(--accent); --ebx-blue-hover: rgba(255,255,255,.18); }
#chatPanel .pane-bar { background: var(--ebx-blue); border-bottom: 1px solid rgba(0,0,0,.12); color: #fff; }
#chatPanel .pane-bar .pane-title { color: #fff; }
/* flat header icons: no box, white glyph/SVG, subtle hover — harmonised with EBX */
#chatPanel .pane-bar .icon-btn {
  border: none; background: transparent; color: #fff; width: 28px; height: 26px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
}
#chatPanel .pane-bar .icon-btn:hover { background: var(--ebx-blue-hover); color: #fff; }
#chatPanel .pane-bar .icon-btn svg { display: block; }
/* sv | en language toggle */
.lang-toggle { display: inline-flex; margin-left: auto; border: 1px solid rgba(255,255,255,.55); border-radius: 6px; overflow: hidden; }
.lang-toggle button {
  border: none; background: transparent; color: #fff; font: 600 11px/1 inherit; text-transform: uppercase;
  padding: 5px 8px; cursor: pointer; letter-spacing: .03em;
}
.lang-toggle button + button { border-left: 1px solid rgba(255,255,255,.55); }
.lang-toggle button.on { background: #fff; color: var(--accent); }
.lang-toggle button:not(.on):hover { background: var(--ebx-blue-hover); }
/* MCP trigger on the blue bar */
#chatPanel .pane-bar .mcp-head .mcp-summary { color: rgba(255,255,255,.92); }
#chatPanel .pane-bar .mcp-head > summary:hover { background: var(--ebx-blue-hover); }
#chatPanel .pane-bar .mcp-head .mcp-refresh-btn { color: #fff; }
#chatPanel .pane-bar .mcp-head .mcp-pop { color: var(--text); }   /* dropdown stays light */
/* The foldout carries chat.css's .mcp-foldout, which paints a white --surface background
   (the "white box" on the blue bar that hid the white summary text). Strip it on the bar. */
#chatPanel .pane-bar #mcpPanel.mcp-foldout { background: transparent; border-top: none; }
/* floating show-chat fab: blue circle, white icon, visible over the white EBX pane */
/* Identical to the approved EBX-UI drawer launcher: transparent, 38x34 button, 32px white icon. */
.chat-show-fab { background: transparent; color: #fff; border: none; border-radius: 6px; width: 38px; height: 34px; }
.chat-show-fab:hover { background: rgba(255,255,255,.18); color: #fff; }
.chat-show-fab svg { width: 32px; height: 32px; }

.pane-body { flex: 1; position: relative; overflow: hidden; }
#ebxFrame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #fff;
}

/* ── Resizer ────────────────────────────────────────────────────── */
.resizer {
  position: relative;
  background: var(--border);
  cursor: col-resize;
  transition: background .12s;
}
.resizer:hover, .resizer:focus { background: var(--accent); outline: none; }
/* widen the clickable grab area ±6px without affecting layout, so the thin divider is easy to catch */
.resizer::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -6px; right: -6px; z-index: 5;
}

.health-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dim); margin-left: 8px; flex-shrink: 0;
}
.health-dot.ok { background: var(--success); }
.health-dot.err { background: var(--danger); }

/* ── MCP status foldout in the chat-pane header (dot + summary; click → list) ───── */
/* Anchor the dropdown to the FULL-WIDTH chat-pane header so the list spans the whole
   chat panel width (not a narrow box). */
#chatPanel .pane-bar { position: relative; }
.pane-bar .mcp-head { margin-left: 8px; }
.pane-bar .mcp-head > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 2px 6px; border-radius: 4px; outline: none;
}
.pane-bar .mcp-head > summary::-webkit-details-marker { display: none; }
.pane-bar .mcp-head > summary:hover { background: rgba(0,0,0,.06); }
.pane-bar .mcp-head .mcp-summary { font-size: 11.5px; color: var(--dim); }
.pane-bar .mcp-head .health-dot { margin-left: 0; }
.pane-bar .mcp-head .mcp-refresh-btn {
  border: none; background: transparent; cursor: pointer; font-size: 13px;
  color: var(--dim); padding: 0 2px; line-height: 1;
}
/* health dot colour driven by McpStatus's data-overall on the summary text span */
.pane-bar .mcp-head summary:has([data-overall="OK"]) .health-dot { background: var(--success); }
.pane-bar .mcp-head summary:has([data-overall="DEGRADED"]) .health-dot { background: var(--warning); }
.pane-bar .mcp-head summary:has([data-overall="FAILED"]) .health-dot,
.pane-bar .mcp-head summary:has([data-overall="UNKNOWN"]) .health-dot { background: var(--danger); }
/* dropdown panel overlaying the chat iframe */
.pane-bar .mcp-head .mcp-pop {
  position: absolute; top: 100%; left: 6px; right: 6px; z-index: 60;
  max-height: 62vh; overflow: auto;
  background: var(--panel, #fff); color: var(--text, #1f2937);
  border: 1px solid var(--border, #d1d5db); border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 10px 26px rgba(0,0,0,.18); padding: 8px;
}
/* roomier rows in the full-width dropdown */
.pane-bar .mcp-head .mcp-pop .mcp-row { padding: 5px 6px; }
.pane-bar .mcp-head .mcp-banner { color: var(--warning); font-size: 11.5px; padding: 4px 2px; }
