/* Claire Web UI — Dark Executive Theme */

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

:root {
  --bg:        #0f1117;
  --bg2:       #161b27;
  --bg3:       #1e2536;
  --border:    #2a3249;
  --accent:    #5b6ef5;
  --accent-h:  #7080ff;
  --text:      #e2e6f3;
  --text-dim:  #7b869e;
  --danger:    #e05c5c;
  --success:   #4caf7d;
  --radius:    8px;
  --font:      'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  height: 100dvh;
  overflow: hidden;
}

/* ── Login ── */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 40% 40%, #1a2040 0%, var(--bg) 70%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.logo-mark {
  font-size: 32px;
  color: var(--accent);
  line-height: 1;
}

.logo-text { display: flex; flex-direction: column; }
.logo-name  { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.logo-sub   { font-size: 11px; color: var(--text-dim); letter-spacing: 0.3px; }

.alert-error {
  background: rgba(224,92,92,.15);
  border: 1px solid rgba(224,92,92,.4);
  color: #f08080;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.login-form input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 10px 13px;
  outline: none;
  transition: border-color .15s;
}

.login-form input:focus { border-color: var(--accent); }
.login-form input::placeholder { color: var(--text-dim); }

.btn-primary {
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }

/* ── App layout ── */
.app-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Panel rail (leftmost icon column) ── */
.panels-rail {
  width: 64px;
  flex-shrink: 0;
  background: #0a0c14;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 6px;
}
.rail-brand {
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 12px;
}
.rail-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.rail-item {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 8px 6px;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
}
.rail-item:hover { background: var(--bg2); }
.rail-item.active {
  background: var(--bg2);
  border-left-color: var(--accent);
}
.rail-pill {
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 7px;
  border-radius: 4px;
  font-family: var(--mono);
}
.rail-item.active .rail-pill {
  background: var(--accent);
  color: #fff;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
}

.sidebar-current-panel {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.btn-new-chat {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background .12s;
}
.btn-new-chat:hover { background: var(--accent-h); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 6px 0;
  padding-right: 2px;
}

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 12px 8px;
  text-align: center;
  font-style: italic;
}

.chat-row {
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: background .1s;
  position: relative;
}
.chat-row:hover { background: var(--bg3); }
.chat-row.active { background: var(--bg3); }
.chat-row.active .chat-name { color: var(--text); font-weight: 600; }

.chat-name {
  flex: 1;
  background: none;
  border: none;
  text-align: left;
  color: var(--text-dim);
  font-size: 13px;
  padding: 7px 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}

.chat-actions {
  display: none;
  gap: 2px;
  padding-right: 4px;
}
.chat-row:hover .chat-actions,
.chat-row.active .chat-actions { display: flex; }

.chat-act {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, color .1s;
}
.chat-act:hover { background: var(--border); color: var(--text); }
.chat-del:hover { color: var(--danger); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.sidebar-brand .logo-mark { font-size: 18px; color: var(--accent); }
.sidebar-brand .logo-name  { font-size: 15px; font-weight: 700; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-email {
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ── Chat main ── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.header-title { font-size: 14px; font-weight: 600; }

.conn-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}
.conn-connecting { background: rgba(255,200,0,.1); color: #e0b840; }
.conn-open       { background: rgba(76,175,125,.1); color: var(--success); }
.conn-closed     { background: rgba(224,92,92,.1);  color: var(--danger); }

/* ── Messages ── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 12px; max-width: 820px; }
.msg.user  { align-self: flex-end; flex-direction: row-reverse; }
.msg.claire { align-self: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.claire .msg-avatar { background: var(--bg3); color: var(--accent); }
.user   .msg-avatar { background: var(--accent); color: #fff; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  max-width: 680px;
  line-height: 1.65;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.claire .msg-bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}
.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Status / step messages */
.msg-status {
  align-self: flex-start;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 12px;
  font-style: italic;
}

/* Markdown elements inside .msg-bubble */
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin: 14px 0 8px; line-height: 1.3; font-weight: 700;
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 14px; color: var(--accent-h); }
.msg-bubble hr {
  border: 0; border-top: 1px solid var(--border); margin: 12px 0;
}
.msg-bubble ul, .msg-bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble code {
  background: rgba(91,110,245,.15);
  color: #b8c2ff;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 4px;
}
.msg-bubble pre.md-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 8px 0;
  overflow-x: auto;
}
.msg-bubble pre.md-code code {
  background: none; padding: 0; color: var(--text);
  font-size: 12.5px; display: block; white-space: pre;
}
.msg-bubble a { color: var(--accent-h); text-decoration: underline; }
.msg-bubble strong { color: #fff; font-weight: 700; }
.msg-bubble em { font-style: italic; color: #c4cce8; }

table.md-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
  width: 100%;
}
table.md-table th, table.md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
table.md-table th {
  background: var(--bg3);
  font-weight: 600;
  color: var(--accent-h);
}
table.md-table tr:nth-child(even) td { background: rgba(91,110,245,.04); }

/* user bubble overrides — keep contrast */
.user .msg-bubble code { background: rgba(255,255,255,.2); color: #fff; }
.user .msg-bubble strong { color: #fff; }
.user .msg-bubble a { color: #d8defc; }

/* ── Toolbox ── */
.tools-side { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.side-link:hover { background: var(--bg3); color: var(--text); }

.tools-canvas { padding: 24px 32px; overflow-y: auto; }
.tools-section { margin-bottom: 32px; scroll-margin-top: 16px; }
.tools-h {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tool-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: transform .12s, border-color .12s, background .12s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--bg3);
}
.tc-icon { font-size: 24px; }
.tc-label { font-size: 14px; font-weight: 700; }
.tc-desc { font-size: 12px; color: var(--text-dim); line-height: 1.4; }

/* Card accent stripes */
.tool-card.tc-purple { border-top: 3px solid #8b5cf6; }
.tool-card.tc-blue   { border-top: 3px solid #3b82f6; }
.tool-card.tc-amber  { border-top: 3px solid #f59e0b; }
.tool-card.tc-teal   { border-top: 3px solid #14b8a6; }
.tool-card.tc-cyan   { border-top: 3px solid #06b6d4; }
.tool-card.tc-pink   { border-top: 3px solid #ec4899; }
.tool-card.tc-indigo { border-top: 3px solid #6366f1; }
.tool-card.tc-red    { border-top: 3px solid #ef4444; }

.tool-output {
  margin-top: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  color: var(--text);
}

/* ── Inbox dropzone (Toolbox) ── */
.dropzone {
  margin-top: 14px;
  background: var(--bg2);
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  transition: background .12s, border-color .12s;
}
.dropzone.dz-over {
  background: rgba(91,110,245,.08);
  border-color: var(--accent);
}
.dz-icon { font-size: 36px; margin-bottom: 10px; }
.dz-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.dz-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.dz-sub code {
  background: var(--bg3);
  color: #b8c2ff;
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
}
.dz-link {
  background: none;
  border: none;
  color: var(--accent-h);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.dz-hint { font-size: 11.5px; color: var(--text-dim); }

.dz-uploaded { margin-top: 14px; text-align: left; }
.dz-status {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 8px;
}
.dz-status code {
  background: var(--bg3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 4px;
}
.dz-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.dz-list li { font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.dz-ok  { background: rgba(76,175,125,.1); color: #b6e0c7; }
.dz-err { background: rgba(224,92,92,.1); color: #f0a0a0; }
.dz-size { color: var(--text-dim); font-size: 11.5px; margin-left: 6px; }

.inbox-listing { margin-top: 18px; }
.inbox-empty {
  font-size: 12.5px;
  color: var(--text-dim);
  font-style: italic;
  padding: 10px 0;
}
.inbox-h {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.inbox-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.inbox-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
}
.il-name { color: var(--text); font-family: var(--mono); }
.il-size { color: var(--text-dim); font-size: 11.5px; }

/* ── Chat-panel drag-drop overlay ── */
.chat-main { position: relative; }
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,17,23,.85);
  border: 3px dashed var(--accent);
  border-radius: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}
.drop-overlay.active { display: flex; }
.drop-overlay-inner {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-h);
  background: var(--bg2);
  padding: 24px 36px;
  border-radius: 12px;
  border: 1px solid var(--accent);
}

/* ── Input area (attachments + input bar) ── */
.input-area {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 12px 24px 16px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.attachments:empty { display: none; }

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px 4px 10px;
  font-size: 12px;
  color: var(--text);
  max-width: 240px;
}
.attach-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.attach-chip-size {
  color: var(--text-dim);
  font-size: 11px;
}
.attach-chip-x {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
}
.attach-chip-x:hover { background: var(--border); color: var(--danger); }

.input-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* Attach button + popover menu */
.attach-menu-wrap { position: relative; flex-shrink: 0; }

.btn-attach {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-attach:hover, .btn-attach.open {
  background: var(--bg3);
  border-color: var(--accent);
  color: var(--accent-h);
}

.attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  z-index: 100;
}
/* Force hidden when [hidden] is set (overrides display: flex above) */
.attach-menu[hidden] { display: none !important; }
.attach-item {
  background: none;
  border: none;
  text-align: left;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  transition: background .1s;
}
.attach-item:hover { background: var(--bg3); }
.attach-icon { font-size: 16px; }

/* Textarea — much taller, supports long-form input */
.msg-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 11px 14px;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 500px;          /* ~30 lines visible, ~2000+ words capacity */
  overflow-y: auto;
  transition: border-color .15s;
  line-height: 1.5;
}
.msg-input:focus { border-color: var(--accent); }
.msg-input::placeholder { color: var(--text-dim); }

.btn-send {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
  height: 42px;
}
.btn-send:hover:not(:disabled) { background: var(--accent-h); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }

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

/* Responsive: hide sidebar on small screens */
@media (max-width: 600px) {
  .sidebar { display: none; }
}
