/* ── AI CHAT WIDGET ── */
.chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--chat-accent, #10a37f); border: none; cursor: pointer;
  box-shadow: 0 4px 16px rgba(16,163,127,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: scale(1.1); box-shadow: 0 6px 24px rgba(16,163,127,0.6); }
.chat-fab svg { width: 22px; height: 22px; fill: white; }
@keyframes chat-sparkle {
  0%,100% { box-shadow: 0 4px 16px rgba(16,163,127,0.4); }
  50% { box-shadow: 0 0 24px rgba(16,163,127,0.8), 0 0 48px rgba(16,163,127,0.3); }
}
.chat-fab.sparkle { animation: chat-sparkle 1.5s ease-in-out; }

#ai-chat-popup {
  position: fixed; bottom: 84px; right: 24px; z-index: 1001;
  width: 400px; max-height: 520px;
  background: rgba(10,10,11,0.95); backdrop-filter: blur(12px);
  border: 1px solid rgba(16,163,127,0.3); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 40px rgba(16,163,127,0.1);
  display: flex; flex-direction: column;
  font-family: var(--mono);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  opacity: 1; transform: translateY(0);
}
#ai-chat-popup.hidden {
  opacity: 0; transform: translateY(20px); pointer-events: none;
}
.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(16,163,127,0.2);
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.3); border-radius: 12px 12px 0 0;
}
.chat-header h3 {
  font-size: 13px; font-weight: 500; color: var(--chat-accent, #10a37f);
  font-family: var(--mono); letter-spacing: 0.5px;
}
.chat-header h3::before { content: '> '; opacity: 0.5; }
.chat-close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 18px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: all 0.2s;
}
.chat-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  max-height: 260px; font-size: 13px; line-height: 1.5;
}
.chat-message {
  margin-bottom: 10px; padding: 10px 12px; border-radius: 6px;
  font-size: 13px; color: rgba(255,255,255,0.9);
}
.chat-message.user {
  background: rgba(16,163,127,0.25); border-left: 2px solid var(--chat-accent, #10a37f); margin-left: 20px;
}
.chat-message.assistant {
  background: rgba(255,255,255,0.05); border-left: 2px solid rgba(255,255,255,0.2); margin-right: 20px;
}
.chat-message.assistant a { color: var(--chat-accent, #10a37f); text-decoration: none; }
.chat-message.assistant a:hover { text-decoration: underline; }
.chat-message.assistant strong { color: #fff; }
.chat-message.assistant code {
  background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-size: 12px;
}
.chat-message.assistant ul, .chat-message.assistant ol { margin: 6px 0; padding-left: 20px; }
.chat-message.assistant li { margin: 3px 0; }
.chat-input-area {
  padding: 12px 16px; border-top: 1px solid rgba(16,163,127,0.2);
  display: flex; gap: 8px; background: rgba(0,0,0,0.2);
}
.chat-input-area input {
  flex: 1; padding: 10px 12px;
  background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; color: rgba(255,255,255,0.9);
  font-size: 13px; font-family: var(--mono);
}
.chat-input-area input::placeholder { color: rgba(255,255,255,0.3); }
.chat-input-area input:focus {
  outline: none; border-color: rgba(16,163,127,0.5);
  box-shadow: 0 0 0 2px rgba(16,163,127,0.1);
}
.chat-input-area button {
  padding: 10px 14px; background: rgba(16,163,127,0.8);
  border: none; border-radius: 6px; color: white; cursor: pointer;
  font-size: 12px; font-family: var(--mono); font-weight: 500; transition: all 0.2s;
}
.chat-input-area button:hover { background: var(--chat-accent, #10a37f); }

/* ── Citations: the graph records behind an answer, collapsed ── */
.chat-answer { white-space: pre-line; overflow-wrap: anywhere; }   /* the answer is plain text: keep its line breaks */
.chat-citations { margin-top: 6px; font-size: 11px; opacity: 0.7; }
.chat-citations summary { cursor: pointer; }
.chat-citations ul { margin: 4px 0 0; padding-left: 16px; }
.chat-citations li { margin: 1px 0; overflow-wrap: anywhere; }

/* ── Feedback bar ── */
.chat-feedback-bar {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.chat-fb-btn {
  background: none; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; cursor: pointer; font-size: 12px;
  padding: 2px 6px; opacity: 0.5; transition: all 0.2s;
}
.chat-fb-btn:hover { opacity: 1; border-color: rgba(16,163,127,0.4); }
.chat-fb-btn.selected { opacity: 1; border-color: var(--chat-accent, #10a37f); background: rgba(16,163,127,0.15); }
.chat-fb-form {
  display: flex; gap: 4px; flex: 1; margin-left: 4px;
}
.chat-fb-input {
  flex: 1; padding: 4px 8px;
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px; color: rgba(255,255,255,0.9);
  font-size: 11px; font-family: var(--mono);
}
.chat-fb-input:focus { outline: none; border-color: rgba(16,163,127,0.4); }
.chat-fb-send {
  padding: 4px 8px; background: rgba(16,163,127,0.6);
  border: none; border-radius: 4px; color: white;
  cursor: pointer; font-size: 11px; font-family: var(--mono);
}
.chat-fb-send:hover { background: var(--chat-accent, #10a37f); }
.chat-fb-thanks {
  font-size: 11px; color: rgba(16,163,127,0.7); font-style: italic;
}

/* ── Triage bar (bottom of chat) ── */
.chat-triage-bar {
  padding: 8px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.15);
  border-radius: 0 0 12px 12px;
  transition: all 0.3s;
}
.chat-triage-bar.chat-triage-highlighted {
  background: rgba(16,163,127,0.08);
  border-top-color: rgba(16,163,127,0.3);
}
.chat-triage-label {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-align: center;
}
.chat-triage-highlighted .chat-triage-label {
  color: rgba(16,163,127,0.7);
}
.chat-triage-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.chat-triage-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--mono);
  transition: all 0.2s;
}
.chat-triage-btn:hover {
  border-color: rgba(16,163,127,0.4);
  color: rgba(255,255,255,0.8);
  background: rgba(16,163,127,0.08);
}
.chat-triage-btn svg {
  opacity: 0.6;
}
.chat-triage-btn:hover svg {
  opacity: 1;
}

/* ── Triage panels ── */
.chat-triage-panels {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-triage-panels.hidden { display: none; }

.triage-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.triage-panel.hidden { display: none; }

.triage-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(16,163,127,0.2);
  background: rgba(0,0,0,0.3);
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  font-family: var(--mono);
}
.triage-back {
  background: none;
  border: none;
  color: var(--chat-accent, #10a37f);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.triage-back:hover {
  background: rgba(16,163,127,0.15);
}

.triage-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.triage-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  line-height: 1.5;
  margin: 0 0 12px;
}

.triage-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.9);
  font-size: 12px;
  font-family: var(--mono);
  box-sizing: border-box;
}
.triage-input:focus {
  outline: none;
  border-color: rgba(16,163,127,0.5);
  box-shadow: 0 0 0 2px rgba(16,163,127,0.1);
}
textarea.triage-input {
  resize: vertical;
  min-height: 60px;
}

.triage-submit {
  display: block;
  width: 100%;
  padding: 10px;
  background: rgba(16,163,127,0.8);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  transition: all 0.2s;
  margin-top: 4px;
}
.triage-submit:hover { background: var(--chat-accent, #10a37f); }
.triage-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.triage-status {
  font-size: 11px;
  margin-top: 8px;
  text-align: center;
}
.triage-status-ok { color: var(--chat-accent, #10a37f); }
.triage-status-error { color: #e57373; }

/* ── Google sign-in button ── */
.triage-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--mono);
  transition: all 0.2s;
}
.triage-google-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
}
.triage-google-btn svg {
  flex-shrink: 0;
}

/* ── Schedule slots ── */
.schedule-slot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.schedule-slot-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 12px;
  font-family: var(--mono);
  transition: all 0.2s;
}
.schedule-slot-link:hover {
  background: rgba(16,163,127,0.1);
  border-color: rgba(16,163,127,0.3);
  color: #fff;
}

.schedule-user-info {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
}
.schedule-logout {
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  font-size: 11px;
}
.schedule-logout:hover { color: var(--chat-accent, #10a37f); text-decoration: underline; }

/* ── Agent API info ── */
.agent-api-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-api-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
}
.agent-api-label {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 60px;
}
.agent-api-url {
  font-size: 11px;
  color: var(--chat-accent, #10a37f);
  font-family: var(--mono);
}

@media (max-width: 480px) {
  .chat-fab { width: 42px; height: 42px; bottom: 16px; right: 16px; }
  #ai-chat-popup { width: calc(100vw - 24px); right: 12px; bottom: 68px; max-height: 440px; }
  .chat-messages { max-height: 180px; }
}
