/* адаптивно, цвета #37003c и #00ff88 */
html, body {
  height: 100%;
  overscroll-behavior: none;
}

#chat-widget {
  position: fixed;
  bottom: 45px;
  right: 45px;
  z-index: 9999;
  /* font-family: 'Segoe UI', Arial, sans-serif; */
}
#open-chat {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  max-width: 64px;
  max-height: 64px;
  border-radius: 50%;
  background: #37003c;
  color: #fff;
  border: 1px solid #ae9bcd;
  box-shadow: 0 4px 24px rgba(108,14,116,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
#open-chat:active {
  background: #4d0852;
}
#open-chat .chat-icon {
  width: 38px;
  height: 38px;
  display: block;
}

/* Скрываем текст, если был */
#open-chat span { display: none; }

#chat-window {
  width: 340px;
  min-height: 260px;
  max-height: 500px;
  background: #fff;
  border-radius: 18px 18px 0 18px;
  box-shadow: 0 8px 32px rgba(108,14,116,0.18);
  padding: 0 0 56px 0;
  position: relative;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  border: 2px solid #37003c;
  animation: chatOpen 0.3s cubic-bezier(.4,2,.6,1) 1;
}
@keyframes chatOpen {
  from { transform: translateY(60px) scale(0.95); opacity: 0; }
  to { transform: none; opacity: 1; }
}
#chat-header {
  background: linear-gradient(90deg, #37003c 60%, #37003c 100%);
  color: #fff;
  padding: 18px 20px 14px 20px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 18px 18px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-title {
  display: flex;
  align-items: center;
  flex: 1;
}
#close-chat {
  background: transparent;
  border: none;
  font-size: 26px;
  color: #fff;
  cursor: pointer;
  margin-left: 10px;
  transition: color 0.2s;
}
#close-chat:hover {
  color: #00ff88;
}
#chat-content {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: 220px;
  margin-bottom: 0;
  padding-bottom: 0;
}
#chat-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 20px 18px 20px;
  overflow-y: auto;
  max-height: 220px;
}
.chat-btn {
  background: #00ff88;
  color: #37003c;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 0;
  box-shadow: 0 2px 8px rgba(24,193,57,0.08);
}
.chat-btn:hover {
  background: #37003c;
  color: #ffffff;
}
.chat-btn-back {
  background: #eee;
  color: #37003c;
  border: 1px solid #37003c;
}
.chat-bot-msg {
  background: #f7f3fa;
  border-radius: 10px 10px 10px 0;
  padding: 12px 16px;
  margin-bottom: 10px;
  color: #37003c;
  font-size: 16px;
  max-width: 90%;
  box-shadow: 0 1px 4px rgba(108,14,116,0.04);
}
#chat-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#chat-form label {
  display: flex;
  align-items: center;
  font-size: 13px;
  margin-bottom: 0;
  gap: 7px;
  line-height: 1.3;
}
#chat-form input[type='checkbox'] {
  margin: 0;
  vertical-align: middle;
}
#chat-form input[type='text'], #chat-form input[type='email'], #chat-form textarea {
  text-align: left;
  padding: 3px;
  font-size: 15px;
  line-height: 19px;
  height: 26px;
  color: #000000;
  background-color: #f3f3f3;
  border: 1px solid #37003c;
  border-radius: 2px;
  margin-bottom:6px;
}
#chat-form textarea {
  height: 52px;
}
#form-back-btn {
  margin-top: 10px;
  width: 100%;
  align-self: flex-start;
  position: relative;
  z-index: 2;
}

/* мобильная адаптация */
@media (max-width: 600px) {
  #chat-widget {
    bottom: 0;
    right: 0;
    width: 100vw;
  }
  #open-chat {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    max-width: 64px;
    max-height: 64px;
    border-radius: 50%;
    left: auto;
    right: 16px;
    bottom: 16px;
    position: fixed;
    z-index: 10000;
  }
  #chat-window {
    width: 100vw;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border-width: 0 0 2px 0;
    margin-bottom: 0;
    box-shadow: 0 -2px 24px rgba(108,14,116,0.10);
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
  }
  #chat-header {
    border-radius: 0;
    font-size: 17px;
    padding: 16px 12px 12px 16px;
  }
  
  .chat-logo {
    width: 28px;
    height: 28px;
    margin-right: 10px;
  }
  
  #chat-content, #chat-actions {
    max-height: 40vh;
    padding-left: 12px;
    padding-right: 12px;
  }
  #chat-actions {
    max-height: 50vh;
  }
}

/* Скрытие окна чата */
.chat-window-hidden {
  display: none !important;
}

/* Мобильное полноэкранное окно */
.mobile-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  z-index: 10001 !important;
  display: flex !important;
  flex-direction: column !important;
  background: white !important;
  overflow: hidden !important;
}

/* Контент и кнопки заполняют доступное пространство */
#chat-content, #chat-actions {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 1;
  flex-grow: 1;
}

/* Контейнер адаптирует высоту под весь экран */
#chat-window.mobile-fullscreen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

@supports (height: 100dvh) {
  #chat-window.mobile-fullscreen {
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
  }
}

/* Скрытие кнопки открытия чата */
#open-chat.hidden {
  display: none !important;
}