/* Thuldai Bot - Futuristic Glassy UI with Proven Message Pattern */

/* Disable text selection and copy/paste */
.thuldai-bot-modal * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* CSS Variables for Theme Support */
:root {
  --bot-glass-bg: rgba(255, 255, 255, 0.1);
  --bot-glass-border: rgba(255, 255, 255, 0.2);
  --bot-glass-shadow: rgba(0, 0, 0, 0.1);
  --bot-primary: #667eea;
  --bot-primary-light: #764ba2;
  --bot-accent: #f093fb;
  --bot-text: #ffffff;
  --bot-text-secondary: rgba(255, 255, 255, 0.8);
  --bot-success: #4ade80;
  --bot-warning: #fbbf24;
  --bot-error: #f87171;
}


/* Dark theme overrides */
[data-theme="dark"] {
  --bot-glass-bg: rgba(0, 0, 0, 0.3);
  --bot-glass-border: rgba(255, 255, 255, 0.1);
  --bot-glass-shadow: rgba(0, 0, 0, 0.3);
  --bot-text: #ffffff;
  --bot-text-secondary: rgba(255, 255, 255, 0.7);
}

/* Light theme overrides */
[data-theme="light"] {
  --bot-glass-bg: rgba(255, 255, 255, 0.2);
  --bot-glass-border: rgba(0, 0, 0, 0.1);
  --bot-glass-shadow: rgba(0, 0, 0, 0.1);
  --bot-text: #1f2937;
  --bot-text-secondary: rgba(31, 41, 55, 0.7);
}

/* Typing indicator with modern animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 20px;
  box-sizing: border-box;
}

.typing-indicator span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--bot-primary), var(--bot-primary-light));
  animation: typingPulse 1.4s infinite ease-in-out;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

@keyframes typingPulse {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.2);
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
  }
}

/* Main modal with glassmorphism */
.thuldai-bot-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Glassmorphism overlay */
.bot-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, 
    rgba(102, 126, 234, 0.1) 0%, 
    rgba(118, 75, 162, 0.1) 50%, 
    rgba(240, 147, 251, 0.1) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Main container with glassmorphism */
.bot-container {
  position: relative;
  width: 90%;
  max-width: 480px;
  height: 85%;
  max-height: 700px;
  background: var(--bot-glass-bg);
  border-radius: 32px;
  border: 1px solid var(--bot-glass-border);
  box-shadow: 
    0 32px 64px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  animation: containerSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Futuristic header with gradient */
.bot-header {
  background: linear-gradient(135deg, 
    rgba(102, 126, 234, 0.2) 0%, 
    rgba(118, 75, 162, 0.2) 50%, 
    rgba(240, 147, 251, 0.2) 100%);
  color: var(--bot-text);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 32px 32px 0 0;
  border-bottom: 1px solid var(--bot-glass-border);
  position: relative;
  overflow: hidden;
  flex-shrink: 0; /* Prevent header from shrinking */
}

.bot-header .icon {
  margin: 0;
  width: 24px;
  height: 24px;
}

.bot-header .custom {
  color: var(--bot-text);
  cursor: pointer;
  border-radius: 12px;
  position: relative;
  transition: all 0.3s ease;
  width: 45px;
  height: 45px;
  padding: 8px;
}

.custom:hover {
  transform: scale(1.05);
/*box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);*/
}

.bot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, 
    rgba(255, 255, 255, 0.1) 0%, 
    transparent 50%, 
    rgba(255, 255, 255, 0.05) 100%);
  pointer-events: none;
}

.thuldai-bot-button {
  position: fixed; bottom: 60px; right: 20px; z-index: 9998; background: var(--bg-glass); color: var(--text-primary); border: 1px solid var(--border-color); padding: 12px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; font-size: 14px; font-weight: 500; transition: 0.3s; transform: translateY(0px); box-shadow: rgba(0, 0, 0, 0.2) 0px 4px 15px;
}

.thuldai-bot-button .icon {
  margin: 0;
  width: 24px;
  height: 24px;
}

.bot-title {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  flex: 1;
  justify-content: center;
}

.bot-icon {
  width: 20px;
  height: 20px;
  color: var(--bot-text);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--bot-glass-border);
  border-radius: 12px;
  padding: 12px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.bot-close {
  color: var(--bot-text);
  cursor: pointer;
  padding: 12px;
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
  flex-shrink: 0;
  background: none;
  border: none;
  outline: none;
}

