/* AI Chat Widget Styles */

#ai-chat-widget {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

#ai-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease, background 0.3s ease;
  color: white;
  font-size: 24px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#ai-chat-toggle:active {
  cursor: grabbing;
}

#ai-chat-toggle:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#ai-chat-toggle.active {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

#ai-chat-panel {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 550px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#ai-chat-panel.show {
  display: flex;
}

.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.chat-header-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header-close:hover {
  opacity: 1;
}

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

.chat-message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.chat-message.assistant .chat-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chat-message.user .chat-avatar {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.chat-message.assistant .chat-bubble {
  background: white;
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.chat-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #667eea;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  font-size: 18px;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.1);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  width: fit-content;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667eea;
  animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: #6c757d;
}

.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.chat-welcome-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.chat-welcome-text {
  font-size: 14px;
  line-height: 1.6;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.chat-suggestion-btn {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: #495057;
}

.chat-suggestion-btn:hover {
  background: #f8f9fa;
  border-color: #667eea;
  color: #667eea;
}

/* Dark mode support */
body.dark #ai-chat-panel {
  background: #2d3748;
  color: #e2e8f0;
}

body.dark .chat-messages {
  background: #1a202c;
}

body.dark .chat-message.assistant .chat-bubble {
  background: #2d3748;
  color: #e2e8f0;
}

body.dark .chat-input-container {
  background: #2d3748;
  border-top-color: #4a5568;
}

body.dark .chat-input {
  background: #1a202c;
  border-color: #4a5568;
  color: #e2e8f0;
}

body.dark .chat-welcome {
  color: #a0aec0;
}

body.dark .chat-welcome-title {
  color: #e2e8f0;
}

body.dark .chat-suggestion-btn {
  background: #2d3748;
  border-color: #4a5568;
  color: #cbd5e0;
}

body.dark .chat-suggestion-btn:hover {
  background: #4a5568;
  border-color: #667eea;
  color: #667eea;
}

/* Mobile responsive */
@media (max-width: 480px) {
  #ai-chat-panel {
    width: calc(100vw - 20px);
    left: 10px;
    bottom: 80px;
  }
  
  #ai-chat-toggle {
    left: 10px;
    bottom: 10px;
  }
}

/* ── Tombol Google Maps di chat bubble ── */
.chat-maps-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 14px;
  background: linear-gradient(135deg, #34a853 0%, #1a73e8 100%);
  color: white !important;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(26,115,232,.35);
  transition: transform .15s, box-shadow .15s;
}
.chat-maps-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26,115,232,.45);
  color: white !important;
  text-decoration: none;
}
body.dark .chat-maps-btn {
  box-shadow: 0 2px 8px rgba(26,115,232,.5);
}

/* ── Tombol Mikrofon ── */
.chat-mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #e9ecef;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background .2s, color .2s, transform .15s, box-shadow .2s;
  flex-shrink: 0;
}
.chat-mic-btn:hover {
  background: #dee2e6;
  transform: scale(1.08);
}

/* State: sedang merekam */
.chat-mic-btn.listening {
  background: #dc3545;
  color: white;
  animation: mic-pulse 1s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(220,53,69,.6);
}

@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(220,53,69,.6); }
  70%  { box-shadow: 0 0 0 10px rgba(220,53,69,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,53,69,0); }
}

/* Dark mode */
body.dark .chat-mic-btn {
  background: #4a5568;
  color: #e2e8f0;
}
body.dark .chat-mic-btn:hover {
  background: #2d3748;
}
body.dark .chat-mic-btn.listening {
  background: #dc3545;
  color: white;
}
