/* Cacao AI Chat widget */
:root { --cacao-accent: #5D3A1A; }

/* Очень высокий z-index: чтобы открытое окно чата было поверх сторонних плавающих
   кнопок сайта (напр. виджета Telegram), а не наоборот. */
#cacao-chat { position: fixed; right: 20px; bottom: 20px; z-index: 2147483647; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }

#cacao-chat-fab {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--cacao-accent); color: #fff; font-size: 28px; line-height: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); transition: transform .15s ease;
}
#cacao-chat-fab:hover { transform: scale(1.08); }

#cacao-chat-win {
  position: absolute; right: 0; bottom: 74px; width: 360px; max-width: calc(100vw - 32px);
  height: 520px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.28);
  display: none; flex-direction: column; overflow: hidden;
}
#cacao-chat-win.cch-open { display: flex; }

.cch-head { background: var(--cacao-accent); color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }
.cch-title { font-weight: 600; font-size: 15px; }
.cch-close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }

.cch-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; background: #FAF6F1; }

.cch-m { max-width: 85%; margin: 0 0 10px; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.cch-bot { background: #fff; color: #2b2b2b; border: 1px solid #EADFD3; border-bottom-left-radius: 4px; }
.cch-user { background: var(--cacao-accent); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.cch-bot a { color: var(--cacao-accent); font-weight: 600; }

.cch-typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: #C8B39B; animation: cch-blink 1.2s infinite both; }
.cch-typing span:nth-child(2) { animation-delay: .2s; }
.cch-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cch-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.cch-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.cch-btn {
  display: inline-block; background: #fff; border: 1.5px solid var(--cacao-accent); color: var(--cacao-accent);
  border-radius: 18px; padding: 7px 13px; font-size: 13px; cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background .12s ease, color .12s ease;
}
.cch-btn:hover { background: var(--cacao-accent); color: #fff; }
.cch-link { margin-top: 8px; }

.cch-lead { display: flex; flex-direction: column; gap: 7px; margin: 2px 0 12px; max-width: 85%; }
/* 16px обязательно: при меньшем шрифте iOS Safari принудительно зумит страницу при фокусе */
.cch-lead input { border: 1px solid #D8C9B8; border-radius: 10px; padding: 9px 12px; font-size: 16px; }

.cch-card {
  display: flex; gap: 10px; align-items: flex-start; max-width: 92%;
  background: #fff; border: 1px solid #EADFD3; border-radius: 14px;
  padding: 10px; margin: 0 0 10px;
}
.cch-card-img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; }
.cch-card-body { min-width: 0; }
.cch-card-title { font-weight: 600; font-size: 13.5px; color: #2b2b2b; line-height: 1.3; }
.cch-card-price { color: var(--cacao-accent); font-weight: 700; font-size: 14px; margin: 3px 0; }
.cch-card-desc { font-size: 12px; color: #6d5c49; line-height: 1.35; margin-bottom: 7px; }
.cch-oos { color: #b00; font-weight: 400; font-size: 12px; }

.cch-input { display: flex; border-top: 1px solid #EADFD3; background: #fff; }
/* 16px обязательно: при меньшем шрифте iOS Safari зумит страницу при фокусе поля */
.cch-input input { flex: 1; border: none; outline: none; padding: 13px 14px; font-size: 16px; }
.cch-send { border: none; background: none; color: var(--cacao-accent); font-size: 20px; cursor: pointer; padding: 0 16px; }

.cch-note { font-size: 10.5px; color: #A69582; text-align: center; padding: 5px 10px 8px; background: #fff; }
.cch-note a { color: inherit; }

/* Пока чат открыт — прячем круглую кнопку, чтобы не налезала на окно */
#cacao-chat.cch-is-open #cacao-chat-fab { display: none; }

@media (max-width: 480px) {
  #cacao-chat { right: 16px; bottom: 16px; }
  /* На мобильном окно крепим к экрану с полями по краям — без горизонтальной прокрутки,
     высота через dvh корректно учитывает выехавшую клавиатуру */
  #cacao-chat-win {
    position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto;
    width: auto; max-width: none;
    height: auto; max-height: 82vh; max-height: 82dvh;
  }
}