.bot-close:hover {
  transform: scale(1.05);
/*box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);*/
}

.bot-close .icon {
  width: 20px;
  height: 20px;
  margin: 0;
  color: var(--bot-text);
}

/* Futuristic body with solid background for message compatibility */
.bot-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
  position: relative;
}

/* Welcome message styled as bot message */
.bot-welcome-message {
  display: flex;
  justify-content: flex-start;
  animation: slideInMessage 0.3s ease;
  margin-top: 5px;
  margin-bottom: 5px;
  padding: 0;
}

.bot-welcome-message .bot-message-content {
  background-color: rgb(235, 235, 235);
  background: rgba(235, 235, 235, 1);
  color: #444444;
  border-radius: 15px;
  border: none;
  padding: 8px 15px;
  float: left;
  position: relative;
  box-sizing: border-box;
  max-width: 320px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: normal;
}

.bot-welcome-message .bot-message-content::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 20px;
  height: 20px;
  background-color: rgb(235, 235, 235);
  background: rgba(235, 235, 235, 1);
  border-bottom-right-radius: 15px;
}

.bot-welcome-message .bot-message-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -10px;
  width: 10px;
  height: 20px;
  background: var(--bg-secondary);
  border-bottom-right-radius: 10px;
}

.bot-welcome-message h3 {
  margin: 0 0 8px 0;
  color: #444444;
  font-size: 15px;
  font-weight: 600;
}

.bot-welcome-message p {
  margin: 0 0 8px 0;
  color: #444444;
  font-size: 15px;
  line-height: 1.5;
}

.bot-welcome-message ul {
  margin: 0;
  padding-left: 30px;
  color: #444444;
  font-size: 15px;
}

.bot-welcome-message li {
  margin-bottom: 4px;
  color: #444444;
  font-size: 15px;
  line-height: 1.5;
}

/* Chat area with solid background */
.bot-chat {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
  min-height: 0; /* Allow flex item to shrink */
  background: var(--bg-secondary);
}

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

.bot-chat::-webkit-scrollbar-track {
  background: transparent;
}

.bot-chat::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--bot-primary), var(--bot-primary-light));
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bot-chat::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--bot-primary-light), var(--bot-accent));
}

/* Message items with proven pattern */
.bot-message-item {
  display: flex;
  animation: slideInMessage 0.3s ease;
  margin-top: 5px;
  margin-bottom: 5px;
  padding: 0;
}

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

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

/* User messages (own) with solid colors */
.bot-message-item.user .bot-message-content {
  background: var(--primary-color);
  color: var(--text-white);
  border-radius: 20px;
  padding: 8px 15px;
  float: right;
  position: relative;
  box-sizing: border-box;
}

/* Arrow for User Messages */
.bot-message-item.user .bot-message-content::before {
  content: "";
  position: absolute;
  bottom: 0;
  right: -8px;
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  border-bottom-left-radius: 15px;
}

.bot-message-item.user .bot-message-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: -10px;
  width: 10px;
  height: 20px;
  background: var(--bg-secondary);
  border-bottom-left-radius: 10px;
}

/* Bot messages (other) with solid colors */
.bot-message-item.bot .bot-message-content {
  background-color: rgb(235, 235, 235);
  background: rgba(235, 235, 235, 1);
  color: #444444;
  border-radius: 15px;
  border: none;
  padding: 8px 15px;
  float: left;
  position: relative;
  box-sizing: border-box;
}

/* Arrow for Bot Messages */
.bot-message-item.bot .bot-message-content::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 20px;
  height: 20px;
  background-color: rgb(235, 235, 235);
  background: rgba(235, 235, 235, 1);
  border-bottom-right-radius: 15px;
}

.bot-message-item.bot .bot-message-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -10px;
  width: 10px;
  height: 20px;
  background: var(--bg-secondary);
  border-bottom-right-radius: 10px;
}

.bot-message-content {
  max-width: 320px;
  padding: 16px 20px;
  font-size: 15px;
  line-height: 1.5;
  position: relative;
  box-sizing: border-box;
  word-wrap: break-word;
  white-space: normal;
}

.bot-message-text {
  white-space: normal;
  word-wrap: break-word;
}

