/* ============================================================
   Zedro Chat — виджет AI-ассистента
   Адаптировано под дизайн-систему zedrostudio.ru:
   - Исправлены синтаксические ошибки комментариев (/* ... */)
   - Оптимизированы отступы пузырей (12px 16px вместо 20px 24px)
   - Добавлена поддержка 100dvh для корректного отображения на мобильных
   - Улучшены тени и анимации для премиального вида
   ============================================================ */

#zedro-chat * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Когда чат открыт — прячем плавающую кнопку */
body.zc-chat-open .call-fab,
body.zc-chat-open .zc-fab {
  display: none !important;
}

#zedro-chat {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1A1A1A;
}

/* --- Плавающая кнопка (FAB) --- */
.zc-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--orange, #FF4D00);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(255, 77, 0, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
}
.zc-fab:hover { transform: scale(1.05); }
.zc-fab:active { transform: scale(0.94); }

.zc-fab .zc-fab-close { display: none; }
.zc-fab.active .zc-fab-open { display: none; }
.zc-fab.active .zc-fab-close { display: block; }

/* Пульс-ободок вокруг кнопки */
.zc-fab.pulse::after {
  content: "";
  position: absolute;
  inset: -6px;
  z-index: -1;
  border-radius: 50%;
  border: 2px solid var(--orange, #FF4D00);
  animation: zc-pulse 2s ease-out infinite;
  pointer-events: none;
}
@keyframes zc-pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

.zc-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  z-index: 2;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1A1A1A;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--orange, #FF4D00);
}

/* --- Панель чата --- */
.zc-panel {
  position: fixed;
  right: 18px;
  bottom: 86px; /* Исходная позиция над кнопкой */
  z-index: 1001;
  width: min(380px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 120px));
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.3s ease;
}

.zc-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  bottom: 18px; /* Плавно занимает место исчезнувшей кнопки */
}

/* --- Шапка --- */
.zc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #1A1A1A;
  color: #fff;
}
.zc-head-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange, #FF4D00);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.zc-head-info { flex: 1; }
.zc-head-info b { display: block; font-size: 15px; font-weight: 600; }
.zc-head-info span { font-size: 12px; opacity: 0.75; }
.zc-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  flex-shrink: 0;
}
.zc-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.zc-close:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

/* --- Тело чата --- */
.zc-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #F7F5F2;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Пузыри сообщений (исправлены отступы и переносы) */
.zc-msg {
  max-width: 85%;
  min-width: 60px;
  padding: 12px 16px; /* Оптимальный запас, не громоздкий */
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Гарантия отступов пузырей: специфичность выше глобального сброса #zedro-chat * {padding:0} */
#zedro-chat .zc-msg {
  padding: 12px 16px;
}
.zc-msg.bot {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom-left-radius: 6px;
  align-self: flex-start;
  color: #1A1A1A;
}
.zc-msg.user {
  background: var(--orange, #FF4D00);
  color: #fff;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
}

/* Индикатор набора текста */
.zc-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  align-self: flex-start;
  border: 1px solid rgba(0, 0, 0, 0.08);
  width: fit-content;
}
.zc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #aaa;
  animation: zc-blink 1.2s infinite;
}
.zc-typing span:nth-child(2) { animation-delay: 0.2s; }
.zc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes zc-blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Быстрые кнопки */
.zc-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 16px;
  background: #F7F5F2;
}
.zc-q-btn {
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--orange, #FF4D00);
  background: transparent;
  color: var(--orange, #FF4D00);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.zc-q-btn:hover {
  background: var(--orange, #FF4D00);
  color: #fff;
}

/* --- Ввод сообщения --- */
.zc-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.zc-input-row input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  background: #F7F5F2;
  transition: border-color 0.2s, background 0.2s;
}
.zc-input-row input:focus {
  border-color: var(--orange, #FF4D00);
  background: #fff;
}
.zc-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: var(--orange, #FF4D00);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}
.zc-send:hover {
  transform: scale(1.05);
  background: #e64500;
}
.zc-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Форма заявки --- */
.zc-lead {
  padding: 16px;
  background: #F7F5F2;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zc-lead[hidden] { display: none; }
.zc-lead p {
  font-size: 14px;
  color: #1A1A1A;
  font-weight: 600;
  margin: 0;
}
.zc-lead input {
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  background: #fff;
  transition: border-color 0.2s;
}
.zc-lead input:focus {
  border-color: var(--orange, #FF4D00);
}
.zc-btn {
  padding: 12px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: var(--orange, #FF4D00);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}
.zc-btn:hover { background: #e64500; }
.zc-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.zc-lead-status {
  font-size: 13px;
  color: #C62828;
  min-height: 18px;
}

/* --- Мобильная адаптация --- */
@media (max-width: 768px) {
  .zc-fab {
    right: 16px;
    bottom: 16px;
  }
  .zc-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100dvh; /* Динамическая высота для мобильных браузеров (Safari/Chrome) */
    max-height: 100dvh;
    border-radius: 0;
    transform: translateY(100%); /* Сдвиг вниз для анимации "шторки" */
  }
  .zc-panel.open {
    transform: translateY(0);
    bottom: 0;
  }
}