/* ============================================================
   JDIH SmartAsk Document Deep Dive — Stylesheet
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Theme Colors */
  --jdih-ss-bg-app: #f8fafc;
  --jdih-ss-bg-header: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  --jdih-ss-bg-chat: #f1f5f9;
  --jdih-ss-bg-card: #ffffff;
  --jdih-ss-primary: #334155;
  --jdih-ss-primary-hover: #1e293b;
  --jdih-ss-primary-grad: linear-gradient(135deg, #475569, #334155);
  --jdih-ss-accent: #3b82f6;

  --jdih-ss-text-dark: #1e293b;
  --jdih-ss-text-light: #ffffff;
  --jdih-ss-text-muted: #64748b;

  --jdih-ss-border: #e2e8f0;
  --jdih-ss-border-focus: #94a3b8;

  --jdih-ss-bubble-user: #3b82f6;
  --jdih-ss-bubble-ai: #ffffff;
}

/* Animations */
@keyframes jdihSSIn {
  from { opacity: 0; transform: scale(.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes jdihBlink {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Main Container */
.jdih-doc-pop {
  font-family: 'Inter', sans-serif;
  color: var(--jdih-ss-text-dark);
  display: flex;
  flex-direction: column;
  background: var(--jdih-ss-bg-chat);
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Sticky Header */
.jdih-doc-header {
  background: var(--jdih-ss-bg-header);
  color: var(--jdih-ss-text-light);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.jdih-doc-header-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.jdih-doc-header-meta {
  font-size: 12px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.jdih-doc-header-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* Chat Body */
.jdih-doc-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.jdih-doc-chat-body::-webkit-scrollbar {
  width: 6px;
}
.jdih-doc-chat-body::-webkit-scrollbar-thumb {
  background-color: var(--jdih-ss-border-focus);
  border-radius: 4px;
}

/* Chat Bubbles */
.ai-chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: jdihSSIn 0.3s ease-out;
}

.ai-chat-bubble-wrap.user {
  align-self: flex-end;
  align-items: flex-end;
}

.ai-chat-bubble-wrap.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.ai-chat-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ai-chat-bubble-user {
  background: var(--jdih-ss-bubble-user);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-chat-bubble-ai {
  background: var(--jdih-ss-bubble-ai);
  color: var(--jdih-ss-text-dark);
  border: 1px solid var(--jdih-ss-border);
  border-bottom-left-radius: 4px;
}

.ai-chat-bubble-ai p {
  margin-bottom: 8px;
}
.ai-chat-bubble-ai p:last-child {
  margin-bottom: 0;
}
.ai-chat-bubble-ai ul, .ai-chat-bubble-ai ol {
  margin-left: 20px;
  margin-bottom: 8px;
}

.ai-chat-time {
  font-size: 10px;
  color: var(--jdih-ss-text-muted);
  margin-top: 4px;
}

/* Source / Context References inside AI Bubble */
.ai-chat-sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--jdih-ss-border);
  font-size: 11px;
}
.ai-chat-source-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--jdih-ss-text-muted);
}
.ai-chat-source-item {
  background: var(--jdih-ss-bg-chat);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.ai-chat-source-item:hover {
  border-color: var(--jdih-ss-border-focus);
}

/* Typing Indicator (User Provided) */
.ai-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}

.ai-chat-dot {
  width: 6px;
  height: 6px;
  background-color: var(--jdih-ss-text-muted);
  border-radius: 50%;
  animation: jdihBlink 1.4s infinite both;
}

.ai-chat-dot-delay-1 {
  animation-delay: 0.2s;
}

.ai-chat-dot-delay-2 {
  animation-delay: 0.4s;
}

/* Fixed Bottom Input Area */
.jdih-doc-input-wrap {
  background: var(--jdih-ss-bg-card);
  border-top: 1px solid var(--jdih-ss-border);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Quick Actions */
.jdih-doc-quick-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.jdih-doc-quick-actions::-webkit-scrollbar {
  height: 4px;
}
.jdih-doc-quick-actions::-webkit-scrollbar-thumb {
  background: var(--jdih-ss-border);
  border-radius: 4px;
}

.jdih-quick-btn {
  background: var(--jdih-ss-bg-chat);
  border: 1px solid var(--jdih-ss-border);
  color: var(--jdih-ss-text-accent);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.jdih-quick-btn:hover {
  background: #e2e8f0;
  color: var(--jdih-ss-text-dark);
}

/* Input Form */
.jdih-doc-input-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.jdih-doc-quick-toggle {
  background: transparent;
  color: var(--jdih-ss-text-muted);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.jdih-doc-quick-toggle:hover {
  background: var(--jdih-ss-bg-chat);
  color: var(--jdih-ss-primary);
}

.jdih-doc-textarea {
  flex: 1;
  background: var(--jdih-ss-bg-chat);
  border: 1px solid var(--jdih-ss-border);
  border-radius: 20px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--jdih-ss-text-dark);
  resize: none;
  min-height: 38px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}

.jdih-doc-textarea:focus {
  border-color: var(--jdih-ss-border-focus);
}

.jdih-doc-send-btn {
  background: var(--jdih-ss-primary-grad);
  color: #fff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.jdih-doc-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.jdih-doc-send-btn:disabled {
  background: var(--jdih-ss-border);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.jdih-doc-send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
