/* ─── AI JYOTISH CHATBOT — LIGHT THEME ──────────────── */

#ai-chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #4a148c, #1a237e);
  border: none; cursor: pointer; color: white; font-size: 28px;
  box-shadow: 0 4px 20px rgba(74,20,140,0.35);
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex; align-items: center; justify-content: center;
}
#ai-chat-fab:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(74,20,140,0.5); }

.fab-icon { line-height: 1; }

.fab-badge {
  position: absolute; top: -4px; right: -4px;
  background: #e53935; color: white; border-radius: 50%;
  width: 22px; height: 22px; font-size: 12px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  animation: aiPulse 1.5s infinite;
}

/* Panel */
.ai-chat-panel {
  position: fixed; bottom: 96px; right: 24px; z-index: 9998;
  width: 420px; height: 620px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e0d6c2;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.3s ease;
  overflow: hidden;
}
.ai-chat-panel.hidden { display: none !important; }
.ai-chat-panel.ai-fullscreen {
  width: 100vw !important; height: 100vh !important;
  bottom: 0 !important; right: 0 !important; border-radius: 0;
  max-width: 100vw; max-height: 100vh;
}

/* Header — keep dark accent */
.ai-chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: linear-gradient(135deg, #4a148c, #1a237e);
  border-bottom: 1px solid rgba(255,215,0,0.2);
  flex-shrink: 0;
}
.ai-chat-title { color: #ffd700; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ai-chat-actions { display: flex; gap: 2px; }
.ai-chat-actions button {
  background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer;
  font-size: 16px; padding: 4px 7px; border-radius: 4px; transition: all 0.2s;
}
.ai-chat-actions button:hover { background: rgba(255,255,255,0.15); color: white; }

.ai-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: bold;
}
.ai-badge.connected { background: #4caf50; color: #fff; }
.ai-badge.disconnected { background: #e53935; color: #fff; }

/* Toolbar */
.ai-toolbar {
  border-bottom: 1px solid #eee5d5;
  flex-shrink: 0;
  background: #faf7f0;
}
.ai-toolbar-tabs {
  display: flex; background: #f5f0e6;
}
.ai-toolbar-tab {
  flex: 1; padding: 7px 4px; border: none;
  background: none; color: #999; cursor: pointer;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.ai-toolbar-tab:hover { color: #555; }
.ai-toolbar-tab.active { color: #4a148c; border-bottom-color: #4a148c; }

.ai-toolbar-content {
  display: none; padding: 8px;
  gap: 5px; flex-wrap: wrap;
  max-height: 140px; overflow-y: auto;
}
.ai-toolbar-content.active { display: flex; }

.ai-quick-btn, .ai-report-btn, .ai-highlight-btn {
  padding: 5px 9px; border-radius: 8px;
  border: 1px solid #e0d6c2;
  background: #fff; color: #444;
  cursor: pointer; font-size: 11px; transition: all 0.2s;
  white-space: nowrap;
}
.ai-quick-btn:hover, .ai-report-btn:hover, .ai-highlight-btn:hover {
  background: #f3eadb; border-color: #b8860b; color: #1a1a2e;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(184,134,11,0.12);
}
.ai-q-icon { margin-right: 3px; }

/* Focus Bar */
.ai-focus-bar {
  padding: 6px 12px;
  border-bottom: 1px solid #eee5d5;
  flex-shrink: 0;
  background: #faf7f0;
}
.ai-focus-bar select {
  width: 100%; padding: 5px 8px; border-radius: 6px;
  background: #fff; color: #333;
  border: 1px solid #ddd5c3;
  font-size: 12px; cursor: pointer;
}
.ai-focus-bar select:focus { border-color: #4a148c; outline: none; }

/* Messages */
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 0;
  background: #fefcf8;
}
.ai-chat-messages::-webkit-scrollbar { width: 5px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: rgba(184,134,11,0.2); border-radius: 3px; }

.ai-msg { display: flex; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-bot { justify-content: flex-start; }

.ai-msg-bubble {
  max-width: 88%; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.55; word-wrap: break-word;
}
.ai-msg-user .ai-msg-bubble {
  background: linear-gradient(135deg, #4a148c, #6a1b9a);
  color: #fff; border-bottom-right-radius: 4px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(74,20,140,0.15);
}
.ai-msg-bot .ai-msg-bubble {
  background: #fff;
  color: #333; border-bottom-left-radius: 4px;
  border: 1px solid #eee5d5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ai-msg-bot .ai-msg-bubble h2 { color: #4a148c; margin: 10px 0 6px; font-size: 16px; }
.ai-msg-bot .ai-msg-bubble h3 { color: #6a1b9a; margin: 8px 0 4px; font-size: 14px; }
.ai-msg-bot .ai-msg-bubble h4 { color: #8b6914; margin: 6px 0 3px; font-size: 13px; }
.ai-msg-bot .ai-msg-bubble strong { color: #4a148c; }
.ai-msg-bot .ai-msg-bubble em { color: #1565c0; }
.ai-msg-bot .ai-msg-bubble code {
  background: #f5f0e6; padding: 1px 5px; border-radius: 3px;
  font-size: 12px; font-family: 'Courier New', monospace; color: #8b6914;
}
.ai-msg-bot .ai-msg-bubble li { margin-left: 16px; margin-bottom: 2px; }
.ai-error { color: #e53935; font-weight: 500; }

/* Typing indicator */
.ai-typing { display: flex; gap: 5px; padding: 6px 0; align-items: center; }
.ai-typing span {
  width: 8px; height: 8px; background: #4a148c; border-radius: 50%;
  animation: aiBounce 1.2s infinite;
  opacity: 0.7;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-10px); opacity: 1; }
}
@keyframes aiPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Input */
.ai-chat-input-area {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid #eee5d5;
  flex-shrink: 0;
  background: #faf7f0;
}
.ai-chat-input-area textarea {
  flex: 1; padding: 8px 12px; border-radius: 8px;
  background: #fff; color: #333;
  border: 1px solid #ddd5c3; resize: none;
  font-size: 13px; font-family: inherit;
  max-height: 80px;
}
.ai-chat-input-area textarea::placeholder { color: #aaa; }
.ai-chat-input-area textarea:focus { border-color: #4a148c; outline: none; box-shadow: 0 0 0 2px rgba(74,20,140,0.1); }

#ai-send-btn {
  padding: 8px 16px; border-radius: 8px; border: none;
  background: linear-gradient(135deg, #4a148c, #1a237e);
  color: #fff; font-weight: bold; cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  font-size: 13px; white-space: nowrap;
}
#ai-send-btn:hover { transform: scale(1.05); background: linear-gradient(135deg, #6a1b9a, #283593); }
#ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Settings */
.ai-settings {
  border-top: 1px solid #eee5d5;
  padding: 0 12px; color: #777; font-size: 12px;
  flex-shrink: 0;
  background: #faf7f0;
}
.ai-settings summary {
  padding: 7px 0; cursor: pointer; user-select: none;
  list-style: none;
}
.ai-settings summary::-webkit-details-marker { display: none; }
.ai-settings-body {
  padding: 6px 0 10px; display: flex; flex-direction: column; gap: 5px;
}
.ai-settings-body label { color: #666; font-size: 11px; font-weight: 600; }
.ai-settings-body input, .ai-settings-body select {
  padding: 6px 8px; border-radius: 6px;
  background: #fff; color: #333;
  border: 1px solid #ddd5c3; font-size: 12px;
}
.ai-settings-body input:focus, .ai-settings-body select:focus { border-color: #4a148c; outline: none; }
.ai-settings-body button {
  padding: 7px 14px; border-radius: 6px; border: none;
  background: linear-gradient(135deg, #4a148c, #6a1b9a);
  color: white; cursor: pointer; font-size: 12px;
  font-weight: 600; margin-top: 4px; transition: all 0.2s;
}
.ai-settings-body button:hover { background: linear-gradient(135deg, #6a1b9a, #8e24aa); }
#ai-settings-status { font-size: 11px; min-height: 16px; }

/* Export Modal — light */
.ai-export-modal {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.3); display: flex;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.ai-export-content {
  background: #fff; border-radius: 12px; padding: 20px;
  max-width: 480px; width: 90%; max-height: 70vh; overflow-y: auto;
  border: 1px solid #e0d6c2; color: #333;
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
.ai-export-content h3 { color: #4a148c; margin: 0 0 12px; }
.ai-export-list { max-height: 300px; overflow-y: auto; margin: 10px 0; }
.ai-export-list label {
  display: block; padding: 4px 0; font-size: 12px;
  cursor: pointer; color: #555;
}
.ai-export-list label:hover { color: #1a1a2e; }
.ai-export-controls { display: flex; gap: 8px; align-items: center; }
.ai-export-controls button {
  padding: 4px 10px; border-radius: 4px; border: 1px solid #ddd;
  background: #f8f6f1; color: #555; cursor: pointer; font-size: 11px;
}
.ai-export-controls button:hover { background: #eee5d5; }
.ai-export-actions { display: flex; gap: 8px; margin-top: 14px; }
.ai-export-actions button {
  flex: 1; padding: 9px; border-radius: 8px; border: none;
  cursor: pointer; font-weight: bold; font-size: 13px; transition: all 0.2s;
}
.ai-export-actions button:first-child { background: linear-gradient(135deg, #4a148c, #1a237e); color: #fff; }
.ai-export-actions button:first-child:hover { background: linear-gradient(135deg, #6a1b9a, #283593); }
.ai-export-actions button:last-child { background: #f0ead6; color: #555; border: 1px solid #ddd; }
.ai-export-actions button:last-child:hover { background: #e5ddc8; }

.ai-hint { color: #999; font-size: 12px; padding: 8px; text-align: center; width: 100%; }

/* Mobile */
@media (max-width: 480px) {
  .ai-chat-panel {
    width: calc(100vw - 16px) !important; right: 8px !important;
    bottom: 80px !important; height: 72vh !important;
  }
  #ai-chat-fab { bottom: 16px; right: 16px; width: 52px; height: 52px; font-size: 24px; }
  .ai-toolbar-content { max-height: 100px; }
  .ai-msg-bubble { max-width: 92%; font-size: 12px; }
}
