/* ═══════════════════════════════════════════════════
   views.css — Right-panel view styles
═══════════════════════════════════════════════════ */

/* ── View shell ── */
.view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  animation: fadeSlide 0.2s ease;
}
.view.active { display: flex; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.view-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--rim);
  flex-shrink: 0;
}
.view-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.view-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.view-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* ── Connect view ── */
.connect-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}
.connect-title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--phosphor);
  text-shadow: 0 0 20px rgba(0,255,136,0.3);
  letter-spacing: 0.05em;
}
.connect-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Upload zone ── */
.upload-zone {
  border: 1px dashed var(--rim2);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(26,36,64,0.3);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--phosphor);
  background: rgba(0,255,136,0.04);
}
.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,255,136,0.05) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s;
}
.upload-zone:hover::before { opacity: 1; }
.upload-icon { font-size: 1.8rem; margin-bottom: 8px; }
.upload-text { font-size: 0.78rem; color: var(--muted); line-height: 1.6; }
.upload-text strong { color: var(--phosphor); }
#fileInput { display: none; }

/* ── Progress card ── */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  display: none;
}
.progress-card.visible { display: block; }
.progress-filename {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress-status   { font-size: 0.68rem; color: var(--muted); margin-bottom: 8px; }
.progress-bar-track { height: 3px; background: var(--rim); border-radius: 2px; overflow: hidden; }
.progress-bar-fill  {
  height: 100%;
  background: var(--phosphor);
  box-shadow: 0 0 8px var(--phosphor);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ── Category review card ── */
.cat-review-card {
  background: var(--surface);
  border: 1px solid var(--amber);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  display: none;
}
.cat-review-card.visible { display: block; }
.cat-review-title  { font-size: 0.72rem; color: var(--amber); font-family: var(--font-mono); margin-bottom: 4px; }
.cat-review-file   { font-size: 0.8rem; color: var(--text); font-weight: 600; margin-bottom: 12px; }
.detected-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(245,166,35,0.1);
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--amber);
  margin-bottom: 12px;
}

/* ── Doc list ── */
.cat-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 4px;
  margin-top: 4px;
}
.cat-group-name {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.cat-count-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--faint);
  color: var(--muted);
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 7px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.doc-item:hover   { border-color: var(--rim2); background: var(--raised); }
.doc-item.selected { border-color: var(--phosphor); background: rgba(0,255,136,0.04); }

.doc-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-meta { font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); margin-top: 2px; }

.doc-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.doc-item:hover .doc-actions { opacity: 1; }

.doc-action-btn {
  width: 24px; height: 24px;
  border: 1px solid var(--rim);
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.doc-action-btn:hover        { border-color: var(--phosphor); color: var(--phosphor); }
.doc-action-btn.danger:hover { border-color: var(--red);      color: var(--red); }

/* ── Inspect view ── */
.inspect-hero {
  padding: 20px;
  border-bottom: 1px solid var(--rim);
  flex-shrink: 0;
}
.inspect-type-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.inspect-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 10px;
  word-break: break-word;
}
.inspect-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid;
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.inspect-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rim);
  flex-shrink: 0;
}
.stat-box { background: var(--surface); border: 1px solid var(--rim); border-radius: 7px; padding: 10px 12px; }
.stat-box-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.stat-box-val { font-family: var(--font-mono); font-size: 0.9rem; color: var(--phosphor); font-weight: 600; }

/* ── Chat view ── */
.chat-filter {
  padding: 8px 20px;
  border-bottom: 1px solid var(--rim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chat-filter-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.filter-select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 4px 8px;
  outline: none;
  margin-bottom: 0;
}
.filter-select:focus { border-color: var(--phosphor); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.msg { display: flex; flex-direction: column; gap: 4px; animation: msgIn 0.2s ease; max-width: 100%;
  min-width: 0;}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg-role { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; }
.msg.user      .msg-role { color: var(--amber); }
.msg.assistant .msg-role { color: var(--phosphor); }

.msg-bubble { padding: 10px 14px; border-radius: 8px; font-size: 0.82rem; line-height: 1.65; max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;}
.msg.user      .msg-bubble { background: rgba(245,166,35,0.07); border: 1px solid rgba(245,166,35,0.15); color: var(--text); }
.msg.assistant .msg-bubble { background: var(--surface); border: 1px solid var(--rim); color: var(--text); }

.sources-toggle {
  margin-top: 6px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--rim);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  cursor: pointer;
  text-align: left;
  width: fit-content;
  transition: all 0.12s;
}
.sources-toggle:hover { border-color: var(--phosphor); color: var(--phosphor); }

.sources-panel { margin-top: 6px; display: none; flex-direction: column; gap: 6px; }
.sources-panel.open { display: flex; }

.source-chip {
  padding: 7px 10px;
  background: var(--raised);
  border: 1px solid var(--rim);
  border-left: 3px solid var(--phosphor);
  border-radius: 5px;
  font-size: 0.72rem;
}
.source-chip.medium { border-left-color: var(--amber); }
.source-chip.low    { border-left-color: var(--red); }
.source-chip-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.source-chip-name   { font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); }
.source-chip-score  { font-family: var(--font-mono); font-size: 0.6rem; color: var(--phosphor); }
.source-chip.medium .source-chip-score { color: var(--amber); }
.source-chip.low    .source-chip-score { color: var(--red); }
.source-chip-text   { color: var(--text); font-size: 0.75rem; line-height: 1.5; }

.thinking-dots { display: flex; gap: 4px; padding: 4px 0; }
.thinking-dots span {
  width: 6px; height: 6px;
  background: var(--phosphor);
  border-radius: 50%;
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%,80%,100% { transform: scale(0.6); opacity: 0.4; }
  40%          { transform: scale(1);   opacity: 1; }
}

.chat-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--rim);
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--rim);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 10px 14px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.15s;
  margin-bottom: 0;
}
.chat-input:focus { border-color: var(--phosphor); }

.chat-send {
  width: 40px; height: 40px;
  background: var(--phosphor);
  border: none;
  border-radius: 8px;
  color: var(--void);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-weight: 700;
}
.chat-send:hover    { background: var(--phosphor2); transform: scale(1.04); }
.chat-send:disabled { background: var(--rim); cursor: not-allowed; transform: none; }

/* Image Gallery in Chat */
.msg-image-gallery {
  display: flex;
  flex-direction:row; 
  gap: 10px;
  margin-top: 12px;
  width: 100%; /* Prevents breaking out of the bubble */
  overflow-x: auto; /* Lets you swipe through images left-to-right */
  padding-bottom: 8px;
}

.chat-image {
  max-height: 400px; /* CRITICAL: Stops vertical screen takeover */
  width: auto;
  object-fit: contain; /* Ensures the whole diagram fits without stretching */
  border-radius: 8px;
  background: white; /* Adds a white background in case the diagram has transparent text */
  border: 1px solid var(--rim);
  cursor: zoom-in;
}

.chat-image:hover {
  transform: scale(1.02);
  border-color: var(--phosphor);
}

/* Markdown Styles */
.code-block {
  background: var(--void);
  padding: 12px;
  border-radius: 6px;
  margin: 10px 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border: 1px solid var(--rim);
  overflow-x: auto;
}

.inline-code {
  background: var(--rim);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}


.alpha-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.alpha-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 36px;
}
#alphaSlider {
  width: 60px;
  height: 3px;
  accent-color: var(--phosphor);
  cursor: pointer;
  margin-bottom: 0;
  padding: 0;
  border: none;
  background: transparent;
}