/* ============================================
   AI ASSISTANT CHATBOT STYLES
   ============================================ */

/* Main Container */
.ai-assistant {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Floating Button */
.ai-assistant-button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  border: 3px solid var(--bg-color);
}

.ai-assistant-button:hover {
  transform: scale(1.15) rotate(-5deg);
  box-shadow: 0 12px 35px rgba(3, 102, 214, 0.5);
}

[data-theme="dark"] .ai-assistant-button:hover {
  box-shadow: 0 12px 35px rgba(88, 166, 255, 0.5);
}

.ai-assistant-button.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Robot Icon in Button */
.ai-robot-icon {
  font-size: 36px;
  animation: robotBounce 3s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

@keyframes robotBounce {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-3px) rotate(-5deg);
  }
  50% {
    transform: translateY(0) rotate(0deg);
  }
  75% {
    transform: translateY(-3px) rotate(5deg);
  }
}

.ai-arrow-icon {
  width: 32px;
  height: 32px;
  animation: arrowBounce 2s ease-in-out infinite;
}

@keyframes arrowBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.ai-avatar-mini {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
}

.ai-avatar-mini spline-viewer {
  width: 100%;
  height: 100%;
  display: block;
}

/* Pulse Ring Animation */
.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid var(--accent-color);
  border-radius: 50%;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Chat Window */
.ai-chat-window {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 380px;
  height: 600px;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  transform: scale(0) translateY(50px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  border: 2px solid var(--border-color);
  overflow: hidden;
}

.ai-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Chat Header */
.ai-chat-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  min-height: 60px;
}

.ai-chat-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.3);
  transition: all 0.3s ease;
  position: relative;
}

/* Avatar Thinking Animation */
.ai-avatar-icon.thinking {
  animation: avatarPulse 1.5s ease-in-out infinite;
  border-color: rgba(255,255,255,0.8);
  box-shadow: 0 0 20px rgba(255,255,255,0.5);
}

.ai-avatar-icon.thinking::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.6);
  animation: avatarRing 1.5s ease-out infinite;
}

@keyframes avatarPulse {
  0%, 100% {
    transform: scale(1);
    background: rgba(255,255,255,0.2);
  }
  50% {
    transform: scale(1.1);
    background: rgba(255,255,255,0.35);
  }
}

@keyframes avatarRing {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Avatar Angry/Alert State */
.ai-avatar-icon.angry {
  animation: avatarShake 0.5s ease-in-out;
  background: rgba(239, 68, 68, 0.4) !important;
  border-color: rgba(239, 68, 68, 0.8) !important;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.6);
}

.ai-chat-header.angry {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  animation: headerFlash 0.8s ease-out;
}

@keyframes avatarShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(-3px) rotate(-5deg); }
  40% { transform: translateX(3px) rotate(5deg); }
  60% { transform: translateX(-3px) rotate(-3deg); }
  80% { transform: translateX(3px) rotate(3deg); }
}

@keyframes headerFlash {
  0% { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}

.ai-header-text h4 {
  margin: 0;
  font-size: 1em;
  font-weight: 700;
}

.status-online {
  font-size: 0.8em;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-online::before {
  content: '●';
  color: #10b981;
  font-size: 1.2em;
}

.ai-close-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 1.2em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-close-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg);
}

/* Messages Area */
.ai-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: var(--secondary-color);
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
}

/* Message Bubbles */
.ai-message {
  display: flex;
  margin-bottom: 10px;
}

.bot-message {
  justify-content: flex-start;
}

.user-message {
  justify-content: flex-end;
}

.message-content {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.9em;
  line-height: 1.7;
  animation: messageSlideIn 0.3s ease;
  white-space: pre-line;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.bot-message .message-content {
  background: var(--secondary-color);
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
}

.user-message .message-content {
  background: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
}

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

/* Quick Actions */
.ai-quick-actions {
  padding: 12px 15px;
  background: var(--card-bg);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  border-top: 1px solid var(--border-color);
}

.quick-action-btn {
  background: var(--secondary-color);
  border: 1px solid var(--border-color);
  padding: 8px 6px;
  border-radius: 20px;
  font-size: 0.75em;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-dark);
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
}

.quick-action-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

/* Chat Input */
.ai-chat-input {
  padding: 20px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
}

.ai-chat-input input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 25px;
  background: var(--bg-color);
  color: var(--text-dark);
  font-size: 0.95em;
  outline: none;
  transition: all 0.3s ease;
}

.ai-chat-input input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
}

