/* ====================== ЧАТ-ВИДЖЕТ (кнопка справа внизу) ====================== */
.cw{ --cw-accent:#8a5f37; --cw-accent-d:#6f4a28; position:fixed; right:20px; bottom:20px; z-index:9000;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
.cw *{ box-sizing:border-box; }

/* Плавающая кнопка */
.cw-fab{ width:60px; height:60px; border-radius:50%; border:none; cursor:pointer; position:relative;
  background:var(--cw-accent); color:#fff; display:flex; align-items:center; justify-content:center;
  box-shadow:0 10px 30px -8px rgba(138,95,55,.6); transition:transform .2s, background .2s; }
.cw-fab:hover{ background:var(--cw-accent-d); transform:translateY(-2px); }
.cw-fab svg{ width:28px; height:28px; }
.cw-fab .cw-ico-close{ display:none; }
.cw.is-menu .cw-fab .cw-ico-chat, .cw.is-open .cw-fab .cw-ico-chat{ display:none; }
.cw.is-menu .cw-fab .cw-ico-close, .cw.is-open .cw-fab .cw-ico-close{ display:block; }
/* пульсация для привлечения внимания */
.cw-fab::after{ content:""; position:absolute; inset:0; border-radius:50%; border:2px solid var(--cw-accent);
  animation:cw-pulse 2.2s ease-out infinite; }
.cw.is-menu .cw-fab::after, .cw.is-open .cw-fab::after{ display:none; }
@keyframes cw-pulse{ 0%{ transform:scale(1); opacity:.6; } 100%{ transform:scale(1.6); opacity:0; } }

.cw-badge{ position:absolute; top:-3px; right:-3px; min-width:20px; height:20px; padding:0 5px; border-radius:100px;
  background:#c0492f; color:#fff; font-size:11px; font-weight:700; display:none; align-items:center; justify-content:center; box-shadow:0 0 0 2px #fff; }
.cw.has-unread .cw-badge{ display:flex; }

/* Меню выбора: позвонить / чат */
.cw-menu{ position:absolute; right:4px; bottom:74px; display:flex; flex-direction:column; gap:10px; align-items:flex-end;
  opacity:0; transform:translateY(10px); pointer-events:none; transition:opacity .2s, transform .2s; }
.cw.is-menu .cw-menu{ opacity:1; transform:translateY(0); pointer-events:auto; }
.cw-menu-item{ display:flex; align-items:center; gap:10px; background:#fff; color:#141414; border:none; cursor:pointer;
  padding:11px 16px; border-radius:100px; font-size:14.5px; font-weight:600; text-decoration:none; white-space:nowrap;
  box-shadow:0 8px 24px -10px rgba(0,0,0,.35); transition:transform .15s; }
.cw-menu-item:hover{ transform:translateX(-3px); }
.cw-menu-item .cw-mi-ico{ width:34px; height:34px; border-radius:50%; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.cw-menu-item .cw-mi-ico svg{ width:18px; height:18px; }
.cw-menu-item.call .cw-mi-ico{ background:#e8f5e9; color:#2e9e4f; }
.cw-menu-item.chat .cw-mi-ico{ background:var(--cw-accent); color:#fff; }

/* Панель чата */
.cw-panel{ position:absolute; right:0; bottom:74px; width:360px; max-width:calc(100vw - 32px); height:520px;
  max-height:calc(100vh - 110px); background:#fff; border-radius:18px; overflow:hidden; display:none; flex-direction:column;
  box-shadow:0 24px 60px -18px rgba(0,0,0,.4); }
.cw.is-open .cw-panel{ display:flex; }
.cw.is-open .cw-menu{ opacity:0; pointer-events:none; }

.cw-head{ background:var(--cw-accent); color:#fff; padding:16px 18px; display:flex; align-items:center; gap:12px; }
.cw-head .cw-h-ava{ width:40px; height:40px; border-radius:50%; background:rgba(255,255,255,.2); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.cw-head .cw-h-ava svg{ width:22px; height:22px; }
.cw-head .cw-h-main{ flex:1; min-width:0; }
.cw-head .cw-h-title{ font-weight:700; font-size:15.5px; }
.cw-head .cw-h-sub{ font-size:12.5px; opacity:.85; }
.cw-head .cw-h-call{ color:#fff; opacity:.9; }
.cw-head .cw-h-call:hover{ opacity:1; }

.cw-msgs{ flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:9px; background:#faf9f7; }
.cw-msg{ max-width:82%; padding:9px 13px; border-radius:14px; font-size:14.5px; line-height:1.4; word-wrap:break-word; white-space:pre-wrap; }
.cw-msg.in{ align-self:flex-end; background:var(--cw-accent); color:#fff; border-bottom-right-radius:4px; }
.cw-msg.out{ align-self:flex-start; background:#fff; border:1px solid rgba(20,20,20,.08); border-bottom-left-radius:4px; }
.cw-msg.system{ align-self:center; background:#fff3e0; color:#8a5a12; border:1px solid #f0d9b5; text-align:center; font-size:13.5px; max-width:92%; }
.cw-msg .cw-m-time{ font-size:10.5px; opacity:.6; margin-top:3px; }

.cw-composer{ display:flex; gap:8px; padding:11px 12px; border-top:1px solid rgba(20,20,20,.08); background:#fff; }
.cw-composer textarea{ flex:1; resize:none; border:1px solid rgba(20,20,20,.16); border-radius:12px; padding:10px 13px;
  font-size:15px; font-family:inherit; max-height:110px; }
.cw-composer textarea:focus{ outline:none; border-color:var(--cw-accent); }
.cw-composer button{ background:var(--cw-accent); color:#fff; border:none; border-radius:12px; width:44px; flex-shrink:0;
  font-size:18px; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.cw-composer button:hover{ background:var(--cw-accent-d); }
.cw-composer button:disabled{ opacity:.5; cursor:default; }

@media (max-width:480px){
  .cw{ right:14px; bottom:14px; }
  .cw-panel{ bottom:72px; height:calc(100vh - 96px); }
}
