/* Чат-помощник «ДокТер» (демо). Цвета и шрифты — из site.css (:root). Логика — assets/chat.js.
   Работает с версией для слабовидящих: классы html.a11y-fs-*, html.a11y-c-*, html.a11y-ls (см. a11y.js). */
.dt-chat{position:fixed;right:20px;bottom:20px;z-index:90;font:400 16px/1.5 var(--body,ui-sans-serif,system-ui,sans-serif);color:var(--ink,#0F2430)}
.dt-chat *{box-sizing:border-box}
/* пока видна плашка cookie (html.ck-open, высота в --ck-h из extras.js) — на узком экране кнопку чата поднимаем над ней */
@media (max-width:900px){html.ck-open .dt-chat{bottom:calc(var(--ck-h,0px) + 24px)}}
@media (max-width:480px){html.ck-open .dt-chat{bottom:calc(var(--ck-h,0px) + 20px)}}

/* Плавающая кнопка */
.dt-chat-btn{display:inline-flex;align-items:center;gap:10px;min-height:52px;padding:14px 22px 14px 18px;border:1px solid transparent;border-radius:999px;
  background:var(--accent,#005CAA);color:#fff;font:600 15px/1 var(--body,sans-serif);cursor:pointer;
  box-shadow:0 14px 34px -14px rgba(0,92,170,.75),0 2px 6px rgba(15,36,48,.12);
  transition:background .3s var(--e-soft,ease),transform .3s var(--e-out,ease),box-shadow .3s var(--e-soft,ease)}
.dt-chat-btn:hover{background:var(--accent-hover,#00478A);transform:translateY(-1px)}
.dt-chat-btn:active{transform:scale(.98)}
.dt-chat-btn svg{width:20px;height:20px;flex-shrink:0}
.dt-chat.open .dt-chat-btn{display:none}

/* Панель */
.dt-chat-panel{position:absolute;right:0;bottom:0;width:380px;max-width:calc(100vw - 32px);height:600px;max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);
  display:flex;flex-direction:column;background:var(--panel,#F3F6F7);border:1px solid var(--line,#B9C8CE);border-radius:20px;overflow:hidden;
  box-shadow:0 30px 70px -30px rgba(15,36,48,.45),0 8px 24px -12px rgba(15,36,48,.2);
  transform-origin:100% 100%;transition:opacity .25s var(--e-out,ease),transform .3s var(--e-out,ease)}
.dt-chat-panel[hidden]{display:none}
.dt-chat:not(.open) .dt-chat-panel{opacity:0;transform:translateY(8px) scale(.98);pointer-events:none}

.dt-chat-head{display:flex;align-items:center;gap:12px;padding:14px 14px 14px 18px;background:var(--ink,#0F2430);color:#fff}
.dt-chat-head img{width:30px;height:30px;flex-shrink:0;background:#fff;border-radius:50%;padding:3px}
.dt-chat-title{flex:1;min-width:0}
.dt-chat-title b{display:block;font:600 15px/1.2 var(--display,sans-serif)}
.dt-chat-title small{display:block;margin-top:3px;font:500 11.5px/1.3 var(--mono,monospace);letter-spacing:.04em;color:#C9D6DC}
.dt-chat-close{width:36px;height:36px;border:0;border-radius:50%;background:rgba(255,255,255,.1);color:#fff;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:background .25s}
.dt-chat-close:hover{background:rgba(255,255,255,.22)}
.dt-chat-close svg{width:16px;height:16px}

/* История */
.dt-chat-log{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:16px 14px 8px;display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth}
.dt-msg{max-width:88%;padding:10px 14px;border-radius:16px;font-size:15px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere}
.dt-msg-bot{align-self:flex-start;background:#fff;border:1px solid var(--line,#B9C8CE);border-bottom-left-radius:6px}
.dt-msg-user{align-self:flex-end;background:var(--accent,#005CAA);color:#fff;border-bottom-right-radius:6px}
.dt-msg-sys{align-self:center;max-width:100%;padding:6px 12px;background:var(--panel-2,#DCE5E8);color:var(--ink-2,#435863);font-size:13px;border-radius:10px;text-align:center}
.dt-msg-err{background:#FFF1EC;border-color:#F1C7A6}
.dt-typing{align-self:flex-start;display:inline-flex;gap:5px;padding:12px 16px;background:#fff;border:1px solid var(--line,#B9C8CE);border-radius:16px;border-bottom-left-radius:6px;color:var(--ink-2,#435863);font-size:14px;align-items:center}
.dt-typing[hidden]{display:none}
.dt-typing i{width:6px;height:6px;border-radius:50%;background:var(--ink-2,#435863);opacity:.35;animation:dt-blink 1.2s infinite}
.dt-typing i:nth-child(2){animation-delay:.2s}.dt-typing i:nth-child(3){animation-delay:.4s}
@keyframes dt-blink{0%,80%,100%{opacity:.25}40%{opacity:1}}

/* Ввод */
.dt-chat-form{display:flex;gap:8px;padding:10px 12px 0;border-top:1px solid var(--line,#B9C8CE);background:var(--panel,#F3F6F7)}
.dt-chat-form textarea{flex:1;min-height:44px;max-height:120px;resize:none;padding:10px 14px;border:1px solid var(--line-strong,#7E959F);border-radius:14px;background:#fff;color:var(--ink,#0F2430);font:400 15px/1.4 var(--body,sans-serif)}
.dt-chat-form textarea:focus-visible{outline:2px solid var(--accent,#005CAA);outline-offset:1px}
.dt-chat-send{width:44px;height:44px;flex-shrink:0;border:0;border-radius:50%;background:var(--accent,#005CAA);color:#fff;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:background .25s;align-self:flex-end}
.dt-chat-send:hover{background:var(--accent-hover,#00478A)}
.dt-chat-send:disabled{opacity:.5;cursor:default}
.dt-chat-send svg{width:18px;height:18px}
.dt-chat-note{padding:7px 14px 10px;font:500 11.5px/1.4 var(--mono,monospace);letter-spacing:.03em;color:var(--ink-2,#435863);text-align:center;background:var(--panel,#F3F6F7)}

@media (max-width:480px){
  .dt-chat{right:12px;bottom:12px}
  .dt-chat-panel{width:calc(100vw - 24px);height:calc(100dvh - 24px)}
  .dt-chat-btn{padding:13px 18px 13px 16px}
}
@media (prefers-reduced-motion:reduce){
  .dt-chat-panel,.dt-chat-btn{transition:none}
  .dt-typing i{animation:none;opacity:.7}
  .dt-chat-log{scroll-behavior:auto}
}

/* ===== Версия для слабовидящих (классы на <html>, см. a11y.js) ===== */
html.a11y-fs-1 .dt-chat{zoom:1.25}
html.a11y-fs-2 .dt-chat{zoom:1.5}
html.a11y-fs-1 .dt-chat-panel{max-height:calc((100vh - 32px)/1.25)}
html.a11y-fs-2 .dt-chat-panel{max-height:calc((100vh - 32px)/1.5)}
html.a11y-c .dt-chat-panel,html.a11y-c .dt-msg-bot,html.a11y-c .dt-msg-sys,html.a11y-c .dt-typing,html.a11y-c .dt-chat-form textarea{border:2px solid var(--a-fg)!important}
html.a11y-c .dt-chat-head{border-bottom:2px solid var(--a-fg)!important}
html.a11y-c .dt-chat-form{border-top:2px solid var(--a-fg)!important}
html.a11y-c .dt-chat-btn,html.a11y-c .dt-msg-user,html.a11y-c .dt-chat-send,html.a11y-c .dt-chat-close{background-color:var(--a-fg)!important;color:var(--a-bg)!important;border:2px solid var(--a-fg)!important}
html.a11y-c .dt-chat-head img{background-color:#fff!important}
html.a11y-noimg .dt-chat-head img{display:none}
html.a11y-c .dt-chat-btn span{background-color:transparent!important;color:var(--a-bg)!important}
