/**
 * RT Management AI Chatbot Widget Styles
 * Modern, professional floating chat interface
 * 
 * Features:
 * - Glassmorphism design
 * - Smooth animations
 * - Dark mode support
 * - Fully responsive
 */

/* ================================
   CSS Custom Properties (Variables)
   ================================ */
:root {
  --chatbot-primary: #1e3a8a;
  --chatbot-primary-light: #3b82f6;
  --chatbot-primary-dark: #1e40af;
  --chatbot-accent: #10b981;
  --chatbot-bg: #ffffff;
  --chatbot-bg-secondary: #f8fafc;
  --chatbot-text: #1f2937;
  --chatbot-text-secondary: #6b7280;
  --chatbot-border: #e5e7eb;
  --chatbot-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --chatbot-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --chatbot-radius: 1rem;
  --chatbot-radius-sm: 0.5rem;
  --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================
   Chatbot Container
   ================================ */
#chatbot-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ================================
   Floating Button
   ================================ */
.chatbot-button {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  color: white;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  transition: var(--chatbot-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.chatbot-button:hover {
  transform: scale(1.1);
  box-shadow: 0 30px 60px -15px rgba(30, 58, 138, 0.4);
}

.chatbot-button:active {
  transform: scale(0.95);
}

.chatbot-button.active {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.chatbot-button svg {
  width: 28px;
  height: 28px;
  transition: var(--chatbot-transition);
}

.chatbot-button .hidden {
  display: none;
}

/* Pulse animation */
.chatbot-button-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--chatbot-primary);
  opacity: 0;
  animation: chatbot-pulse 2s infinite;
}

@keyframes chatbot-pulse {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.chatbot-button.active .chatbot-button-pulse {
  display: none;
}

/* ================================
   Chat Panel
   ================================ */
.chatbot-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: var(--chatbot-transition);
  border: 1px solid var(--chatbot-border);
}

.chatbot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ================================
   Chat Header
   ================================ */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
  color: white;
  flex-shrink: 0;
}

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

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chatbot-glow 2s infinite alternate;
}

@keyframes chatbot-glow {
  0% {
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
  }
  100% {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  }
}

.chatbot-avatar svg {
  width: 24px;
  height: 24px;
}

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

.chatbot-role-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  margin-top: 4px;
}

.chatbot-role-badge.admin {
  background: rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

.chatbot-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-transition);
}

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

.chatbot-close-btn svg {
  width: 18px;
  height: 18px;
}

/* ================================
   Messages Area
   ================================ */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--chatbot-bg-secondary);
  scroll-behavior: smooth;
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-border);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-text-secondary);
}

/* ================================
   Message Bubbles
   ================================ */
.chatbot-message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: chatbot-message-in 0.3s ease-out;
}

@keyframes chatbot-message-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.bot {
  align-self: flex-start;
}

.chatbot-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
}

.chatbot-message-avatar svg {
  width: 16px;
  height: 16px;
}

.chatbot-message.user .chatbot-message-avatar {
  display: none;
}

.chatbot-message-content {
  padding: 12px 16px;
  border-radius: var(--chatbot-radius);
  font-size: 14px;
  line-height: 1.5;
}

.chatbot-message.bot .chatbot-message-content {
  background: var(--chatbot-bg);
  color: var(--chatbot-text);
  border: 1px solid var(--chatbot-border);
  border-bottom-left-radius: 4px;
}

.chatbot-message.user .chatbot-message-content {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.chatbot-message-content p {
  margin: 0 0 8px 0;
}

.chatbot-message-content p:last-child {
  margin-bottom: 0;
}

.chatbot-message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.chatbot-message-content li {
  margin: 4px 0;
}

.chatbot-message-content code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.chatbot-message.user .chatbot-message-content code {
  background: rgba(255, 255, 255, 0.2);
}

.chatbot-message-content strong {
  font-weight: 600;
}

/* ================================
   Typing Indicator
   ================================ */
.chatbot-message.typing .chatbot-message-content {
  padding: 16px 20px;
}

.typing-dots {
  display: flex;
  gap: 6px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  opacity: 0.4;
  animation: typing-dot 1.4s infinite;
}

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

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

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

/* ================================
   Input Area
   ================================ */
.chatbot-input-area {
  padding: 16px;
  background: var(--chatbot-bg);
  border-top: 1px solid var(--chatbot-border);
  flex-shrink: 0;
}

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

.chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--chatbot-border);
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--chatbot-transition);
  background: var(--chatbot-bg-secondary);
}

.chatbot-input:focus {
  border-color: var(--chatbot-primary-light);
  background: var(--chatbot-bg);
}

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

.chatbot-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chatbot-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-light) 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-transition);
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: var(--chatbot-shadow-sm);
}

.chatbot-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

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

.chatbot-send-btn svg {
  width: 20px;
  height: 20px;
}

.chatbot-powered-by {
  margin: 8px 0 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--chatbot-text-secondary);
  opacity: 0.7;
}

/* ================================
   Quick Suggestions
   ================================ */
.quick-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 10px 16px 10px;
  animation: chatbot-message-in 0.4s ease-out;
}

.suggestion-btn {
  padding: 8px 14px;
  border: 1px solid var(--chatbot-border);
  border-radius: 20px;
  background: var(--chatbot-bg);
  color: var(--chatbot-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--chatbot-transition);
  white-space: nowrap;
}

.suggestion-btn:hover {
  background: var(--chatbot-primary);
  color: white;
  border-color: var(--chatbot-primary);
  transform: translateY(-2px);
  box-shadow: var(--chatbot-shadow-sm);
}

.suggestion-btn:active {
  transform: translateY(0);
}

/* ================================
   Mobile Responsive
   ================================ */
@media (max-width: 480px) {
  #chatbot-container {
    bottom: 90px; /* Raised to clear bottom navigation (80px height + 10px padding) */
    right: 16px;
  }

  .chatbot-button {
    width: 56px;
    height: 56px;
  }

  .chatbot-button svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
  }

  .chatbot-panel.open {
    transform: translateY(0);
  }

  .chatbot-messages {
    padding: 16px;
  }

  .chatbot-message {
    max-width: 90%;
  }
}

/* ================================
   Dark Mode Support
   ================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --chatbot-bg: #1f2937;
    --chatbot-bg-secondary: #111827;
    --chatbot-text: #f9fafb;
    --chatbot-text-secondary: #9ca3af;
    --chatbot-border: #374151;
  }

  .chatbot-message.bot .chatbot-message-content {
    background: #374151;
    border-color: #4b5563;
  }

  .chatbot-input {
    background: #374151;
    color: var(--chatbot-text);
    border-color: #4b5563;
  }

  .chatbot-input:focus {
    background: #1f2937;
  }
}

/* ================================
   Reduced Motion Support
   ================================ */
@media (prefers-reduced-motion: reduce) {
  .chatbot-button,
  .chatbot-panel,
  .chatbot-message,
  .chatbot-input,
  .chatbot-send-btn {
    transition: none;
  }

  .chatbot-button-pulse,
  .chatbot-avatar,
  .typing-dots span {
    animation: none;
  }

  .chatbot-avatar {
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
  }
}

/* ================================
   Print Styles (hide chatbot)
   ================================ */
@media print {
  #chatbot-container {
    display: none !important;
  }
}
