/* Modern Chat Widget */
:root {
    --primary-color: #0066ff;
    --primary-dark: #0052cc;
    --primary-light: #3385ff;
    --secondary-color: #ff6b35;
    --accent-color: #00d4aa;
    --dark-color: #0a0a0a;
    --dark-secondary: #1a1a1a;
    --gray-color: #6b7280;
    --gray-light: #f3f4f6;
    --white: #ffffff;
    --gradient-primary: linear-gradient(135deg, #0066ff 0%, #00d4aa 100%);
    --gradient-secondary: linear-gradient(135deg, #ff6b35 0%, #ff8c69 100%);
    --gradient-dark: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    --shadow-light: 0 4px 20px rgba(0, 102, 255, 0.1);
    --shadow-medium: 0 8px 40px rgba(0, 102, 255, 0.15);
    --shadow-heavy: 0 16px 60px rgba(0, 102, 255, 0.2);
    --border-radius: 12px;
    --font-family: 'Inter', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Legacy chat widget variables mapped to new color scheme */
    --chat-primary: var(--primary-color);
    --chat-primary-hover: var(--primary-dark);
    --chat-secondary: var(--gray-color);
    --chat-light: var(--gray-light);
    --chat-border: #e2e8f0;
    --chat-white: var(--white);
    --chat-text: var(--dark-color);
    --chat-text-light: var(--gray-color);
    --chat-success: var(--accent-color);
    --chat-error: var(--secondary-color);
    --chat-radius: var(--border-radius);
    --chat-shadow: var(--shadow-medium);
    --chat-font: var(--font-family);
    --chat-gradient: var(--gradient-primary);
}

/* Toggle Button */
.chat-widget-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100000;
}

.chat-widget-toggle button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--chat-gradient);
  color: var(--chat-white);
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--chat-shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--chat-font);
  backdrop-filter: blur(10px);
}

.chat-widget-toggle button:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Chat Window */
.chat-widget-window {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 380px;
  max-height: 600px;
  background: var(--chat-white);
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100000;
  font-family: var(--chat-font);
  backdrop-filter: blur(20px);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header */
.chat-widget-header {
  background: var(--gradient-primary);
  color: var(--white);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: none;
  position: relative;
}

.chat-widget-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.chat-widget-header span {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.chat-close {
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--chat-white);
  transform: scale(1.05);
}

/* Body */
.chat-widget-body {
  padding: 24px 20px;
  flex: 1 1 auto;
  overflow-y: auto;
  background: var(--chat-white);
  scroll-behavior: smooth;
}

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

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

.chat-widget-body::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 3px;
  transition: all 0.2s ease;
}

.chat-widget-body::-webkit-scrollbar-thumb:hover {
  background: var(--chat-secondary);
}

/* Footer */
.chat-widget-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-light);
  backdrop-filter: blur(10px);
}

/* Contact Form */
.chat-widget-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-widget-form p {
  margin: 0;
  color: var(--chat-text);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}

.chat-widget-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border: 2px solid var(--chat-border);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--chat-font);
  background: var(--chat-white);
  color: var(--chat-text);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
}

