/* ============================================
   Alva Shared Styles
   Fixed sidebar layout with scrollable main content
   ============================================ */

:root {
  --bg: #ffffff;
  --panel: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --accent: #14b8a6;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }
/* Global tooltip styles - faster appearance (40% faster) */
[title]:not([data-no-tooltip]) {
  position: relative;
  cursor: help;
}
.tooltip-custom {
  position: absolute;
  background: #1f2937;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.tooltip-custom.show {
  opacity: 1;
  transform: translateY(0);
}
.tooltip-custom::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1f2937;
}

/* ============================================
   BASE LAYOUT - Fixed sidebars, scrollable main
   ============================================ */

html, body {
  height: 100%;
  overflow: hidden; /* Prevent body scrolling */
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 100vh;
  grid-template-areas: "sidebar main";
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* Body with subnav open */
body.subnav-open {
  grid-template-columns: 260px 220px 1fr;
  grid-template-areas: "sidebar subnav main";
}

/* Body with chat panel */
body.has-chat-panel {
  grid-template-columns: 260px 1fr 360px;
  grid-template-areas: "sidebar main chat";
}

/* Body with both subnav and chat */
body.subnav-open.has-chat-panel {
  grid-template-columns: 260px 220px 1fr 360px;
  grid-template-areas: "sidebar subnav main chat";
}

/* Sidebar collapsed state */
body.sidebar-collapsed {
  grid-template-columns: 60px 1fr;
}
body.sidebar-collapsed.has-chat-panel {
  grid-template-columns: 60px 1fr 360px;
}
body.sidebar-collapsed.subnav-open {
  grid-template-columns: 60px 220px 1fr;
}
body.sidebar-collapsed.subnav-open.has-chat-panel {
  grid-template-columns: 60px 220px 1fr 360px;
}

body.sidebar-collapsed .name,
body.sidebar-collapsed .nav-top,
body.sidebar-collapsed .nav-scroll,
body.sidebar-collapsed .nav-bottom,
body.sidebar-collapsed .nav-new-chat {
  display: none;
}
body.sidebar-collapsed .icon-rail { display: flex; }

/* ============================================
   LEFT SIDEBAR (Fixed)
   ============================================ */

aside {
  grid-area: sidebar;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid #3a3a48;
  background: #2A2A38;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.side-brand .logo {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  box-shadow: 0 0 0 1px #0b5d31 inset;
}

.side-brand .name {
  font-size: 13px;
  color: #e5e7eb;
}

.collapse-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 8px;
  width: 24px;
  height: 24px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
}
.collapse-btn:hover { border-color: #14b8a6; }

.icon-rail {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px;
}

.rail-btn {
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.rail-btn:hover { border-color: #24513b; }
.rail-btn svg { width: 18px; height: 18px; fill: #a7f3d0; opacity: 0.9; }

.nav-new-chat { padding: 0 6px 6px; }
.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #111827;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.new-chat-btn:hover { background: #ffffff; }
.new-chat-btn svg { width: 14px; height: 14px; fill: #374151; }

.nav-top { padding: 4px 0; }
.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}
.nav-bottom {
  padding-top: 12px;
  border-top: 1px solid #3a3a48;
  position: sticky;
  bottom: 0;
  background: #2A2A38;
}

.section { display: flex; flex-direction: column; gap: 6px; }
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.6px;
  padding: 0 6px;
}
aside .section-title { color: #cbd5e1; }

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.title-plus {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 6px;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}
.title-plus:hover { border-color: #14b8a6; color: #0f766e; }

.with-divider {
  border-top: 1px solid #182030;
  padding-top: 8px;
  margin-top: 4px;
}

ul { list-style: none; margin: 0; padding: 0; }
li { display: block; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0 4px;
}

aside a,
.subnav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}
aside a:hover,
.subnav a:hover { background: #e2e8f0; }
aside a { color: #e5e7eb; }
aside a:hover { background: rgba(255,255,255,0.06); color: #ffffff; }
aside a.active { background: rgba(255,255,255,0.10); color: #ffffff; }

.nav-external-icon {
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transform: translateY(1px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
a:hover .nav-external-icon,
a:focus-visible .nav-external-icon {
  opacity: 1;
  transform: translateY(0);
}
.nav-external-icon svg {
  width: 10px;
  height: 10px;
}

.badge { margin-left: auto; font-size: 10px; color: var(--muted); }
.more { color: var(--muted); }
.more:hover { color: var(--text); }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-left: 6px;
  box-shadow: 0 0 0 2px #ffffff;
}

.me-icons { display: flex; gap: 8px; }
.icon-btn {
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { border-color: #24513b; }
.icon-btn svg { width: 18px; height: 18px; fill: #a7f3d0; opacity: 0.9; }

.nav-bottom .icon-btn { width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.nav-bottom .icon-btn svg { width: 16px; height: 16px; }

/* ============================================
   SUBNAV (Secondary sidebar - Fixed)
   ============================================ */

.subnav {
  grid-area: subnav;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: #ffffff;
  display: none;
  flex-direction: column;
}
body.subnav-open .subnav { display: flex; }

.subnav a { color: #111827; }
.subnav a:hover { background: #f1f5f9; color: #111827; }

.subnav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.subnav-title { font-size: 13px; font-weight: 600; }
.subnav-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}
.subnav-content ul { display: flex; flex-direction: column; gap: 4px; }
.subnav-close {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
}

/* ============================================
   MAIN CONTENT (Scrollable)
   ============================================ */

main {
  grid-area: main;
  overflow-y: auto;
  height: 100vh;
  padding: 16px;
}

/* Hide scrollbar but keep functionality */
main::-webkit-scrollbar { width: 8px; }
main::-webkit-scrollbar-track { background: transparent; }
main::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
main::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================
   RIGHT CHAT PANEL (Fixed)
   ============================================ */

.chat-panel {
  grid-area: chat;
  height: 100vh;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  flex-direction: column;
}

.chat-panel .hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-panel .bd {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.chat-panel .chat-compose {
  padding: 8px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
}

/* Chat input card - new design */
.chat-input-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.chat-textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  min-height: 60px;
  line-height: 1.5;
  outline: none;
}

.chat-textarea::placeholder {
  color: var(--muted);
}

/* Mention chips container - floating above textarea */
.mention-chips-container {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
  height: 28px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.mention-chips-container::-webkit-scrollbar {
  height: 4px;
}

.mention-chips-container::-webkit-scrollbar-track {
  background: transparent;
}

.mention-chips-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.chat-input-card.has-mentions .chat-textarea {
  margin-top: 40px;
}

.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: #0f766e;
  font-weight: 500;
  pointer-events: auto;
  flex-shrink: 0;
  white-space: nowrap;
  max-width: 200px;
}

.mention-chip-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mention-chip-icon svg {
  width: 12px;
  height: 12px;
  fill: #14b8a6;
}

.mention-chip-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-chip-remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #14b8a6;
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.mention-chip-remove:hover {
  background: #a7f3d0;
}

.mention-chip-remove svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.build-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: #f3f4f6;
  color: #374151;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.build-btn:hover {
  background: #e5e7eb;
}

.build-btn svg {
  width: 14px;
  height: 14px;
  fill: #6b7280;
}

.build-btn span {
  color: #6b7280;
  font-size: 10px;
  margin-left: 2px;
}

.build-btn-dd {
  position: relative;
}

.build-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: none;
  padding: 4px;
  z-index: 30;
  min-width: 100px;
}

.build-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.build-menu-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  color: #374151;
  transition: background 0.2s ease;
}

.build-menu-item:hover {
  background: #f8fafc;
}

.build-menu-item.active {
  background: #ecfdf5;
  color: #0f766e;
}

.build-menu-item svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Add Context Menu */
.add-context-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  max-width: 330px;
  max-height: 360px;
  overflow: hidden;
  z-index: 50;
}

.add-context-menu.open {
  display: flex;
}

.add-context-header {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  color: #111827;
}

.add-context-body {
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.add-context-category {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.add-context-category-title {
  font-size: 9px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 5px;
}

.add-context-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 11px;
  color: #111827;
}

.add-context-item:hover {
  background: #f8fafc;
}

.add-context-item-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.add-context-item-icon svg {
  width: 12px;
  height: 12px;
  fill: #6b7280;
}

.add-context-item-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.add-context-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.add-context-item-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  flex-shrink: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #374151;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
}

.toolbar-icon-btn:hover {
  background: #f3f4f6;
}

.toolbar-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: #6b7280;
}

.toolbar-icon-btn.send-btn {
  background: #f3f4f6;
}

.toolbar-icon-btn.send-btn:hover {
  background: #e5e7eb;
}

.toolbar-icon-btn.send-btn svg {
  fill: #374151;
}

/* Chat panel collapsed state - shrinks panel to toggle button width */
body.chat-collapsed {
  grid-template-columns: 260px 1fr 48px;
}
body.chat-collapsed.sidebar-collapsed {
  grid-template-columns: 60px 1fr 48px;
}
body.chat-collapsed.subnav-open {
  grid-template-columns: 260px 220px 1fr 48px;
}
body.chat-collapsed.sidebar-collapsed.subnav-open {
  grid-template-columns: 60px 220px 1fr 48px;
}

.chat-panel.collapsed .hd {
  padding: 12px 14px;
  justify-content: center;
}
.chat-panel.collapsed .title {
  display: none;
}
.chat-panel.collapsed .bd {
  display: none;
}
.chat-panel.collapsed .toggle {
  padding: 4px;
  border: 0;
  background: transparent;
  position: relative;
}
.chat-panel.collapsed .toggle:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  white-space: nowrap;
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
  z-index: 10;
  font-size: 13px;
}

/* ============================================
   SHARED COMPONENTS
   ============================================ */

.hidden { display: none; }

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,8,23,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.search-overlay.open { display: flex; }

.search-modal {
  width: min(760px, 92vw);
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; }
.modal-close {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
}
.modal-body { padding: 12px 14px; }
.modal-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.entity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow: auto;
}
.entity-row {
  display: grid;
  grid-template-columns: 80px 1fr 90px 100px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
}
.entity-row:hover { background: #f8fafc; }
.sym { font-weight: 600; letter-spacing: 0.4px; }
.type { color: var(--muted); font-size: 12px; }
.exch { color: #a7f3d0; font-size: 12px; }

.nav-popover {
  position: fixed;
  top: 70px;
  left: 260px;
  width: 380px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  display: none;
  z-index: 900;
}
body.sidebar-collapsed .nav-popover { left: 60px; }
.nav-popover.open { display: block; }
.nav-popover .pop-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.nav-popover .pop-bd { padding: 12px 14px; }
.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 10px;
  padding: 14px 8px;
  cursor: pointer;
  text-decoration: none;
}
.action-btn:hover { border-color: #cbd5e1; }
.act-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.act-ico svg { width: 18px; height: 18px; }
.ico-blue { background: #0b3a55; }
.ico-orange { background: #5a3a0b; }
.ico-green { background: #0b3a2a; }
.ico-purple { background: #3a0b55; }
.label {
  font-size: 13px;
  color: #374151;
  font-weight: 600;
}
.popover-close {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
}

/* ============================================
   PAGE-SPECIFIC OVERRIDES
   (Each page can add more styles after this)
   ============================================
*/

/* THREAD / CHAT STYLES */
.thread-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding: 0;
  background: #ffffff;
  /* Ensure it fits in the grid area defined in body */
  grid-area: main; 
}

.thread-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  z-index: 10;
}
.thread-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}
.action-icon-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.action-icon-btn:hover { background: #f9fafb; border-color: #d1d5db; }

.thread-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.user-message-box {
  background: #ecfdf5; /* Light green bg */
  border: 1px solid #d1fae5;
  border-radius: 12px;
  padding: 16px;
  color: #065f46;
  font-size: 15px;
  line-height: 1.5;
}

.ai-response {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #14b8a6;
  font-weight: 600;
}
.ai-meta svg { width: 14px; height: 14px; }

.ai-content {
  font-size: 15px;
  line-height: 1.6;
  color: #374151;
}
.ai-content p { margin-bottom: 12px; }
.ai-content a { color: #14b8a6; text-decoration: none; font-weight: 500; }
.ai-content strong { color: #111827; display: block; margin-top: 16px; margin-bottom: 8px; }
.ai-content ul { padding-left: 20px; list-style: disc; margin-bottom: 12px; }
.ai-content li { margin-bottom: 4px; }

.chart-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-top: 12px;
}
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}
.chart-tabs {
  display: flex;
  gap: 24px;
}
.chart-tab {
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  padding: 8px 0;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
}
.chart-tab.active {
  color: #111827;
  border-bottom-color: #14b8a6;
}
.chart-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-chat-alva {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-chat-alva:hover { background: #f3f4f6; }
.btn-icon-only {
  width: 28px;
  height: 28px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s;
}
.btn-icon-only:hover { background: #f3f4f6; color: #374151; }

.chart-viz-container {
  width: 100%;
  height: 320px;
  background: #ffffff;
}

.input-area-wrapper {
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}
.input-box {
  display: flex;
  align-items: center;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 8px 12px;
  gap: 12px;
}
.input-box input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 14px;
  outline: none;
  color: #111827;
}
.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: #ffffff;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.2s;
}
.input-btn:hover { color: #14b8a6; }

/* ============================================
   EDIT HISTORY PANEL
   ============================================ */
.edit-history-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-height: 480px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.edit-history-panel.open {
  display: flex;
}

.edit-history-body {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.edit-history-section {
  border-bottom: 1px solid var(--border);
}

.edit-history-section:last-child {
  border-bottom: none;
}

.edit-history-section-header {
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edit-history-discard-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #9ca3af;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.edit-history-discard-btn:hover {
  color: #ef4444;
  background: #fef2f2;
}

.edit-history-discard-btn svg {
  width: 14px;
  height: 14px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.edit-history-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.edit-history-item:hover {
  background: #f8fafc;
}

.edit-history-item.viewing {
  background: #f0fdf4;
}

.edit-history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.edit-history-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-history-version {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.edit-history-item.viewing .edit-history-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #14b8a6;
}

.edit-history-item .edit-history-check {
  display: none;
}

.edit-history-description {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  margin-bottom: 4px;
}

.edit-history-timestamp {
  font-size: 11px;
  color: #9ca3af;
}

/* Scroll indicator for history list */
.edit-history-body::-webkit-scrollbar {
  width: 6px;
}

.edit-history-body::-webkit-scrollbar-track {
  background: transparent;
}

.edit-history-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.edit-history-body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Position container for history panel */
.hd-actions {
  position: relative;
}
