/* Виджет чата AzerGid — ВРЕМЕННАЯ разметка на токенах темы (DESIGN-CHAT §4, решение Д 19.09).
   Ни одного своего цвета: только var(--…) темы. Заменяется компонентом ag-chat темы. */
.azg-chat [hidden] { display: none !important; } /* наши display:flex/grid иначе перебивают [hidden] браузера */
.azg-chat { position: fixed; right: 16px; bottom: 16px; z-index: var(--ag-layer-drawer, 1200); font-family: inherit; }
/* Мобильное меню темы открыто (body.ag-menu-open): виджет целиком — кнопка, плашка, открытая панель — уходит
   на слой НИЖЕ подложки меню (300 → 299), чтобы не закрывать стрелки нижних пунктов. Только слой: кнопку не
   прятать (display/visibility/opacity не трогаем) — она видна сквозь подложку и возвращается наверх, как
   только меню закрыто. Клики по нему при открытом меню забирает подложка темы (закрывает меню) (09.10). */
body.ag-menu-open .azg-chat { z-index: calc(var(--ag-layer-drawer-backdrop, 300) - 1); }
/* Кнопка ассистента — изолирована от .ag-button темы: селектор .azg-chat .azg-chat__launcher (0,2,0) и все
   свойства формы заданы явно, поэтому порядок подключения CSS темы на разных шаблонах форму не меняет (06.10). */
