/**
 * AutoDesk AI Web Chat Widget Styles
 */

.autodesk-chat-container {
  position: fixed;
  bottom: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Position Classes */
.autodesk-chat-container.right-4 {
  right: 20px;
}

.autodesk-chat-container.left-4 {
  left: 20px;
}

/* Chat Button */
.autodesk-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  color: white;
  position: relative;
}

.autodesk-chat-button-unread {
  animation: pulse 2s infinite;
}

.autodesk-chat-button-unread::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid white;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(79, 70, 229, 0.7);
  }
  50% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(79, 70, 229, 0);
  }
}

.autodesk-chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

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

.autodesk-chat-icon,
.autodesk-chat-close-icon {
  width: 28px;
  height: 28px;
}

/* Chat Window */
.autodesk-chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
  transition: width 0.3s ease, height 0.3s ease, max-height 0.3s ease;
}

/* Expanded Mode */
.autodesk-chat-window.autodesk-chat-window-expanded {
  width: 60vw;
  min-width: 600px;
  height: 70vh;
  max-height: 70vh;
}

/* Chat Window Position Override for Left */
.autodesk-chat-container.left-4 .autodesk-chat-window {
  left: 0;
  right: auto;
}

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

.autodesk-chat-window.hidden {
  display: none;
}

/* Header */
.autodesk-chat-header {
  padding: 16px 20px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.autodesk-chat-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.autodesk-chat-header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

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

/* Messages Container */
.autodesk-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.autodesk-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.autodesk-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Message */
.autodesk-chat-message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.3s ease-out;
}

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

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

.autodesk-chat-message-customer {
  align-self: flex-end;
}

.autodesk-chat-message-content {
  padding: 12px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 14px;
  position: relative;
}

.autodesk-chat-message-agent .autodesk-chat-message-content {
  background: white;
  color: #1f2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.autodesk-chat-message-customer .autodesk-chat-message-content {
  background: #4F46E5;
  color: white;
  border-bottom-right-radius: 4px;
}

.autodesk-chat-message-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  padding: 0 4px;
}

.autodesk-chat-message-customer .autodesk-chat-message-time {
  text-align: right;
}

.autodesk-chat-ai-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 8px;
  text-transform: uppercase;
}

/* Attachment in message */
.autodesk-chat-attachment {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.autodesk-chat-message-customer .autodesk-chat-attachment {
  background: rgba(255, 255, 255, 0.2);
}

.autodesk-chat-attachment i {
  color: #6b7280;
  font-size: 14px;
}

.autodesk-chat-message-customer .autodesk-chat-attachment i {
  color: rgba(255, 255, 255, 0.9);
}

.autodesk-chat-attachment a {
  color: #4F46E5;
  text-decoration: none;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autodesk-chat-message-customer .autodesk-chat-attachment a {
  color: white;
}

.autodesk-chat-attachment a:hover {
  text-decoration: underline;
}

/* Input Container */
.autodesk-chat-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.autodesk-chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.autodesk-attach-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.2s, color 0.2s;
}

.autodesk-attach-btn:hover {
  background-color: #f3f4f6;
  color: #4F46E5;
}

.autodesk-file-input {
  display: none;
}

.autodesk-file-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.autodesk-file-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #374151;
}

.autodesk-file-preview-item i {
  color: #6b7280;
}

.autodesk-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.autodesk-file-size {
  color: #9ca3af;
  font-size: 11px;
}

.autodesk-file-remove {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
}

.autodesk-file-remove:hover {
  background-color: #fee2e2;
  color: #ef4444;
}

.autodesk-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.autodesk-chat-input:focus {
  border-color: #4F46E5;
}

.autodesk-chat-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: opacity 0.2s;
}

.autodesk-chat-send-btn:hover {
  opacity: 0.9;
}

.autodesk-chat-send-btn:active {
  opacity: 0.8;
}

/* Customer Info Form */
.autodesk-chat-info-form {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.2s ease-out;
}

.autodesk-chat-info-form.hidden {
  display: none;
}

.autodesk-chat-info-content {
  background: white;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.autodesk-chat-info-content h4 {
  margin: 0 0 16px 0;
  font-size: 18px;
  color: #1f2937;
}

.autodesk-chat-info-content input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  box-sizing: border-box;
}

.autodesk-chat-info-content input:focus {
  border-color: #4F46E5;
}

.autodesk-chat-info-content button {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.autodesk-chat-info-content button:hover {
  opacity: 0.9;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  /* Скрываем кнопку "Развернуть" на мобильных */
  .autodesk-chat-expand-btn {
    display: none !important;
  }
  
  /* На мобильных виджет занимает весь экран */
  .autodesk-chat-window {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
  }
  
  /* Отключаем расширенный режим на мобильных */
  .autodesk-chat-window.autodesk-chat-window-expanded {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
  }
}

@media (max-width: 480px) {
  .autodesk-chat-window {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
  }
  
  .autodesk-chat-container.right-4 .autodesk-chat-window {
    right: 0 !important;
    left: 0 !important;
  }
  
  .autodesk-chat-container.left-4 .autodesk-chat-window {
    left: 0 !important;
    right: 0 !important;
  }
}
/* ========================================
   HTML Content Styles (для форматированных сообщений)
   ======================================== */

/* Базовые стили для HTML контента */
.autodesk-message-content strong,
.autodesk-message-content b {
    font-weight: 600;
}

.autodesk-message-content em,
.autodesk-message-content i {
    font-style: italic;
}

.autodesk-message-content u {
    text-decoration: underline;
}

.autodesk-message-content a {
    color: #3b82f6;
    text-decoration: underline;
    word-break: break-word;
}

.autodesk-message-content a:hover {
    color: #2563eb;
}

/* Списки */
.autodesk-message-content ul,
.autodesk-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.autodesk-message-content li {
    margin-bottom: 4px;
}

/* Параграфы */
.autodesk-message-content p {
    margin: 4px 0;
}

.autodesk-message-content p:first-child {
    margin-top: 0;
}

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

/* Переносы строк */
.autodesk-message-content br {
    display: block;
    content: ;
    margin: 4px 0;
}