.ai-chat-input button {
  width: 45px;
  height: 45px;
  border: none;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  font-size: 1.2em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-input button:hover {
  background: var(--accent-color);
  transform: scale(1.1);
}

/* Dark Mode Adjustments */
[data-theme="dark"] .ai-chat-messages {
  background: var(--bg-color);
}

[data-theme="dark"] .bot-message .message-content {
  background: var(--secondary-color);
  color: var(--text-dark);
}

[data-theme="dark"] .ai-chat-input input {
  background: var(--secondary-color);
  border-color: var(--border-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .ai-assistant-button {
    width: 60px;
    height: 60px;
    bottom: 20px;
    right: 20px;
  }

  .ai-robot-icon {
    font-size: 30px;
  }

  .ai-chat-window {
    width: calc(100vw - 40px);
    height: calc(100vh - 100px);
    bottom: 20px;
    right: 20px;
    max-width: 400px;
  }

  .ai-chat-header {
    padding: 10px 12px;
    min-height: 55px;
  }

  .ai-avatar-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  
  .ai-header-text h4 {
    font-size: 0.95em;
  }
  
  .status-online {
    font-size: 0.75em;
  }

  .message-content {
    max-width: 85%;
    font-size: 0.9em;
  }

  .quick-action-btn {
    font-size: 0.7em;
    padding: 7px 4px;
  }
}

/* Extra Small Devices */
@media (max-width: 480px) {
  .ai-chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 80px);
    bottom: 10px;
    right: 10px;
  }
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator .message-content {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  min-width: 60px;
}

.typing-dot {
  display: inline-block;
  font-size: 1.5em;
  line-height: 1;
  animation: typingBounce 1.4s ease-in-out infinite;
  color: var(--text-light);
}

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

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

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

/* Enhanced message content for markdown support */
.message-content strong {
  font-weight: 700;
  color: inherit;
}

.bot-message .message-content strong {
  color: var(--primary-color);
}

[data-theme="dark"] .bot-message .message-content strong {
  color: var(--accent-color);
}

/* ============================================
   HEADER ACTIONS (Clear Chat Button)
   ============================================ */

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-clear-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.ai-clear-btn:hover {
  background: rgba(255,255,255,0.25);
  opacity: 1;
  transform: scale(1.1);
}

/* ============================================
   SUGGESTED QUESTIONS
   ============================================ */

.ai-suggestions {
  padding: 12px 0;
  animation: fadeInUp 0.3s ease;
}

.suggestions-label {
  font-size: 0.8em;
  color: var(--text-light);
  margin: 0 0 10px 0;
  font-weight: 500;
}

.suggestions-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.suggestion-btn {
  background: var(--secondary-color);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 0.82em;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--text-dark);
  font-weight: 500;
  white-space: nowrap;
}

.suggestion-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(3, 102, 214, 0.25);
}

[data-theme="dark"] .suggestion-btn:hover {
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.25);
}

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

/* ============================================
   PROACTIVE TOOLTIP
   ============================================ */

.ai-proactive-tooltip {
  position: absolute;
  bottom: 85px;
  right: 0;
  width: 280px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  padding: 16px;
  transform: translateY(20px) scale(0.9);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  border: 2px solid var(--border-color);
  z-index: 1001;
}

.ai-proactive-tooltip.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.ai-proactive-tooltip::after {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 25px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid var(--card-bg);
}

.tooltip-content {
  position: relative;
}

.tooltip-content p {
  margin: 0 0 12px 0;
  font-size: 0.95em;
  color: var(--text-dark);
  line-height: 1.5;
}

.tooltip-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: var(--secondary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.tooltip-close:hover {
  background: var(--text-light);
  color: white;
}

.tooltip-cta {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

.tooltip-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(3, 102, 214, 0.35);
}

/* Tooltip animation */
@keyframes tooltipPulse {
  0%, 100% {
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  }
  50% {
    box-shadow: 0 10px 40px rgba(3, 102, 214, 0.35);
  }
}

.ai-proactive-tooltip.visible {
  animation: tooltipPulse 2s ease-in-out infinite;
}

/* ============================================
   MOBILE ADJUSTMENTS FOR NEW FEATURES
   ============================================ */

@media (max-width: 768px) {
  .ai-proactive-tooltip {
    width: 250px;
    right: -5px;
    bottom: 75px;
    padding: 14px;
  }
  
  .tooltip-content p {
    font-size: 0.9em;
  }
  
  .tooltip-cta {
    font-size: 0.85em;
    padding: 9px 16px;
  }
  
  .suggestions-buttons {
    gap: 6px;
  }
  
  .suggestion-btn {
    font-size: 0.78em;
    padding: 6px 12px;
  }
  
  .ai-clear-btn {
    width: 28px;
    height: 28px;
    font-size: 0.8em;
  }
}

@media (max-width: 480px) {
  .ai-proactive-tooltip {
    width: 220px;
    right: 0;
    padding: 12px;
  }
  
  .suggestion-btn {
    font-size: 0.75em;
    padding: 5px 10px;
  }
}