.azg-chat .azg-chat__launcher { box-sizing: border-box; width: 60px; height: 60px; min-width: 60px; min-height: 60px; margin: 0; padding: 0; border: 2px solid var(--color-brand-gold, #D8872A); border-radius: 50%; display: grid; place-items: center; position: relative; background: var(--color-deep-navy, #1E2A36); color: var(--color-warm-white, #FAF8F5); box-shadow: 0 6px 18px rgba(17, 28, 40, .24); cursor: pointer; transform: none; transition: transform .15s ease, box-shadow .15s ease; -webkit-tap-highlight-color: transparent; }
.azg-chat .azg-chat__launcher:hover { transform: translateY(-1px) scale(1.04); box-shadow: 0 10px 24px rgba(17, 28, 40, .28); }
.azg-chat .azg-chat__launcher:focus-visible { outline: 3px solid var(--color-brand-gold, #D8872A); outline-offset: 3px; }
.azg-chat__icon-svg { display: block; width: 30px; height: 30px; position: relative; z-index: 1; }
.azg-chat__launcher[data-icon="b"] .azg-chat__icon-svg { width: 34px; height: 34px; }
.azg-chat__icon-accent { fill: var(--color-brand-gold, #D8872A); }
/* Волны вокруг кнопки: пока у корня класс azg-chat--pulse (JS: всегда, кроме открытого чата) — мягкая волна раз в 3,5 с. */
.azg-chat__wave { position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--color-brand-gold, #D8872A); opacity: 0; pointer-events: none; }
.azg-chat--pulse .azg-chat__wave { animation: azg-chat-wave 3.5s ease-out infinite; }
.azg-chat--pulse .azg-chat__wave--2 { animation-delay: .4s; }
@keyframes azg-chat-wave { 0% { transform: scale(1); opacity: .6; } 55% { transform: scale(1.7); opacity: 0; } 100% { transform: scale(1.7); opacity: 0; } }
/* Подсказка первого визита: слева от кнопки, по центру её высоты; кнопку не перекрывает. */
.azg-chat__hint { position: absolute; right: 72px; bottom: 9px; box-sizing: border-box; width: max-content; display: flex; align-items: center; gap: 2px; max-width: min(260px, calc(100vw - 112px)); padding: 4px 4px 4px 14px; background: var(--color-warm-white, #FAF8F5); color: var(--color-deep-navy, #1E2A36); border: 1px solid var(--color-brand-gold, #D8872A); border-radius: 999px; box-shadow: 0 6px 18px rgba(17, 28, 40, .16); animation: azg-chat-hint-in .3s ease-out; }
.azg-chat__hint::after { content: ""; position: absolute; right: -6px; top: 50%; width: 10px; height: 10px; margin-top: -5px; background: inherit; border-top: 1px solid var(--color-brand-gold, #D8872A); border-right: 1px solid var(--color-brand-gold, #D8872A); transform: rotate(45deg); }
.azg-chat .azg-chat__hint-text { margin: 0; padding: 6px 0; border: 0; background: transparent; color: inherit; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.25; text-align: left; white-space: normal; cursor: pointer; }
.azg-chat .azg-chat__hint-close { flex: 0 0 auto; width: 32px; height: 32px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ag-muted, #6B7280); font-size: 13px; line-height: 32px; cursor: pointer; }
.azg-chat .azg-chat__hint-close:hover { background: rgba(17, 28, 40, .08); }
@keyframes azg-chat-hint-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.azg-chat[data-state="open"] .azg-chat__hint { display: none; }
.azg-chat[data-state="open"] .azg-chat__wave, .azg-chat[data-state="offline"] .azg-chat__wave { animation: none; opacity: 0; } /* чат открыт — без волн */
@media (prefers-reduced-motion: reduce) {
  .azg-chat .azg-chat__wave { display: none; animation: none; }
  .azg-chat__hint { animation: none; }
  .azg-chat .azg-chat__launcher, .azg-chat .azg-chat__launcher:hover { transition: none; transform: none; }
}
.azg-chat__badge { position: absolute; z-index: 2; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--ag-radius-pill, 999px); background: var(--color-brand-gold); color: var(--color-deep-navy); font-size: 12px; line-height: 20px; font-weight: 700; text-align: center; }
.azg-chat__panel { position: fixed; right: 16px; bottom: 88px; width: min(380px, calc(100vw - 32px)); height: min(600px, calc(100vh - 110px)); display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--color-warm-white); border: var(--border-subtle); border-radius: var(--ag-radius-lg, 16px); box-shadow: var(--ag-shadow-float, 0 12px 32px rgba(0,0,0,.2)); }
.azg-chat__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 14px; background: var(--color-deep-navy); color: var(--color-warm-white); }
.azg-chat__title { display: block; font-size: 15px; line-height: 1.2; }
.azg-chat__status { display: block; font-size: 12px; opacity: .8; }
.azg-chat__actions { display: flex; gap: 4px; }
.azg-chat__icon { width: 44px; height: 44px; border: 0; background: transparent; color: inherit; font-size: 16px; border-radius: var(--ag-radius-md, 8px); cursor: pointer; }
.azg-chat__icon:hover { background: rgba(255,255,255,.12); }
.azg-chat__messages { flex: 1 1 auto; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--ag-surface-muted, var(--color-warm-white)); }
.azg-chat__bubble { max-width: 88%; padding: 8px 12px; border-radius: var(--ag-radius-lg, 16px); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.azg-chat__bubble--user { align-self: flex-end; background: var(--color-deep-navy); color: var(--color-warm-white); border-bottom-right-radius: 4px; }
.azg-chat__bubble--assistant { align-self: flex-start; background: var(--ag-surface-raised, #fff); color: var(--color-charcoal); border: var(--border-subtle); border-bottom-left-radius: 4px; }
.azg-chat__bubble--operator { align-self: flex-start; background: var(--color-sand, #f3ead9); color: var(--color-charcoal); border-bottom-left-radius: 4px; }
.azg-chat__bubble--system { align-self: center; max-width: 100%; background: transparent; color: var(--ag-muted, var(--color-stone)); font-size: 12px; text-align: center; }
.azg-chat__bubble--warn { align-self: stretch; max-width: 100%; background: var(--ag-surface-raised, #fff); color: var(--color-charcoal); border: 1px solid var(--color-brand-gold); border-left-width: 4px; font-size: 13px; } /* отказ очистки при открытом обращении — заметно, не серой строкой */
.azg-chat__author { display: block; font-size: 11px; opacity: .7; margin-bottom: 2px; }
.azg-chat__bubble a { color: inherit; text-decoration: underline; }
.azg-chat__bubble--assistant a { color: var(--color-caspian-blue, var(--color-deep-navy)); }
.azg-chat__typing { padding: 4px 14px; font-size: 12px; color: var(--ag-muted, var(--color-stone)); }
.azg-chat__typing em { font-style: normal; }
.azg-chat__typing span { display: inline-block; width: 6px; height: 6px; margin-right: 2px; border-radius: 50%; background: currentColor; animation: azg-chat-dot 1s infinite; }
.azg-chat__typing span:nth-child(2) { animation-delay: .2s; } .azg-chat__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes azg-chat-dot { 0%, 80%, 100% { opacity: .3 } 40% { opacity: 1 } }
.azg-chat__suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.azg-chat__suggestions:empty { display: none; }
.azg-chat__chip { min-height: 40px; padding: 6px 12px; border: var(--border-subtle); border-radius: var(--ag-radius-pill, 999px); background: var(--color-warm-white); color: var(--color-deep-navy); font-size: 12px; cursor: pointer; }
.azg-chat__chip:hover { border-color: var(--color-brand-gold); }
.azg-chat__notice { margin: 8px 12px 0; min-width: 0; }
.azg-chat__notice-body { min-width: 0; }
.azg-chat__notice .ag-alert__text { margin: 0; overflow-wrap: anywhere; }
.azg-chat__contact { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.azg-chat__form { display: grid; gap: 8px; padding: 8px 12px 0; }
.azg-chat__composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding: 10px 12px 12px; border-top: var(--border-subtle); position: relative; }
.azg-chat__input { resize: none; max-height: 120px; min-height: 44px; }
.azg-chat__send { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.azg-chat__counter { position: absolute; right: 64px; bottom: 16px; font-size: 11px; color: var(--ag-muted, var(--color-stone)); }
.azg-chat[data-state="offline"] .azg-chat__composer { display: none; }
.azg-chat[data-busy="1"] .azg-chat__send { opacity: .5; pointer-events: none; }
/* 429: до Retry-After кнопка «Отправить» неактивна (текст лимита — в ленте) */
.azg-chat[data-limited="1"] .azg-chat__send { opacity: .5; pointer-events: none; }
@media (max-width: 767px) {
  .azg-chat { right: 12px; bottom: calc(var(--shell-bottom-nav-height, 68px) + 12px + env(safe-area-inset-bottom, 0px)); }
  /* Панель под шапкой и НАД нижней навигацией темы — навигация остаётся доступной. */
  .azg-chat__panel { right: 0; left: 0; bottom: calc(var(--shell-bottom-nav-height, 68px) + env(safe-area-inset-bottom, 0px)); top: var(--shell-header-height-mobile, 56px); width: 100vw; height: auto; border-radius: 0; }
  .azg-chat[data-state="open"] .azg-chat__launcher { display: none; }
}
