/* WorldClass CRM — «Помощник» для новичков (чат-энциклопедия в стиле ИИ-чата).
   Круглая кнопка в правом нижнем углу + окно чата. На телефоне окно открывается на весь экран. */

.wch-fab{
  position:fixed;right:24px;bottom:24px;z-index:240;
  width:58px;height:58px;border-radius:50%;border:none;padding:0;cursor:pointer;
  background:linear-gradient(145deg,#FF4A50 0%,#E31E24 55%,#B4181D 100%);
  color:#fff;display:flex;align-items:center;justify-content:center;
  box-shadow:0 10px 28px rgba(227,30,36,.42),0 2px 6px rgba(0,0,0,.18);
  transition:transform .18s ease,box-shadow .18s ease;
  -webkit-tap-highlight-color:transparent;
}
.wch-fab:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 14px 32px rgba(227,30,36,.5),0 2px 8px rgba(0,0,0,.2);}
.wch-fab:active{transform:scale(.95);}
.wch-fab svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;}
.wch-fab .wch-ico-close{display:none;}
.wch-fab.is-open .wch-ico-chat{display:none;}
.wch-fab.is-open .wch-ico-close{display:block;}
.wch-fab-dot{
  position:absolute;top:-2px;right:-2px;min-width:20px;height:20px;padding:0 5px;border-radius:10px;
  background:#fff;color:var(--red,#E31E24);font-size:11px;font-weight:800;line-height:20px;text-align:center;
  box-shadow:0 0 0 2px var(--red,#E31E24);
}
.wch-fab-dot.hidden,.wch-fab.is-open .wch-fab-dot{display:none;}
.wch-fab::after{ /* мягкая пульсация, пока новичок не открыл помощника */
  content:"";position:absolute;inset:0;border-radius:50%;
  box-shadow:0 0 0 0 rgba(227,30,36,.45);animation:wchPulse 2.4s ease-out infinite;pointer-events:none;
}
.wch-fab.seen::after,.wch-fab.is-open::after{animation:none;}
@keyframes wchPulse{0%{box-shadow:0 0 0 0 rgba(227,30,36,.45);}70%{box-shadow:0 0 0 16px rgba(227,30,36,0);}100%{box-shadow:0 0 0 0 rgba(227,30,36,0);}}

/* подсказка-приветствие над кнопкой (один раз) */
.wch-teaser{
  position:fixed;right:24px;bottom:96px;z-index:240;max-width:250px;
  background:#fff;color:var(--text,#1B1B19);border:1px solid var(--line,#E7E5DF);border-radius:16px 16px 4px 16px;
  padding:11px 14px;font-size:13px;line-height:1.4;font-weight:500;cursor:pointer;
  box-shadow:0 12px 32px rgba(0,0,0,.16);animation:wchPop .3s cubic-bezier(.2,.8,.2,1);
}
.wch-teaser b{font-weight:700;}
.wch-teaser-x{
  position:absolute;top:-9px;left:-9px;width:22px;height:22px;border-radius:50%;border:1px solid var(--line,#E7E5DF);
  background:#fff;color:var(--muted,#8B8A85);font-size:13px;line-height:20px;text-align:center;cursor:pointer;padding:0;
}
.wch-teaser.hidden{display:none;}
@keyframes wchPop{from{opacity:0;transform:translateY(8px) scale(.96);}to{opacity:1;transform:none;}}

/* окно чата */
.wch-panel{
  position:fixed;right:24px;bottom:96px;z-index:1100;
  width:392px;height:min(640px,calc(100vh - 124px));
  display:none;flex-direction:column;overflow:hidden;
  background:var(--paper,#F5F4F0);border-radius:20px;border:1px solid var(--line,#E7E5DF);
  box-shadow:0 24px 64px rgba(0,0,0,.28),0 4px 14px rgba(0,0,0,.12);
  font-family:'Inter',sans-serif;color:var(--text,#1B1B19);
  transform-origin:bottom right;
}
.wch-panel.open{display:flex;animation:wchOpen .22s cubic-bezier(.2,.8,.2,1);}
@keyframes wchOpen{from{opacity:0;transform:translateY(14px) scale(.96);}to{opacity:1;transform:none;}}

.wch-head{
  flex:0 0 auto;display:flex;align-items:center;gap:11px;padding:13px 14px;
  background:linear-gradient(135deg,#1d1e21 0%,#2B2C2F 100%);color:#fff;
  padding-top:calc(13px + env(safe-area-inset-top,0px));
}
.wch-ava{
  position:relative;flex:0 0 auto;width:42px;height:42px;border-radius:50%;
  background:linear-gradient(145deg,#FF4A50,#E31E24 60%,#B4181D);
  display:flex;align-items:center;justify-content:center;color:#fff;
  box-shadow:0 0 0 2px rgba(255,255,255,.18);
}
.wch-ava svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.wch-ava.sm{width:30px;height:30px;box-shadow:none;}
.wch-ava.sm svg{width:17px;height:17px;}
.wch-ava .wch-online{
  position:absolute;right:-1px;bottom:-1px;width:12px;height:12px;border-radius:50%;
  background:#2BD27A;border:2px solid #232427;
}
.wch-title{flex:1 1 auto;min-width:0;}
.wch-title b{display:block;font-size:15px;font-weight:700;line-height:1.2;}
.wch-title span{display:block;font-size:11.5px;color:#B9BABF;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.wch-hbtn{
  flex:0 0 auto;width:34px;height:34px;border-radius:50%;border:none;background:rgba(255,255,255,.1);
  color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;
  transition:background .15s;-webkit-tap-highlight-color:transparent;
}
.wch-hbtn:hover{background:rgba(255,255,255,.2);}
.wch-hbtn svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}

.wch-body{
  flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:16px 12px 8px;
  display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
.wch-day{align-self:center;font-size:11px;font-weight:600;color:var(--muted,#8B8A85);background:rgba(0,0,0,.05);border-radius:10px;padding:3px 10px;}

.wch-row{display:flex;align-items:flex-end;gap:8px;max-width:100%;animation:wchMsg .25s ease-out;}
.wch-row.user{justify-content:flex-end;}
@keyframes wchMsg{from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:none;}}
.wch-bubble{
  max-width:calc(100% - 42px);padding:10px 13px;border-radius:18px;font-size:14px;line-height:1.5;
  word-wrap:break-word;overflow-wrap:anywhere;
}
.wch-row.bot .wch-bubble{background:#fff;border:1px solid var(--line,#E7E5DF);border-bottom-left-radius:5px;box-shadow:0 1px 2px rgba(0,0,0,.04);}
.wch-row.user .wch-bubble{background:linear-gradient(145deg,#F03A40,#E31E24);color:#fff;border-bottom-right-radius:5px;max-width:84%;}
.wch-bubble b{font-weight:700;}
.wch-bubble p{margin:0;}
.wch-bubble p+p,.wch-bubble ul+p,.wch-bubble p+ul{margin-top:8px;}
.wch-bubble ul{margin:0;padding-left:18px;}
.wch-bubble li{margin:2px 0;}
.wch-bubble .wch-step{display:flex;gap:8px;margin:5px 0;}
.wch-bubble .wch-step i{
  flex:0 0 auto;width:20px;height:20px;border-radius:50%;background:var(--red,#E31E24);color:#fff;
  font-style:normal;font-size:11px;font-weight:700;line-height:20px;text-align:center;margin-top:1px;
}
.wch-bubble .wch-tip{
  margin-top:9px;padding:8px 10px;border-radius:10px;background:var(--amber-bg,#FBEDDA);color:#7a4a08;font-size:12.5px;line-height:1.45;
}
.wch-time{font-size:10.5px;color:var(--muted,#8B8A85);margin:3px 4px 0;}

/* «печатает…» */
.wch-typing{display:inline-flex;gap:4px;align-items:center;padding:4px 2px;}
.wch-typing span{width:7px;height:7px;border-radius:50%;background:#B8B7B1;animation:wchDot 1.1s infinite ease-in-out;}
.wch-typing span:nth-child(2){animation-delay:.15s;}
.wch-typing span:nth-child(3){animation-delay:.3s;}
@keyframes wchDot{0%,60%,100%{transform:translateY(0);opacity:.5;}30%{transform:translateY(-5px);opacity:1;}}

/* быстрые ответы-«чипсы» */
.wch-chips{display:flex;flex-wrap:wrap;gap:7px;padding-left:38px;animation:wchMsg .25s ease-out;}
.wch-chip{
  border:1px solid var(--red,#E31E24);background:#fff;color:var(--red-dark,#B4181D);
  border-radius:16px;padding:7px 12px;font-family:inherit;font-size:13px;font-weight:600;line-height:1.25;
  text-align:left;cursor:pointer;transition:background .15s,color .15s,transform .1s;-webkit-tap-highlight-color:transparent;
}
.wch-chip:hover{background:var(--red,#E31E24);color:#fff;}
.wch-chip:active{transform:scale(.97);}
.wch-chip.ghost{border-color:var(--line,#E7E5DF);color:var(--text,#1B1B19);}
.wch-chip.ghost:hover{background:var(--ink,#17181A);border-color:var(--ink,#17181A);color:#fff;}
.wch-chip.go{border-color:var(--ink,#17181A);color:var(--ink,#17181A);}
.wch-chip.go:hover{background:var(--ink,#17181A);color:#fff;}
.wch-chips.used .wch-chip{opacity:.45;pointer-events:none;}

/* поле ввода */
.wch-foot{
  flex:0 0 auto;display:flex;align-items:flex-end;gap:8px;padding:10px 12px;background:#fff;border-top:1px solid var(--line,#E7E5DF);
  padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));
}
.wch-input{
  flex:1 1 auto;min-width:0;border:1px solid var(--line,#E7E5DF);background:var(--paper,#F5F4F0);border-radius:20px;
  padding:10px 14px;font-family:inherit;font-size:14px;line-height:1.35;color:var(--text,#1B1B19);outline:none;
  resize:none;max-height:96px;height:40px;
}
.wch-input:focus{border-color:var(--red,#E31E24);background:#fff;}
.wch-send{
  flex:0 0 auto;width:40px;height:40px;border-radius:50%;border:none;background:var(--red,#E31E24);color:#fff;cursor:pointer;
  display:flex;align-items:center;justify-content:center;padding:0;transition:background .15s,transform .1s;
}
.wch-send:hover{background:var(--red-dark,#B4181D);}
.wch-send:active{transform:scale(.92);}
.wch-send:disabled{background:#CFCDC6;cursor:default;}
.wch-send svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.wch-disclaimer{flex:0 0 auto;text-align:center;font-size:10.5px;color:var(--muted,#8B8A85);padding:0 12px 6px;background:#fff;}

/* пока открыт помощник, другие плавающие элементы не мешают */
html.wch-open-mobile{overflow:hidden;}

/* ===== ТЕЛЕФОН / ПЛАНШЕТ ===== */
@media (max-width:980px){
  /* кнопка — над плавающей нижней панелью навигации */
  .wch-fab{right:14px;bottom:calc(88px + env(safe-area-inset-bottom,0px));width:54px;height:54px;}
  .wch-fab svg{width:26px;height:26px;}
  .wch-teaser{right:14px;bottom:calc(152px + env(safe-area-inset-bottom,0px));max-width:min(250px,calc(100vw - 40px));}
  /* пока открыт разговор в «Чате», нижняя панель скрыта — помощник тоже прячем, чтобы не закрывать поле ввода */
  html.wc-chat-open .wch-fab,html.wc-chat-open .wch-teaser{display:none !important;}
  /* окно — на весь экран */
  .wch-panel{
    right:0;left:0;top:0;bottom:0;width:100%;height:100%;max-height:none;border-radius:0;border:none;
    transform-origin:bottom center;z-index:100002;
  }
  .wch-panel.open{animation:wchSheet .26s cubic-bezier(.2,.8,.2,1);}
  @keyframes wchSheet{from{opacity:.4;transform:translateY(40px);}to{opacity:1;transform:none;}}
  .wch-bubble{font-size:15px;}
  .wch-input{font-size:16px;} /* 16px — чтобы iOS не увеличивал страницу при фокусе */
  /* когда окно открыто, кнопку скрываем (закрывается крестиком в шапке) */
  .wch-fab.is-open{display:none;}
}
@media (max-width:360px){
  .wch-chip{font-size:12.5px;padding:6px 10px;}
}
@media print{.wch-fab,.wch-panel,.wch-teaser{display:none !important;}}
@media (prefers-reduced-motion:reduce){
  .wch-fab::after{animation:none;}
  .wch-panel.open,.wch-row,.wch-chips,.wch-teaser{animation:none;}
}

/* помощник показывается только на главной вкладке «Меню» */
.wch-away{display:none !important;}