/**
 * css/views/chat-workspace.css
 * ----------------------------
 * Chat Workspace & Start Screen (Ai-Tools & ChatGPT style):
 * - #chatWorkspace with .is-new-chat bottom/center alignment
 * - #newChatHero greeting, title, and quick action chips
 * - #chatInputGroup with context status bar, URL input, and action triggers
 * - #chatArea scrollable container for messages and full-width audit reports
 */

.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-dark);
  position: relative;
  width: 100%;
  height: 100%;
  align-items: stretch;
}

/* User Profile Button: the avatar on its own, a circle in the top right corner.
   The agent's name and the chevron that used to sit beside it were spending
   header width on information the profile menu already carries. */
.user-profile-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.user-profile-pill:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}

.user-profile-pill:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.user-profile-pill .avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  font-weight: 800;
}

/* Profile Context Menu (Ai-Tools style) */
.profile-menu {
  position: absolute;
  top: 48px;
  right: 0;
  width: 310px;
  max-height: 85vh;
  overflow-y: auto;
  background: rgba(13, 18, 31, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  z-index: 10001;
  display: none;
  flex-direction: column;
  animation: menuFadeIn 0.2s ease-out;
}

.profile-menu.show {
  display: flex;
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-menu-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-bottom: 10px;
}

.user-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-small {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.user-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.user-plan {
  font-size: 0.72rem;
  color: var(--accent-emerald);
  font-family: var(--font-mono);
}

.profile-usage {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.015);
}

.profile-menu-items {
  padding: 8px 0;
}

.menu-item {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.menu-item i {
  width: 16px;
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
}

.menu-item:hover {
  background: rgba(16, 185, 129, 0.12);
  color: #fff;
}

.menu-item:hover i {
  color: var(--accent-emerald);
}

.divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

.model-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.model-badge i {
  color: var(--accent-emerald);
}

.status-indicator-pill {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 4px 10px;
  border-radius: 8px;
}

.status-indicator-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

/* Scrollable Chat Area */
.chat-scroll-area {
  flex: 1 1 0%;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  scroll-behavior: smooth;
  padding: 72px 20px 20px 20px;
}

.messages-column-v4 {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1100px;
  gap: 24px;
}

/* User & Assistant Message Bubbles */
.chat-msg {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: msgSlideUp 0.3s ease-out;
}

@keyframes msgSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg.user .msg-bubble {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #fff;
  border-radius: 16px 16px 2px 16px;
  padding: 12px 18px;
  max-width: 650px;
  font-size: 0.9rem;
}

.chat-msg.assistant .msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.chat-msg.assistant .msg-content-wrapper {
  flex: 1;
  min-width: 0;
}

/* ════ Folded report list ════ */
/* Folding steps every report card aside so the column reads as a conversation
   again; the rail's dots are the index and each one opens its own card. */
.chat-workspace.is-cards-collapsed .chat-msg.is-report {
  display: none;
}

.chat-workspace.is-cards-collapsed .chat-msg.is-report.is-solo {
  display: flex;
}

/* Strip carried only by the card that was pulled back out of the fold — it is
   also the way back for anyone who never thinks to tap the dot twice. */
.solo-report-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(6, 182, 212, 0.45);
  background: rgba(6, 182, 212, 0.07);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--accent-cyan);
}

.chat-msg.is-report.is-solo .solo-report-bar {
  display: flex;
}

