/**
 * ═══════════════════════════════════════════════════════════
 * CHATBOT COMPLETE - Apple Intelligence Style
 * Clean, working, production-ready
 * ═══════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════
   SCROLL TO TOP BUTTON
   ═══════════════════════════════════════════════════════════ */

#scroll-to-top {
  position: fixed !important;
  bottom: 180px !important;
  right: 30px !important;
  z-index: 9996 !important;
  
  width: 48px;
  height: 48px;
  border-radius: 50%;
  
  background: rgba(120, 120, 128, 0.2);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  
  color: #007aff;
  font-size: 20px;
  
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  
  transition: all 0.3s ease;
}

html.dark #scroll-to-top {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #0a84ff;
}

#scroll-to-top:hover {
  opacity: 1;
  transform: translateY(-2px);
}

/* ═══════════════════════════════════════════════════════════
   CHATBOT TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════ */

#chatbot-toggle {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  z-index: 9997 !important;
  
  width: 60px;
  height: 60px;
  border-radius: 50%;
  
  background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
  border: none;
  box-shadow: 
    0 8px 32px rgba(0, 122, 255, 0.4),
    0 4px 16px rgba(0, 0, 0, 0.12);
  
  color: white;
  font-size: 26px;
  
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#chatbot-toggle:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 
    0 12px 40px rgba(0, 122, 255, 0.5),
    0 6px 20px rgba(0, 0, 0, 0.15);
}

/* ═══════════════════════════════════════════════════════════
   CHATBOT WIDGET
   ═══════════════════════════════════════════════════════════ */

#chatbot-widget {
  position: fixed !important;
  bottom: 100px !important;
  right: 20px !important;
  z-index: 10000 !important;
  
  width: 420px;
  height: 680px;
  max-height: 85vh;
  
  /* Apple Intelligence glass effect */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(80px) saturate(180%);
  -webkit-backdrop-filter: blur(80px) saturate(180%);
  
  border-radius: 28px;
  border: 0.5px solid rgba(0, 122, 255, 0.08);
  
  box-shadow: 
    0 32px 64px rgba(0, 122, 255, 0.12),
    0 16px 32px rgba(0, 0, 0, 0.08);
  
  display: flex;
  flex-direction: column;
  overflow: hidden;
  
  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.92);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#chatbot-widget.active,
#chatbot-widget:not(.hidden) {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
}

html.dark #chatbot-widget {
  background: rgba(28, 28, 30, 0.95);
  border-color: rgba(100, 200, 255, 0.15);
  box-shadow: 
    0 32px 64px rgba(0, 0, 0, 0.5),
    0 0 1px rgba(10, 132, 255, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════ */

.chatbot-header {
  padding: 20px 24px;
  background: rgba(248, 248, 248, 0.95);
  backdrop-filter: blur(40px);
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

html.dark .chatbot-header {
  background: rgba(44, 44, 46, 0.95);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.chatbot-header h2,
.chatbot-header h3 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: #000000;
  margin: 0;
  letter-spacing: -0.4px;
}

html.dark .chatbot-header h2,
html.dark .chatbot-header h3 {
  color: #ffffff;
}

.chatbot-header p {
  font-size: 13px;
  color: #86868b;
  margin: 2px 0 0 0;
}

.chatbot-close-btn {
  position: absolute;
  left: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  
  background: linear-gradient(135deg, rgba(255,59,48,0.12) 0%, rgba(255,45,33,0.08) 100%);
  border: none;
  color: #FF3B30;
  font-size: 16px;
  font-weight: 600;
  
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

html.dark .chatbot-close-btn {
  background: linear-gradient(135deg, rgba(255,59,48,0.2) 0%, rgba(255,45,33,0.15) 100%);
}

.chatbot-close-btn:hover {
  transform: scale(1.1);
  filter: brightness(1.1);
}

/* ═══════════════════════════════════════════════════════════
   MESSAGES AREA
   ═══════════════════════════════════════════════════════════ */

#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  background: #ffffff;
}

html.dark #chatbot-messages {
  background: #000000;
}

#chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 122, 255, 0.2);
  border-radius: 3px;
}

/* ═══════════════════════════════════════════════════════════
   MESSAGE BUBBLES - iMessage Style
   ═══════════════════════════════════════════════════════════ */

