/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */

/* Сокращенная версия Tailwind base - оставляем только необходимое */
@layer properties {
  @supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))) {
    *, :before, :after, ::backdrop {
      --tw-rotate-x: initial;
      --tw-rotate-y: initial;
      --tw-rotate-z: initial;
      --tw-skew-x: initial;
      --tw-skew-y: initial;
      --tw-space-y-reverse: 0;
      --tw-space-x-reverse: 0;
      --tw-border-style: solid;
      --tw-font-weight: initial;
      --tw-shadow: 0 0 #0000;
      --tw-inset-shadow: 0 0 #0000;
      --tw-ring-shadow: 0 0 #0000;
      --tw-scale-x: 1;
      --tw-scale-y: 1;
      --tw-scale-z: 1;
    }
  }
}

@layer theme {
  :root, :host {
    --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --color-red-500: #ef4444;
    --color-red-600: #dc2626;
    --color-red-700: #b91c1c;
    --color-blue-500: #3b82f6;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-white: #fff;
    --spacing: .25rem;
    --text-xs: .75rem;
    --text-sm: .875rem;
    --text-2xl: 1.5rem;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --radius-lg: .5rem;
    --radius-xl: .75rem;
  }
}

@layer base {
  *, :after, :before {
    box-sizing: border-box;
    border: 0 solid;
    margin: 0;
    padding: 0;
  }
  
  html {
    line-height: 1.5;
    font-family: var(--font-sans);
    -webkit-text-size-adjust: 100%;
  }
  
  button, input, select, textarea {
    font: inherit;
    letter-spacing: inherit;
    color: inherit;
  }
  
  button {
    cursor: pointer;
  }
}

@layer components;

@layer utilities {
  .fixed { position: fixed; }
  .flex { display: flex; }
  .inline-block { display: inline-block; }
  .size-5 { width: calc(var(--spacing)*5); height: calc(var(--spacing)*5); }
  .size-6 { width: calc(var(--spacing)*6); height: calc(var(--spacing)*6); }
  .h-8 { height: calc(var(--spacing)*8); }
  .w-8 { width: calc(var(--spacing)*8); }
  .h-\[70vh\] { height: 70vh; }
  .w-\[50vh\] { width: 50vh; }
  .max-h-\[100vh\] { max-height: 100vh; }
  .max-w-\[75\%\] { max-width: 75%; }
  .flex-1 { flex: 1; }
  .flex-shrink-0 { flex-shrink: 0; }
  .cursor-pointer { cursor: pointer; }
  .cursor-not-allowed { cursor: not-allowed; }
  .flex-col { flex-direction: column; }
  .items-center { align-items: center; }
  .items-start { align-items: flex-start; }
  .justify-between { justify-content: space-between; }
  .justify-center { justify-content: center; }
  .justify-end { justify-content: flex-end; }
  .justify-start { justify-content: flex-start; }
  .gap-2 { gap: calc(var(--spacing)*2); }
  .gap-4 { gap: calc(var(--spacing)*4); }
  .space-y-2 > :not(:last-child) { margin-bottom: calc(var(--spacing)*2); }
  .space-x-2 > :not(:last-child) { margin-right: calc(var(--spacing)*2); }
  .overflow-hidden { overflow: hidden; }
  .overflow-y-auto { overflow-y: auto; }
  .rounded { border-radius: .25rem; }
  .rounded-full { border-radius: 9999px; }
  .rounded-lg { border-radius: var(--radius-lg); }
  .rounded-xl { border-radius: var(--radius-xl); }
  .border { border-width: 1px; border-style: solid; }
  .border-2 { border-width: 2px; border-style: solid; }
  .border-gray-200 { border-color: var(--color-gray-200); }
  .border-red-500 { border-color: var(--color-red-500); }
  .border-transparent { border-color: transparent; }
  .bg-blue-500 { background-color: var(--color-blue-500); }
  .bg-gray-100 { background-color: var(--color-gray-100); }
  .bg-gray-300 { background-color: var(--color-gray-300); }
  .bg-red-500 { background-color: var(--color-red-500); }
  .bg-red-600 { background-color: var(--color-red-600); }
  .bg-red-700 { background-color: var(--color-red-700); }
  .bg-white { background-color: var(--color-white); }
  .bg-transparent { background-color: transparent; }
  .p-1 { padding: calc(var(--spacing)*1); }
  .p-2 { padding: calc(var(--spacing)*2); }
  .p-3 { padding: calc(var(--spacing)*3); }
  .px-3 { padding-left: calc(var(--spacing)*3); padding-right: calc(var(--spacing)*3); }
  .px-4 { padding-left: calc(var(--spacing)*4); padding-right: calc(var(--spacing)*4); }
  .py-1 { padding-top: calc(var(--spacing)*1); padding-bottom: calc(var(--spacing)*1); }
  .py-2 { padding-top: calc(var(--spacing)*2); padding-bottom: calc(var(--spacing)*2); }
  .pl-10 { padding-left: calc(var(--spacing)*10); }
  .pr-5 { padding-right: calc(var(--spacing)*5); }
  .pt-5 { padding-top: calc(var(--spacing)*5); }
  .pb-10 { padding-bottom: calc(var(--spacing)*10); }
  .text-center { text-align: center; }
  .text-left { text-align: left; }
  .text-2xl { font-size: var(--text-2xl); }
  .text-sm { font-size: var(--text-sm); }
  .text-xs { font-size: var(--text-xs); }
  .font-bold { font-weight: var(--font-weight-bold); }
  .font-semibold { font-weight: var(--font-weight-semibold); }
  .text-gray-400 { color: var(--color-gray-400); }
  .text-gray-500 { color: var(--color-gray-500); }
  .text-gray-700 { color: var(--color-gray-700); }
  .text-gray-800 { color: var(--color-gray-800); }
  .text-white { color: var(--color-white); }
  .opacity-50 { opacity: .5; }
  .opacity-60 { opacity: .6; }
  .shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
  .transition { transition: all 0.3s ease; }
  .transition-transform { transition: transform 0.3s ease; }
  .select-none { user-select: none; }
  .hover\:bg-gray-400:hover { background-color: var(--color-gray-400); }
  .hover\:bg-red-700:hover { background-color: var(--color-red-700); }
  .hover\:scale-125:hover { transform: scale(1.25); }
  .focus\:outline-none:focus { outline: none; }
  .mb-1 { margin-bottom: calc(var(--spacing)*1); }
  .mb-2 { margin-bottom: calc(var(--spacing)*2); }
  .mb-3 { margin-bottom: calc(var(--spacing)*3); }
  .ml-2 { margin-left: calc(var(--spacing)*2); }
  .ml-10 { margin-left: calc(var(--spacing)*10); }
  .mr-2 { margin-right: calc(var(--spacing)*2); }
  .mt-2 { margin-top: calc(var(--spacing)*2); }
}

