/* ── AI Chat ───────────────────────────────────────────── */
.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 70px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary, #3498db);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(52, 152, 219, 0.4);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ai-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(52, 152, 219, 0.5);
}

.ai-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 70px;
  width: 360px;
  max-height: 480px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: geoviewSlideUp 0.25s ease;
}
.theme-dark .ai-chat-panel {
  background: #16213e;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
.theme-dark .ai-chat-header {
  border-color: #2a2a4a;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
}

.ai-chat-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 85%;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ai-chat-msg--assistant {
  background: rgba(52, 152, 219, 0.08);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.theme-dark .ai-chat-msg--assistant {
  background: rgba(52, 152, 219, 0.15);
}
.ai-chat-msg--user {
  background: var(--primary, #3498db);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg--error {
  background: rgba(231, 76, 60, 0.08);
  color: #e74c3c;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ── File attachment badge inside user message ─────────── */
.ai-chat-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  margin-bottom: 4px;
  max-width: 100%;
  overflow: hidden;
}
.ai-chat-file-badge i {
  flex-shrink: 0;
}
.ai-chat-file-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── File preview bar (shown above input when file selected) */
.ai-chat-file-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-top: 1px solid #eee;
  background: rgba(52, 152, 219, 0.04);
  font-size: 12px;
  color: #666;
}
.theme-dark .ai-chat-file-preview {
  border-color: #2a2a4a;
  background: rgba(52, 152, 219, 0.08);
  color: #aab;
}
.ai-chat-file-preview i.fa-file {
  color: var(--primary, #3498db);
}
.ai-chat-file-preview .filename {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-chat-file-preview .filesize {
  color: #999;
  flex-shrink: 0;
}
.ai-chat-file-preview .remove-file {
  background: none;
  border: none;
  cursor: pointer;
  color: #e74c3c;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

/* ── Typing indicator ──────────────────────────────────── */
.ai-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
}
.ai-chat-typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary, #3498db);
  animation: geoviewBounce 1.2s ease-in-out infinite;
}
.ai-chat-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.ai-chat-typing .dot:nth-child(3) { animation-delay: 0.3s; }

/* ── Input bar ─────────────────────────────────────────── */
.ai-chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  align-items: center;
}
.theme-dark .ai-chat-input {
  border-color: #2a2a4a;
}
.ai-chat-input input[type="text"] {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  background: inherit;
  color: inherit;
  outline: none;
  min-width: 0;
}
.theme-dark .ai-chat-input input[type="text"] {
  border-color: #2a2a4a;
}
.ai-chat-input input[type="text"]:focus {
  border-color: var(--primary, #3498db);
}
.ai-chat-input input[type="text"]:disabled {
  opacity: 0.6;
}

/* Attach button */
.ai-chat-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: #888;
  border: 1px solid #ddd;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.theme-dark .ai-chat-attach-btn {
  border-color: #2a2a4a;
  color: #778;
}
.ai-chat-attach-btn:hover {
  color: var(--primary, #3498db);
  border-color: var(--primary, #3498db);
}
.ai-chat-attach-btn.has-file {
  color: var(--primary, #3498db);
  border-color: var(--primary, #3498db);
}

/* Send button */
.ai-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary, #3498db);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.ai-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Hidden file input */
.ai-chat-file-input {
  display: none;
}

/* ── Animations ────────────────────────────────────────── */
@keyframes geoviewSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes geoviewBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
  .ai-chat-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
  }
}
