/* ══════════════════════════════════════════════════
   GeoTask AI Chat Widget
   ══════════════════════════════════════════════════ */

/* ── Floating button ─────────────────────────────── */
#ai-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ee7b7 0%, #3b82f6 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(110,231,183,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
}
#ai-chat-btn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(110,231,183,0.55); }
#ai-chat-btn svg { width: 26px; height: 26px; fill: #0a0f1e; }
#ai-chat-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #f87171;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  display: none;
}

/* ── Chat window ─────────────────────────────────── */
#ai-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(.34,1.56,.64,1), opacity 0.18s ease;
}
#ai-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────── */
#ai-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.ai-chat-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ee7b7 0%, #3b82f6 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ai-chat-avatar svg { width: 18px; height: 18px; fill: #0a0f1e; }
.ai-chat-header-info { flex: 1; }
.ai-chat-header-info h4 { color: #f1f5f9; font-size: 14px; font-weight: 600; margin: 0; }
.ai-chat-header-info span { color: #6ee7b7; font-size: 11px; }
#ai-chat-close {
  background: none; border: none; cursor: pointer;
  color: #64748b; font-size: 20px; line-height: 1;
  padding: 4px; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
#ai-chat-close:hover { color: #f1f5f9; background: #1e293b; }

/* ── Messages ────────────────────────────────────── */
#ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#ai-chat-messages::-webkit-scrollbar { width: 4px; }
#ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ai-chat-messages::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.ai-msg.user { align-self: flex-end; align-items: flex-end; }
.ai-msg.assistant { align-self: flex-start; align-items: flex-start; }
.ai-msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  color: #e0f2fe;
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-msg-bubble {
  background: #1e293b;
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}
.ai-msg-time {
  font-size: 10px;
  color: #475569;
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing indicator */
.ai-typing-dot {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
}
.ai-typing-dot span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6ee7b7;
  animation: aiTypeBounce 1.2s infinite ease-in-out;
}
.ai-typing-dot span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTypeBounce {
  0%,80%,100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* File preview */
.ai-file-preview {
  background: #0a0f1e;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-file-preview .ai-file-icon { font-size: 16px; }
.ai-file-preview .ai-file-info { flex: 1; min-width: 0; }
.ai-file-preview .ai-file-name { color: #e2e8f0; font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-file-remove {
  background: none; border: none; cursor: pointer;
  color: #64748b; font-size: 14px; padding: 2px;
}
.ai-file-remove:hover { color: #f87171; }

/* ── Input area ───────────────────────────────────── */
#ai-chat-input-area {
  border-top: 1px solid #1e293b;
  padding: 10px 12px;
  flex-shrink: 0;
}
#ai-chat-file-previews {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}
#ai-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
#ai-chat-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 13px;
  padding: 9px 12px;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.15s;
}
#ai-chat-input:focus { border-color: #6ee7b7; }
#ai-chat-input::placeholder { color: #475569; }

.ai-chat-icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #64748b;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ai-chat-icon-btn:hover { background: #334155; color: #e2e8f0; }
.ai-chat-icon-btn svg { width: 16px; height: 16px; }
.ai-chat-icon-btn.active { background: #f87171; border-color: #f87171; color: #fff; }
.ai-chat-icon-btn.recording { background: #f87171; border-color: #f87171; color: #fff; animation: aiPulse 1s infinite; }
@keyframes aiPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

#ai-chat-send {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #6ee7b7 0%, #3b82f6 100%);
  color: #0a0f1e;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#ai-chat-send:hover { opacity: 0.9; transform: scale(1.05); }
#ai-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#ai-chat-send svg { width: 16px; height: 16px; fill: #0a0f1e; }

/* ── Welcome screen ──────────────────────────────── */
#ai-chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 20px;
  gap: 12px;
  flex: 1;
}
.ai-welcome-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ee7b7 0%, #3b82f6 100%);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.ai-welcome-icon svg { width: 28px; height: 28px; fill: #0a0f1e; }
#ai-chat-welcome h3 { color: #f1f5f9; font-size: 16px; font-weight: 600; margin: 0; }
#ai-chat-welcome p { color: #64748b; font-size: 12px; line-height: 1.5; margin: 0; max-width: 280px; }
.ai-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
}
.ai-quick-btn {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  color: #94a3b8;
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ai-quick-btn:hover { background: #334155; color: #e2e8f0; border-color: #6ee7b7; }

/* ── TTS toggle ───────────────────────────────────── */
#ai-chat-tts-btn.tts-on { color: #6ee7b7; border-color: #6ee7b7; background: rgba(110,231,183,0.1); }
