/* ═══════════════════════════════════════════════════
   FIP Knowledge Base v2 — Additional Styles
   Chat panel, comments, graph viz
   ═══════════════════════════════════════════════════ */

/* ── Chat Toggle Button ──────────────────────────── */
.chat-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #003B66;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 59, 102, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}
.chat-toggle-btn:hover { background: #1794FF; transform: scale(1.05); }
.chat-toggle-btn.active { background: #1794FF; }

/* ── Chat Panel ──────────────────────────────────── */
.chat-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}
.chat-panel.open { right: 0; }

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  background: #003B66;
  color: #fff;
}
.chat-title { font-weight: 600; font-size: 15px; }
.chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  opacity: 0.8;
}
.chat-close:hover { opacity: 1; }

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

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}
.chat-welcome p:first-child { font-size: 16px; }

.chat-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.chat-msg p { margin: 0 0 8px; }
.chat-msg p:last-child { margin-bottom: 0; }

.chat-msg-user {
  align-self: flex-end;
  background: #003B66;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
  align-self: flex-start;
  background: #f4f6f8;
  color: #333;
  border-bottom-left-radius: 4px;
}

.chat-thinking {
  color: #999;
  font-style: italic;
}

.chat-error {
  color: #DC2626;
  font-size: 13px;
}

.chat-citation {
  color: #1794FF;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.chat-citation:hover { text-decoration: underline; }

.chat-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
  font-size: 12px;
}
.chat-source-link {
  display: block;
  color: #1794FF;
  text-decoration: none;
  padding: 3px 0;
  font-size: 12px;
}
.chat-source-link:hover { text-decoration: underline; }

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  background: #fafafa;
}
.chat-input-area textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
}
.chat-input-area textarea:focus { border-color: #1794FF; }
.chat-send-btn {
  background: #003B66;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 44px;
  cursor: pointer;
  font-size: 18px;
}
.chat-send-btn:hover { background: #1794FF; }

/* ── Comments ────────────────────────────────────── */
.comments-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid #f0f0f0;
}
.comments-heading {
  font-size: 16px;
  margin: 0 0 12px;
  color: #003B66;
}

.comment-new-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}
.comment-new-thread input,
.comment-new-thread textarea {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.comment-new-thread input:focus,
.comment-new-thread textarea:focus { border-color: #1794FF; outline: none; }

.comment-threads {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-thread {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}
.comment-thread.resolved { opacity: 0.7; }

.thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  background: #fafafa;
}
.thread-header:hover { background: #f0f4f8; }
.thread-subject { font-weight: 600; font-size: 14px; }
.thread-meta { font-size: 12px; color: #888; display: flex; align-items: center; gap: 8px; }

.thread-body { padding: 12px 14px; border-top: 1px solid #eee; }

.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.thread-message {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.user-msg { background: #f4f6f8; }
.admin-msg { background: #EBF5FF; border-left: 3px solid #1794FF; }
.msg-header { margin-bottom: 4px; font-size: 12px; }
.msg-body { line-height: 1.5; }

.thread-reply {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.thread-reply textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
}

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue { background: #EBF5FF; color: #1794FF; }
.badge-green { background: #ECFDF5; color: #059669; }
.badge-navy { background: #003B66; color: #fff; }
.badge-red { background: #FEF2F2; color: #DC2626; }

.btn-small {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: #003B66;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-small:hover { background: #1794FF; }

/* ── Graph Visualization ─────────────────────────── */
.graph-container {
  width: 100%;
  height: 350px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin: 16px 0;
  background: #fafafa;
  position: relative;
}

.graph-legend {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(255,255,255,0.92);
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 300px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Proof-point stats row ────────────────────────── */
.card-grid[style*="repeat(4"] .info-card {
  padding: 14px 10px;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 960px) {
  .card-grid[style*="repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 768px) {
  .chat-panel { width: 100vw; right: -100vw; }
  .chat-toggle-btn { bottom: 16px; right: 16px; width: 46px; height: 46px; }
  .graph-container { height: 250px; }
  .card-grid[style*="repeat(4"] { grid-template-columns: 1fr !important; }
  .start-layout { grid-template-columns: 1fr !important; }
}