.solo-return {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(6, 182, 212, 0.45);
  background: transparent;
  color: var(--accent-cyan);
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.solo-return:hover {
  background: rgba(6, 182, 212, 0.16);
}

/* AI Conversational Response Card */
.ai-response-card {
  background: rgba(13, 18, 31, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 20px;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.6;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.ai-response-card h4 {
  font-size: 0.98rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-response-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.ai-response-card ul {
  margin: 8px 0 14px 20px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.ai-response-card li {
  margin-bottom: 6px;
}

.ai-response-card li strong {
  color: var(--text-main);
}

.ai-metric-callout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.ai-metric-item {
  display: flex;
  flex-direction: column;
}

.ai-metric-item .lbl {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.ai-metric-item .val {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

.ai-response-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ════ NEW CHAT / START SCREEN STATE ════ */
.chat-workspace.is-new-chat {
  justify-content: center;
  align-items: center;
  padding-top: 56px;
  padding-bottom: var(--footer-h);
}

.chat-workspace.is-new-chat .chat-scroll-area {
  display: none !important;
}

.main-input-group {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 auto;
}

.chat-workspace.is-new-chat .main-input-group {
  flex: 0 0 auto;
}

/* Active Chat State: pinned at bottom right above the footer bar */
.chat-workspace:not(.is-new-chat) .main-input-group {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  background: rgba(10, 14, 26, 0.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  padding: 12px 20px 12px 20px;
  margin-bottom: var(--footer-h);
  z-index: 50;
}

.chat-workspace:not(.is-new-chat) .new-chat-hero {
  display: none !important;
}

/* New Chat Hero Greeting */
.new-chat-hero {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-vector-badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 16px;
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.35);
}

.new-chat-hero h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.new-chat-hero h1 span.highlight {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.new-chat-hero p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 560px;
  line-height: 1.5;
}

/* Task Chips */
.task-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

.task-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.task-chip:hover {
  background: rgba(16, 185, 129, 0.12);
  color: #fff;
  border-color: rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}

/* Chat Input Container */
.chat-input-container {
  width: 100%;
  max-width: 860px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-container:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.15);
}

/* Context Status Bar */
.context-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

/* Composer chips — Voice Mode and Tone, mirroring the Avi AI tool row. */
.tone-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tone-chip:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.16);
}

.tone-chip i {
  font-size: 0.68rem;
}

/* Voice Mode while the recogniser is actually live. */
.voice-chip.is-listening {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.12);
}

.voice-chip.is-listening i {
  animation: voicePulse 1.1s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

/* Check: same chip as Voice Mode, but it paints emerald and spins its icon for
   as long as a scan is in flight. The busy state is the only signal — a press
   while it is green is swallowed silently by runManualCheck(). */
.check-chip.is-checking {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.14);
}

.check-chip.is-checking i {
  animation: checkSpin 0.9s linear infinite;
}

@keyframes checkSpin {
  to { transform: rotate(360deg); }
}

/* Tone: a chip that opens the same icon menu the Avi AI tools use. The menu
   opens upward so it lands over the conversation and can never be pushed
   off-screen by the composer sitting at the bottom of the workspace. */
.tone-dropdown {
  position: relative;
  display: inline-flex;
}

.tone-trigger {
  font-weight: 600;
}

.tone-trigger #currentToneLabel {
  color: var(--text-main);
  font-weight: 700;
}

.tone-caret {
  font-size: 0.58rem;
  opacity: 0.7;
}

.tone-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 168px;
  padding: 4px;
  background: #0d1220;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}

.tone-menu[hidden] {
  display: none;
}

.tone-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tone-option i {
  width: 14px;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
}

.tone-option:hover,
.tone-option:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.tone-option[aria-checked="true"] {
  background: rgba(16, 185, 129, 0.14);
  color: var(--accent-emerald);
}

.tone-option[aria-checked="true"] i {
  color: var(--accent-emerald);
}

/* Horizon stays pinned to the right of the same row. */
.horizon-pill-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.ctx-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 700;
}

.horizon-mini-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.horizon-mini-pill.active {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.35);
}

/* Input Area */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-input-row i.link-icon {
  color: var(--text-dim);
  font-size: 1rem;
}

.chat-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.92rem;
  font-family: var(--font-sans);
}

.chat-input-row input::placeholder {
  color: var(--text-dim);
}

.chat-send-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.chat-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.5);
}

/* Recommendations: one derived list rendered twice — as lines in the Agent
   Vector stream, and as the numbered protocol cards underneath. Both surfaces
   take the same array, so the two can never disagree about the post. */
.rec-line {
  margin-bottom: 4px;
  font-size: 0.73rem;
  line-height: 1.45;
}

.rec-line:last-child {
  margin-bottom: 0;
}

.rec-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
}

.rec-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.rec-card-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.73rem;
  line-height: 1.4;
}