.message {
  max-width: 70% !important;
  padding: 12px 16px !important;
  border-radius: 22px !important;
  margin-bottom: 12px !important;
  
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif !important;
  font-size: 16px !important;
  line-height: 1.47 !important;
  font-weight: 400 !important;
  
  /* FORCE HORIZONTAL TEXT */
  word-break: normal !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
  direction: ltr !important;
  writing-mode: horizontal-tb !important;
  
  display: inline-block !important;
  animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* USER MESSAGE - Colorful Blue */
.user-message {
  background: linear-gradient(135deg, #0A84FF 0%, #64D2FF 100%) !important;
  color: #ffffff !important;
  border-bottom-right-radius: 6px !important;
  
  margin-left: auto !important;
  float: right !important;
  clear: both !important;
  
  box-shadow: 0 2px 12px rgba(10, 132, 255, 0.35) !important;
  font-weight: 500 !important;
}

html.dark .user-message {
  background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%) !important;
}

/* BOT MESSAGE - BLACK text for both themes */
.bot-message {
  background: #F2F2F7 !important;
  color: #000000 !important;
  border-bottom-left-radius: 6px !important;
  
  margin-right: auto !important;
  float: left !important;
  clear: both !important;
  
  box-shadow: 0 2px 12px rgba(0, 122, 255, 0.08) !important;
}

html.dark .bot-message {
  background: #E5E5EA !important;
  color: #000000 !important;
  box-shadow: 0 2px 12px rgba(10, 132, 255, 0.15) !important;
}

/* METADATA - BLACK for both themes (as requested) */
.message-metadata {
  font-size: 11px !important;
  margin-top: 8px !important;
  line-height: 1.5 !important;
  font-weight: 400 !important;
  
  color: #000000 !important;
  opacity: 0.8 !important;
}

html.dark .message-metadata {
  color: #000000 !important;
  opacity: 0.8 !important;
}

.message-metadata div {
  color: #000000 !important;
  opacity: 1 !important;
}

html.dark .message-metadata div {
  color: #000000 !important;
  opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════════════════════════ */

.chatbot-input-area,
#chatbot-form {
  padding: 16px 20px;
  background: rgba(248, 248, 248, 0.95);
  backdrop-filter: blur(40px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

html.dark .chatbot-input-area,
html.dark #chatbot-form {
  background: rgba(28, 28, 30, 0.95);
  border-top-color: rgba(255, 255, 255, 0.06);
}

#chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 22px;
  border: 1px solid rgba(0, 122, 255, 0.15);
  background: #ffffff;
  
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  font-size: 16px;
  color: #000000;
  
  outline: none;
  transition: all 0.3s ease;
}

#chatbot-input:focus {
  border-color: #007AFF;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

html.dark #chatbot-input {
  background: #2C2C2E;
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

html.dark #chatbot-input:focus {
  border-color: #0A84FF;
}

/* BUTTONS - Colorful Apple Intelligence */
.chatbot-btn,
.chatbot-send-btn,
.chatbot-voice-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-send-btn {
  background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.chatbot-send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.chatbot-voice-btn {
  background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
  color: white;
  position: relative;
  box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3);
}

.chatbot-voice-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(52, 199, 89, 0.4);
}

.chatbot-voice-btn.listening {
  background: linear-gradient(135deg, #FF3B30 0%, #FF2D21 100%);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.4);
  }
  50% {
    box-shadow: 
      0 4px 12px rgba(255, 59, 48, 0.6),
      0 0 0 8px rgba(255, 59, 48, 0.2);
  }
}

.chatbot-voice-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: white;
  color: #34C759;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ═══════════════════════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════════════════════ */

.chatbot-typing {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: #F2F2F7;
  border-radius: 22px;
  border-bottom-left-radius: 6px;
  max-width: fit-content;
  float: left;
  clear: both;
  margin-bottom: 12px;
}

html.dark .chatbot-typing {
  background: #2C2C2E;
}

.chatbot-typing span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8E8E93;
  animation: typingDot 1.4s ease-in-out infinite;
}

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

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  #scroll-to-top {
    bottom: 90px;
    right: 16px;
    width: 44px;
    height: 44px;
  }
  
  #chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
  
  #chatbot-widget {
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto;
    height: 75vh;
  }
  
  .message {
    max-width: 80%;
    font-size: 15px;
  }
}
