/* AI Chatbox Styles */
.ai-chatbox {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  height: 500px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  font-family: 'Poppins', sans-serif;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

.ai-chatbox.open {
  display: flex;
}

.chatbox-header {
  background: rgba(255, 255, 255, 0.1);
  padding: 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(10px);
}

.chatbox-title {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-icon {
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: background 0.2s;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chatbox-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  animation: slideIn 0.3s ease;
}

.message.user {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

.message.ai {
  background: #f1f3f5;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.message.ai strong {
  color: #333;
  font-weight: 600;
}

.message.ai ol, .message.ai ul {
  margin: 8px 0;
  padding-left: 20px;
}

.message.ai li {
  margin-bottom: 12px;
  line-height: 1.5;
}

.message.ai p {
  margin: 8px 0;
  line-height: 1.5;
}

.message.typing {
  background: #f1f3f5;
  color: #666;
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.typing-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: #666;
}

.thinking-text {
  margin-right: 8px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: thinking 1.2s infinite;
}

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

/* Popup notification */
.ai-popup {
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 20px 30px;
  border-radius: 20px;
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
  font-weight: 600;
  z-index: 9999;
  cursor: pointer;
  animation: popupSlide 0.5s ease;
  min-width: 180px;
  text-align: center;
}

.ai-popup::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 30px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #667eea;
}

.chatbox-input {
  padding: 20px;
  background: white;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 10px;
}

.message-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e9ecef;
  border-radius: 25px;
  font-size: 14px;
  font-family: 'Poppins', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

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

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

.send-btn:hover {
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
  z-index: 10001;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.chat-toggle.hidden {
  display: none;
}

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

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

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

@media (max-width: 768px) {
  .ai-chatbox {
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    bottom: 20px;
    right: 20px;
    left: 20px;
    border-radius: 15px;
  }
  
  .chat-toggle {
    bottom: 15px;
    right: 15px;
  }
}

.message-counter {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.message-counter.normal {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.message-counter.warning {
  background: rgba(255, 193, 7, 0.9);
  color: #000;
}

.message-counter.critical {
  background: rgba(220, 53, 69, 0.9);
  color: #fff;
  animation: pulse 2s infinite;
}


@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

.message.system {
  margin: 10px 0;
  text-align: center;
}

.system-message {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  color: #856404;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.chatbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chatbox-title {
  flex: 1;
  min-width: 140px;
}

.message-counter {
  order: 2;
}

.close-btn {
  order: 3;
}

/* Disabled input styles */
.message-input:disabled {
  background: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
}

.send-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Custom tooltip styling */
[title] {
  position: relative;
}

[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 9999;
  opacity: 0.9;
}

/* Conversation separator styles */
.conversation-separator {
  display: flex;
  align-items: center;
  margin: 20px 0;
  text-align: center;
  position: relative;
}

.conversation-separator::before {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, #e9ecef, transparent);
}

.conversation-separator span {
  padding: 0 15px;
  font-size: 12px;
  font-weight: 500;
  color: #6c757d;
  background: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.conversation-separator.current span {
  color: #667eea;
  font-weight: 600;
}

.conversation-separator.current::before {
  background: linear-gradient(to right, transparent, #667eea, transparent);
}