/* Floating elements */
.bot-message-item::after {
  content: "";
  display: table;
  clear: both;
}

/* Futuristic input container - Footer */
.bot-input-container {
  padding: 24px 28px;
/*border-top: 1px solid var(--bot-glass-border);*/
  background: var(--bg-secondary);
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-shrink: 0; /* Prevent footer from shrinking */
  border-radius: 0 0 32px 32px; /* Match container border radius */
}

.bot-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.bot-input-wrapper input {
  flex: 1;
  padding: 18px 60px 18px 24px;
  border: 1px solid var(--bot-glass-border);
  border-radius: 28px;
  font-size: 15px;
  outline: none;
  background: var(--bg-secondary);
  color: var(--bot-text);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.bot-input-wrapper input:focus {
  border-color: var(--bot-primary);
  box-shadow: 
    0 8px 32px rgba(102, 126, 234, 0.2),
    0 0 0 3px rgba(102, 126, 234, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.bot-input-wrapper input::placeholder {
  color: var(--bot-text-secondary);
}

/* Modern send button */
.bot-send-icon {
  position: absolute;
  right: 20px;
  width: 24px;
  height: 24px;
  color: var(--bot-glass-border);
  cursor: pointer;
  transition: all 0.3s ease;
}

/* When input field is focused, change send icon color */
#botInput:focus + .bot-send-icon,
.bot-input-wrapper:focus-within .bot-send-icon {
  color: var(--bot-primary);
}

.bot-send-icon:focus {
    color: var(--bot-primary);
    box-shadow: 
      0 8px 32px rgba(102, 126, 234, 0.2),
      0 0 0 3px rgba(102, 126, 234, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.bot-send-icon:hover {
  transform: scale(1.1);
  color: var(--bot-primary);
}

.bot-send-icon:active {
  transform: scale(0.95);
  color: var(--bot-primary);
}

/* Mobile responsiveness - Modern state-of-the-art chat experience */
@media (max-width: 779px) {
  .thuldai-bot-modal {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }
  
  .thuldai-bot-button {
      bottom: 15px;
      right: 10px;
  }
  
  .bot-container {
    border-radius: 0;
    width: 100%;
    min-height: 100vh;
    height: 100vh;
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0;
    overflow: hidden;
  }
  
  .bot-header {
    position: relative;
    top: 0;
    z-index: 1000;
    border-radius: 0;
    padding: 5px 20px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: linear-gradient(135deg, 
      rgba(102, 126, 234, 0.25) 0%, 
      rgba(118, 75, 162, 0.25) 50%, 
      rgba(240, 147, 251, 0.25) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .bot-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  
  .bot-chat {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    min-height: 0;
    max-height: calc(100vh - 140px);
    position: relative;
    margin-bottom: 100px;
  }
  
  .bot-input-container {
    border-radius: 0;
    padding: 20px;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 80px;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    bottom: 100px;
  }
  
  /* Enhanced input styling for mobile */
  .bot-input-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  
  .bot-input-wrapper input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    border-radius: 27px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--bot-text);
    transition: all 0.3s ease;
  }
  
  .bot-input-wrapper input:focus {
    outline: none;
    border-color: var(--bot-primary);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 0.15);
  }
  
  .bot-send-icon {
    right: 8px;
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
  }
  
  .bot-send-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  }
  
  /* Prevent body scroll when bot modal is open */
  body:has(.thuldai-bot-modal[style*="flex"]) {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  
  /* Smooth scrolling for messages */
  .bot-chat::-webkit-scrollbar {
    width: 4px;
  }
  
  .bot-chat::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .bot-chat::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }
  
  .bot-chat::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
  }
}

/* Animation for message appearance */
@keyframes slideInMessage {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading state for send button */
.bot-send-icon.loading {
  animation: spin 1s linear infinite;
}

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

/* Hover effects for interactive elements */
.bot-message-content:hover {
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}

/* Focus states for accessibility */
.bot-send-icon:focus {
  outline: 2px solid var(--bot-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .bot-container {
    border: 2px solid var(--bot-text);
  }
  
  .bot-message-content {
    border: 1px solid var(--bot-text);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .bot-container,
  .bot-message-item,
  .typing-indicator span,
  .bot-send-icon {
    animation: none;
  }
}