.chat-widget-form input:focus {
  outline: none;
  border-color: var(--chat-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.chat-widget-form input::placeholder {
  color: var(--chat-text-light);
  font-weight: 400;
}

.chat-widget-form button {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  background: var(--chat-primary);
  color: var(--chat-white);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--chat-font);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: -0.01em;
}

.chat-widget-form button:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

/* Message Input */
.chat-widget-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  border: 2px solid var(--chat-border);
  border-radius: 16px;
  font-size: 14px;
  font-family: var(--chat-font);
  background: var(--chat-white);
  color: var(--chat-text);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

.chat-widget-input:focus {
  outline: none;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Input Container */
.chat-widget-footer > div {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* Send Button */
.chat-widget-footer button {
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  background: var(--chat-primary);
  color: var(--chat-white);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--chat-font);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  min-height: 44px;
}

.chat-widget-footer button:hover {
  background: var(--chat-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* End Chat Button */
#end-chat-btn {
  background: transparent !important;
  color: var(--secondary-color) !important;
  border: 2px solid var(--secondary-color) !important;
  font-size: 12px !important;
  padding: 8px 16px !important;
  margin-top: 12px;
  border-radius: 8px !important;
  font-weight: 600 !important;
  transition: var(--transition) !important;
}

#end-chat-btn:hover {
  background: var(--secondary-color) !important;
  color: var(--white) !important;
  transform: translateY(-1px) !important;
}

/* Messages */
.chat-message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

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

.chat-message .meta {
  font-size: 11px;
  color: var(--chat-text-light);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.chat-message.web {
  align-items: flex-end;
}

.chat-message.web .meta {
  text-align: right;
}

.chat-message.agent {
  align-items: flex-start;
}

.chat-message div:last-child {
  background: var(--chat-light);
  padding: 12px 16px;
  border-radius: 18px;
  color: var(--chat-text);
  line-height: 1.5;
  font-size: 14px;
  max-width: 85%;
  word-wrap: break-word;
  border: 1px solid var(--chat-border);
  margin: 0;
  position: relative;
  font-weight: 450;
}

.chat-message.web div:last-child {
  background: var(--chat-primary);
  color: var(--chat-white);
  border: none;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.chat-message.agent div:last-child {
  background: var(--chat-white);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-message.system {
  align-items: center;
  margin: 20px 0;
}

.chat-message.system div {
  background: transparent !important;
  color: var(--chat-text-light) !important;
  text-align: center !important;
  font-style: italic;
  padding: 8px 16px !important;
  margin: 0 !important;
  border: 1px solid var(--chat-border) !important;
  font-size: 12px;
  border-radius: 20px !important;
  font-weight: 500;
  backdrop-filter: blur(10px);
  background: rgba(248, 250, 252, 0.8) !important;
}

/* Status Messages */
.chat-widget-small {
  font-size: 12px;
  color: var(--gray-color);
  text-align: center;
  padding: 12px 16px;
  background: rgba(243, 244, 246, 0.8);
  border-radius: var(--border-radius);
  margin: 12px 0;
  font-style: italic;
  border: 1px solid var(--gray-light);
  backdrop-filter: blur(10px);
  font-weight: 500;
}

/* Error Messages */
#form-error {
  background: rgba(255, 107, 53, 0.1);
  color: var(--secondary-color);
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 12px;
  text-align: center;
  margin-top: 12px;
  border: 1px solid rgba(255, 107, 53, 0.2);
  font-weight: 500;
  backdrop-filter: blur(10px);
  display: none;
}

/* Connection Status */
#connection-status {
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 12px;
  background: rgba(243, 244, 246, 0.8);
  color: var(--gray-color);
  border: 1px solid var(--gray-light);
  font-style: italic;
  font-weight: 500;
  backdrop-filter: blur(10px);
}

/* Responsive */
@media (max-width: 768px) {
  .chat-widget-window {
    right: 16px;
    bottom: 90px;
    width: calc(100vw - 32px);
    max-width: 380px;
    max-height: 75vh;
    border-radius: 16px;
  }
  
  .chat-widget-toggle {
    right: 16px;
    bottom: 16px;
  }
  
  .chat-widget-toggle button {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .chat-widget-window {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    max-height: 70vh;
    border-radius: 12px;
  }
  
  .chat-widget-toggle {
    right: 12px;
    bottom: 12px;
  }
  
  .chat-widget-toggle button {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }
  
  .chat-message.web div:last-child {
    max-width: 90%;
  }
  
  .chat-message.agent div:last-child {
    max-width: 90%;
  }
  
  .chat-widget-header {
    padding: 16px 20px;
  }
  
  .chat-widget-body {
    padding: 20px 16px;
  }
  
  .chat-widget-footer {
    padding: 16px 20px;
  }
}
