/**
 * JO.BTEC Chatbot - Styles
 * 
 * Elegant and professional chatbot widget styling
 * with RTL/LTR support and smooth animations
 */

/* ============================================
   CHATBOT TOGGLE BUTTON
   ============================================ */

#chatbot-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  border: none;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  animation: pulse 3s infinite;
  position: relative;
  overflow: hidden;
}

#chatbot-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

#chatbot-toggle:hover::before {
  opacity: 1;
}

#chatbot-toggle:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.7);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
  }
  50% {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.8), 0 0 0 10px rgba(102, 126, 234, 0.1);
  }
}

#chatbot-toggle i {
  font-size: 28px;
  color: white;
}

#chatbot-toggle.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* RTL Support */
html[dir="rtl"] #chatbot-toggle {
  left: auto;
  right: 24px;
}

/* ============================================
   CHATBOT WIDGET
   ============================================ */

#chatbot-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 400px;
  height: 650px;
  background: linear-gradient(to bottom, #ffffff 0%, #f7fafc 100%);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(102, 126, 234, 0.25), 0 0 0 1px rgba(102, 126, 234, 0.1);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(30px) scale(0.9);
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

#chatbot-widget::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(102,126,234,0.05) 0%, transparent 70%);
  animation: rotate 20s linear infinite;
  z-index: -1;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#chatbot-widget.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* RTL Support */
html[dir="rtl"] #chatbot-widget {
  left: auto;
  right: 24px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  #chatbot-widget {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 16px;
    left: 16px;
  }
  
  html[dir="rtl"] #chatbot-widget {
    left: auto;
    right: 16px;
  }
  
  #chatbot-toggle {
    bottom: 16px;
    left: 16px;
  }
  
  html[dir="rtl"] #chatbot-toggle {
    left: auto;
    right: 16px;
  }
}

/* ============================================
   CHATBOT HEADER
   ============================================ */

.chatbot-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px 20px;
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.chatbot-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: shimmer 6s linear infinite;
}

@keyframes shimmer {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
  animation: bounce 2s infinite;
}

.chatbot-avatar:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.35);
}

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

.chatbot-header-text h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.chatbot-header-text p {
  margin: 2px 0 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.chatbot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chatbot-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

#chatbot-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: white;
  font-size: 18px;
}

#chatbot-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* ============================================
   CHATBOT MESSAGES
   ============================================ */

#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
#chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#chatbot-messages::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Message Container */
.chatbot-message {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

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

/* Bot Message */
.bot-message {
  flex-direction: row;
}

.bot-message .message-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.bot-message .message-content {
  max-width: 75%;
}

.bot-message .message-text {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  color: #2d3748;
  padding: 14px 18px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.03);
  line-height: 1.7;
  word-wrap: break-word;
  position: relative;
  transition: all 0.2s ease;
}

.bot-message .message-text:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.bot-message .message-text::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transition: width 0.3s ease;
}

.bot-message .message-text:hover::before {
  width: 100%;
}

/* User Message */
.user-message {
  flex-direction: row-reverse;
}

.user-message .message-content {
  max-width: 75%;
  margin-left: auto;
}

.user-message .message-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 18px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
  line-height: 1.7;
  word-wrap: break-word;
  position: relative;
  transition: all 0.2s ease;
  overflow: hidden;
}

.user-message .message-text::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.user-message .message-text:hover::before {
  opacity: 1;
}

.user-message .message-text:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-1px);
}

/* RTL Support for Messages */
html[dir="rtl"] .bot-message {
  flex-direction: row-reverse;
}

html[dir="rtl"] .user-message {
  flex-direction: row;
}

html[dir="rtl"] .bot-message .message-text {
  border-radius: 12px 12px 4px 12px;
}

html[dir="rtl"] .user-message .message-text {
  border-radius: 12px 12px 12px 4px;
}

html[dir="rtl"] .user-message .message-content {
  margin-left: 0;
  margin-right: auto;
}

/* Message Time */
.message-time {
  font-size: 11px;
  color: #718096;
  margin-top: 4px;
  opacity: 0.7;
}

.user-message .message-time {
  text-align: left;
  color: rgba(255, 255, 255, 0.8);
}

html[dir="rtl"] .user-message .message-time {
  text-align: right;
}

/* System Message */
.system-message {
  justify-content: center;
  margin: 12px 0;
}

.system-message .message-content {
  max-width: 100%;
}

.system-message .message-text {
  background: #e6f2ff;
  color: #2563eb;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  border: 1px solid #bfdbfe;
}

/* Error Message */
.error-message {
  justify-content: center;
  margin: 12px 0;
}

.error-message .message-content {
  max-width: 100%;
}

.error-message .message-text {
  background: #fee;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  border: 1px solid #fecaca;
}

/* Message Text Formatting */
.message-text strong {
  font-weight: 600;
}

.message-text em {
  font-style: italic;
}

.message-text a {
  color: #667eea;
  text-decoration: underline;
}

.user-message .message-text a {
  color: white;
}

/* Quick Replies */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quick-reply-btn {
  background: white;
  border: 2px solid #667eea;
  color: #667eea;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.quick-reply-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* ============================================
   CHATBOT INPUT
   ============================================ */

.chatbot-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e2e8f0;
  border-radius: 0 0 16px 16px;
}

#chatbot-loading {
  text-align: center;
  color: #667eea;
  font-size: 13px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#chatbot-loading.hidden {
  display: none;
}

#chatbot-loading i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.chatbot-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

#chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
  resize: none;
  max-height: 100px;
}

#chatbot-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chatbot-input:disabled {
  background: #f7fafc;
  cursor: not-allowed;
}

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

#chatbot-send:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#chatbot-attach {
  width: 40px;
  height: 40px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  color: #667eea;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 8px;
}

#chatbot-attach:hover {
  background: #edf2f7;
  color: #764ba2;
  transform: rotate(15deg) scale(1.1);
  border-color: #667eea;
}

html[dir="rtl"] #chatbot-attach {
  margin-right: 0;
  margin-left: 8px;
}

/* ============================================
   CHATBOT POWERED BY
   ============================================ */

.chatbot-footer {
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: #a0aec0;
  border-top: 1px solid #f1f1f1;
}

.chatbot-footer a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
}

.chatbot-footer a:hover {
  text-decoration: underline;
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden {
  display: none !important;
}

/* ============================================
   PRINT MEDIA
   ============================================ */

@media print {
  #chatbot-widget,
  #chatbot-toggle {
    display: none !important;
  }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  #chatbot-widget {
    border: 2px solid #000;
  }
  
  .chatbot-header {
    background: #000;
  }
  
  #chatbot-send {
    background: #000;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
