/* ===================================================================
   CHATBOT STYLES
   =================================================================== */

/* Chatbot Container */
.chatbot-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  font-family: var(--font-sans);
}

/* Floating Toggle Button */
.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.chatbot-toggle:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle .chatbot-icon,
.chatbot-toggle .chatbot-icon-close {
  width: 28px;
  height: 28px;
  transition: all 0.3s ease;
}

.chatbot-toggle .chatbot-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(90deg);
}

.chatbot-toggle.active .chatbot-icon {
  opacity: 0;
  transform: rotate(-90deg);
}

.chatbot-toggle.active .chatbot-icon-close {
  opacity: 1;
  transform: rotate(0deg);
}

/* Pulse animation for attention */
.chatbot-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background-color: var(--color-primary);
  animation: chatbot-pulse 2s infinite;
  z-index: -1;
}

@keyframes chatbot-pulse {

  0%,
  100% {
    opacity: 0;
    transform: scale(1);
  }

  50% {
    opacity: 0.3;
    transform: scale(1.2);
  }
}

/* Chat Window */
.chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-container.open .chatbot-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chatbot-header {
  background-color: var(--color-primary);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  background-color: white;
  color: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.chatbot-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: white;
}

.chatbot-subtitle {
  margin: 0;
  font-size: 0.75rem;
  opacity: 0.9;
  color: white;
}

.chatbot-close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

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

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

/* Messages Container */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background-color: var(--color-bg-alt);
}

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

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

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

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

/* Messages */
.chatbot-message {
  display: flex;
  animation: chatbot-message-in 0.3s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.chatbot-message-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chatbot-message-user .chatbot-message-bubble {
  background-color: var(--color-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

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

/* Typing Indicator */
.chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 1rem;
  align-items: center;
}

.chatbot-typing span {
  width: 8px;
  height: 8px;
  background-color: var(--color-text-muted);
  border-radius: 50%;
  animation: chatbot-typing-bounce 1.4s infinite ease-in-out;
}

.chatbot-typing span:nth-child(1) {
  animation-delay: -0.32s;
}

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

@keyframes chatbot-typing-bounce {

  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Suggestions */
.chatbot-suggestions {
  padding: 0 1.25rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background-color: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
}

.chatbot-suggestion-btn {
  padding: 0.5rem 0.875rem;
  background-color: white;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--color-text-main);
}

.chatbot-suggestion-btn:hover {
  background-color: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Input Wrapper */
.chatbot-input-wrapper {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  background-color: white;
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 12px 12px;
}

.chatbot-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font-sans);
}

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

.chatbot-send-btn {
  width: 42px;
  height: 42px;
  background-color: var(--color-primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.05);
}

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

/* Mobile Responsive */
@media (max-width: 480px) {
  .chatbot-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

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

  .chatbot-window {
    width: 100%;
    height: calc(100vh - 100px);
    bottom: 75px;
    right: 0;
    left: 0;
    margin: 0 auto;
  }

  .chatbot-message-bubble {
    max-width: 85%;
  }
}

/* ===================================================================
   AVATAR CONFIGURATION MODAL
   =================================================================== */

/* Avatar header actions */
.chatbot-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chatbot-icon-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.chatbot-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

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

/* Modal overlay */
.avatar-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Modal content */
.avatar-modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal header */
.avatar-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.avatar-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-text-main);
}

.avatar-modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.avatar-modal-close:hover {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

/* Modal body */
.avatar-modal-body {
  padding: 1.5rem;
}

.avatar-config-section {
  margin-bottom: 2rem;
}

.avatar-config-section:last-child {
  margin-bottom: 0;
}

.avatar-config-label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text-main);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Avatar options grid */
.avatar-option-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.avatar-option {
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.avatar-option:hover {
  border-color: var(--color-primary);
  background-color: white;
  transform: translateY(-2px);
}

.avatar-option.active {
  border-color: var(--color-primary);
  background-color: white;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.avatar-option span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-main);
}

.avatar-option-preview {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option-preview svg {
  width: 100%;
  height: 100%;
}

/* Large preview */
.avatar-preview-large {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg-alt);
}

.avatar-preview-large svg {
  width: 100%;
  height: 100%;
}

/* Modal footer */
.avatar-modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.avatar-cancel {
  order: 1;
}

.avatar-save {
  order: 2;
}

@media (max-width: 480px) {
  .avatar-option-group {
    grid-template-columns: repeat(2, 1fr);
  }

  .avatar-modal-footer {
    flex-direction: column-reverse;
  }

  .avatar-modal-footer .btn {
    width: 100%;
  }
}

/* ===================================================================
   HEADER AVATAR WIDGET
   =================================================================== */

.header-avatar-widget {
  display: flex;
  align-items: center;
  margin-right: 1rem;
  padding-right: 1rem;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  transition: transform 0.2s;
}

.header-avatar-widget:hover {
  transform: scale(1.05);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--color-primary);
  background: var(--color-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===================================================================
   ADVANCED AVATAR MODAL V2
   =================================================================== */

.avatar-modal-v2 {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease-out;
}

.avatar-modal-content-v2 {
  background: white;
  border-radius: 16px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

.avatar-modal-header-v2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px 16px 0 0;
}

.avatar-modal-header-v2 h3 {
  margin: 0;
  font-size: 1.5rem;
  color: white;
}

.avatar-modal-close-v2 {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: white;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.avatar-modal-close-v2:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.avatar-modal-body-v2 {
  padding: 2rem;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
}

/* Preview Section */
.avatar-preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.avatar-live-preview {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--color-primary);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.avatar-live-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-preview-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Options Section */
.avatar-options-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.avatar-option-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.avatar-option-group label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.avatar-color-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.color-btn.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1);
  transform: scale(1.15);
}

.avatar-select {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.avatar-select:hover {
  border-color: var(--color-primary);
}

.avatar-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.avatar-modal-footer-v2 {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .avatar-modal-body-v2 {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .avatar-preview-section {
    order: -1;
  }

  .avatar-live-preview {
    width: 120px;
    height: 120px;
  }

  .header-avatar-widget {
    margin-right: 0.5rem;
    padding-right: 0.5rem;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
  }

  .avatar-modal-footer-v2 {
    flex-direction: column-reverse;
  }

  .avatar-modal-footer-v2 .btn {
    width: 100%;
  }
}