/* === КАСТОМНЫЕ СТИЛИ ДЛЯ ЧАТ-ВИДЖЕТА === */

/* Красивый градиентный фон */


/* Контейнер чата с glassmorphism эффектом */
#chatWidgetContainer {
  backdrop-filter: blur(24px) saturate(180%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transform-origin: 100% 100%;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2), 
              0 8px 16px rgba(0, 0, 0, 0.1);
}

#chatWidgetContainer.minimized {
  opacity: 0;
  pointer-events: none;
  transform: translateY(90%) scale(0.85);
}

/* Улучшенная красная шапка с градиентом */
#chatWidgetContainer > div:first-child {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

/* Стилизация кнопок в шапке */
#chatWidgetContainer > div:first-child button {
  transition: all 0.2s ease;
}

#chatWidgetContainer > div:first-child button:hover {
  background-color: rgba(185, 28, 28, 0.5);
  transform: scale(1.1);
}

#chatWidgetContainer > div:first-child button:active {
  transform: scale(0.95);
}

/* Кнопка открытия чата */
#chatToggleButton {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-radius: 50%;
  padding: 16px;
  font-size: 26px;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  position: fixed;
  bottom: 24px;
  right: 24px;
  transform: scale(0.8);
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.5),
              0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatToggleButton.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

#chatToggleButton:hover {
  transform: scale(1.15);
  box-shadow: 0 12px 32px rgba(220, 38, 38, 0.6),
              0 6px 16px rgba(0, 0, 0, 0.3);
}

#chatToggleButton:active {
  transform: scale(0.95);
}

/* Анимация печати с bounce эффектом */
.typing-dots span {
  margin-right: 3px;
  font-size: 1.4em;
  font-weight: 700;
  display: inline-block;
  animation: blink 1.4s infinite both;
  color: #dc2626;
}

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

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

@keyframes blink {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-6px);
  }
}

/* Улучшенные стили сообщений пользователя */
.message-color {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 16px;
  animation: slideIn 0.3s ease-out;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
  position: relative;
}

/* Стили для сообщений бота */
.bot-message,
#chatWidgetContainer .bg-gray-100.text-gray-800 {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  color: #1f2937;
  border-radius: 18px 18px 18px 4px;
  padding: 12px 16px;
  animation: slideIn 0.3s ease-out;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Анимация появления сообщений */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Аватары пользователей */
.bg-blue-500 {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.bg-gray-300 {
  background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Кастомный скроллбар для области сообщений */
#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.5);
  border-radius: 10px;
}

#messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-radius: 10px;
}

#messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
}

/* Поле ввода с улучшенным дизайном */
#chatInput {
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: #1f2937;
}

#chatInput::placeholder {
  color: #9ca3af;
}

/* Контейнер поля ввода с эффектом фокуса */
#chatWidgetContainer .p-3.rounded-full {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

#chatWidgetContainer .p-3.rounded-full:focus-within {
  border-color: #dc2626;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Кнопка отправки */
#sendBtn {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
  transition: all 0.2s ease;
}

#sendBtn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

#sendBtn:active {
  transform: scale(0.95);
}

/* Кнопки feedback */
.feedback-btn {
  transition: all 0.2s ease;
  font-weight: 500;
}

.feedback-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.feedback-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Emoji рейтинг */
.emoji-rating {
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
}

.emoji-rating:hover {
  transform: scale(1.3) rotate(10deg);
}

.emoji-rating:active {
  transform: scale(1.1);
}

/* Отключенные элементы */
.opacity-50 {
  opacity: 0.5;
}

.cursor-not-allowed {
  cursor: not-allowed;
}



/* Дополнительные микроанимации */
button {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:active {
  transform: scale(0.96);
}

/* Текст в футере */
#chatWidgetContainer p.text-gray-400 {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

#chatWidgetContainer p.text-gray-400:hover {
  opacity: 1;
}

/*NEW*/


/* Базовая адаптивность для планшетов и небольших экранов */
@media (max-width: 768px) {
  #chatWidgetContainer {
    width: calc(100vw - 20px) !important;
    max-width: 100vw !important;
    height: calc(100vh - 20px) !important;
    max-height: calc(100vh - 20px) !important;
    bottom: 10px !important;
    right: 10px !important;
    left: 10px !important;
    border-radius: 16px !important;
  }
  
  #messages {
    height: calc(100vh - 200px) !important;
    padding: 12px !important;
  }
  
  /* Оптимизация отступов для сообщений */
  .pl-10 { padding-left: 12px !important; }
  .pr-5 { padding-right: 12px !important; }
  
  /* Адаптивные размеры текста для читаемости */
  .text-xs { font-size: 0.75rem; line-height: 1.4; }
  .text-sm { font-size: 0.875rem; line-height: 1.5; }
  
  /* Уменьшенные аватары */
  .w-8, .h-8 { 
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }
  
  /* Кнопка открытия чата */
  #chatToggleButton {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    padding: 0;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

/* Оптимизация для маленьких смартфонов */
@media (max-width: 480px) {
  #chatWidgetContainer {
    position: fixed !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important; /* ИЗМЕНЕНО: dvh вместо vh */
    max-height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important; /* ДОБАВЛЕНО */
  }
  
  #messages {
    height: calc(100dvh - 180px) !important; /* ИЗМЕНЕНО: dvh вместо vh */
    max-height: calc(100dvh - 180px) !important; /* ДОБАВЛЕНО */
    padding: 8px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important; /* ДОБАВЛЕНО */
  }
  
  /* Компактные сообщения */
  .message-bubble {
    max-width: 85% !important;
    padding: 10px 12px !important;
    margin-bottom: 8px !important;
  }
  
  /* Увеличенная область ввода для удобства тапа */
  #chatInput {
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 12px 16px !important;
  }
  
  /* Увеличенная кнопка отправки */
  #sendBtn {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 12px !important;
    font-size: 18px !important;
  }
  
  /* Кнопки быстрых ответов / категорий */
  .category-button,
  .quick-reply-button {
    min-height: 44px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    margin: 4px !important;
    touch-action: manipulation !important;
  }
  
  /* Заголовок чата - ОБНОВЛЕНО */
  .chat-header {
    padding: 12px 16px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    flex-shrink: 0 !important; /* ДОБАВЛЕНО */
    background: #dc2626 !important; /* ДОБАВЛЕНО - ваш красный цвет */
  }
  
  /* Footer чата - НОВОЕ */
  .chat-footer {
    flex-shrink: 0 !important;
    background: white !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 10 !important;
  }
  
  /* Кнопка закрытия */
  .close-button {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 10px !important;
  }
  
  /* Оптимизация аватаров */
  .w-8, .h-8 { 
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
  }
  
  /* Улучшенная читаемость текста */
  .text-xs { 
    font-size: 0.7rem; 
    line-height: 1.4;
  }
  .text-sm { 
    font-size: 0.85rem; 
    line-height: 1.5;
  }
  
  /* Компактные отступы */
  .pl-10 { padding-left: 8px !important; }
  .pr-5 { padding-right: 8px !important; }
  
  /* Кнопка открытия чата */
  #chatToggleButton {
    bottom: 12px;
    right: 12px;
    width: 56px;
    height: 56px;
    padding: 0;
    font-size: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  }
}

/* Оптимизация для landscape режима на смартфонах */
@media (max-width: 896px) and (max-height: 414px) and (orientation: landscape) {
  #chatWidgetContainer {
    height: 100dvh !important; /* ИЗМЕНЕНО: dvh вместо vh */
    max-height: 100dvh !important;
  }
  
  #messages {
    height: calc(100dvh - 140px) !important; /* ИЗМЕНЕНО: dvh вместо vh */
  }
  
  .chat-header {
    padding: 8px 16px !important;
  }
  
  #chatInput {
    min-height: 40px !important;
    padding: 8px 12px !important;
  }
}

/* Предотвращение zoom на iOS при фокусе на input */
input, textarea, select {
  font-size: 16px !important;
}

/* Улучшенная прокрутка для мобильных */
#messages {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

/* Активные состояния для touch устройств */
@media (hover: none) and (pointer: coarse) {
  button:active,
  .category-button:active,
  .quick-reply-button:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

/* НОВОЕ: Фиксация body при открытой клавиатуре */
body.keyboard-open {
  position: fixed !important;
  width: 100% !important;
  height: 100dvh !important;
  overflow: hidden !important;
}

/* НОВОЕ: Предотвращение скролла страницы при открытом чате */
body.chat-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
}




/*Shrifty ebanye*/

/* Фикс шрифтов */
body, #chatWidgetContainer, #chatWidgetContainer * {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Читаемые размеры шрифтов */
#chatInput {
  font-size: 14px;
}

#messages {
  font-size: 14px;
  line-height: 1.5;
}

.text-xs {
  font-size: 11px;
}

.text-sm {
  font-size: 13px;
}

/* Кириллица */
#chatWidgetContainer {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/*Оформление сообщений*/

/* Стили для отформатированных сообщений бота */
#messages .bg-gray-100 p {
  margin: 0;
  line-height: 1.6;
}

#messages .bg-gray-100 ul {
  margin: 8px 0;
  padding-left: 20px;
}

#messages .bg-gray-100 li {
  margin: 6px 0;
  line-height: 1.5;
}

#messages .bg-gray-100 strong {
  font-weight: 600;
  color: #1f2937;
}

#messages .bg-gray-100 a {
  color: #dc2626;
  text-decoration: underline;
  font-weight: 500;
  transition: color 0.2s ease;
}

#messages .bg-gray-100 a:hover {
  color: #b91c1c;
  text-decoration: none;
}

#messages .bg-gray-100 br + br {
  display: block;
  content: "";
  margin-top: 8px;
}



/*Управление фоном*/

/* ЗатемненнВАВАый фон */
.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.chat-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Контейнер чата поверх overlay */
#chatWidgetContainer {
  position: relative;
  z-index: 9999;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#chatWidgetContainer.minimized {
  transform: scale(0.8) translateY(100vh);
  opacity: 0;
  pointer-events: none;
}

/* Кнопка открытия чата */
#chatToggleButton {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: white;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
  transition: all 0.3s ease;
  z-index: 9999;
}

#chatToggleButton:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.5);
}

#chatToggleButton:active {
  transform: scale(0.95);
}

/* Блокировка скролла body когда чат открыт */
body.chat-open {
  overflow: hidden;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
  #chatWidgetContainer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }
  
  #chatToggleButton {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
}