/* ===== Чат-виджет (симуляция диалога с Игорем) =====
   Адаптация ChatWidget.tsx из rabbit под брендинг au (золото/тёмно-синий).
   Открывается по CustomEvent 'open-chat-widget' или клику на [data-open-chat-widget].
   Скрипт /js/chat-widget.js инжектит <aside id="chatWidget"> в body при загрузке. */

/* ===== Контейнер виджета ===== */
.chat-widget{
  position:fixed;
  bottom:24px;
  right:108px;                                 /* левее FAB (FAB right=24, ширина 68) */
  z-index:202;
  width:min(360px, calc(100vw - 32px));
  font-family:'Inter','Helvetica Neue',sans-serif;
  pointer-events:auto;
  /* Анимация появления */
  opacity:0;transform:translateY(16px) scale(.98);
  transition:opacity .25s ease, transform .3s cubic-bezier(.16,1,.3,1);
}
.chat-widget[hidden]{display:none}
.chat-widget.is-open{opacity:1;transform:none}

@media (max-width:880px){
  .chat-widget{
    bottom:84px;                               /* над mobile-cta-bar */
    right:14px;left:14px;width:auto;
  }
  body.has-cookie-banner .chat-widget{bottom:168px}
}

/* ===== Карточка ===== */
.chat-card{
  background:#fff;
  border:1px solid rgba(10,35,66,.10);
  border-radius:24px;
  overflow:hidden;
  box-shadow:0 18px 50px rgba(6,22,51,.22), 0 6px 18px rgba(6,22,51,.10);
}

/* ===== Header ===== */
.chat-header{
  display:flex;align-items:center;justify-content:space-between;
  gap:12px;padding:14px 18px;
  background:linear-gradient(135deg, var(--gold-500) 0%, var(--gold-400) 100%);
  color:var(--navy-900);
}
.chat-agent{display:flex;align-items:center;gap:12px;min-width:0}
.chat-avatar-wrap{position:relative;flex-shrink:0}
.chat-avatar{
  width:48px;height:48px;border-radius:50%;object-fit:cover;display:block;
  border:2px solid rgba(255,255,255,.85);
  box-shadow:0 2px 8px rgba(6,22,51,.18);
}
.chat-online-dot{
  position:absolute;right:0;bottom:0;
  width:12px;height:12px;border-radius:50%;
  background:#22C55E;border:2px solid #fff;
  box-shadow:0 0 0 0 rgba(34,197,94,.6);
  animation:chat-pulse 2s ease-in-out infinite;
}
@keyframes chat-pulse{
  0%,100%{box-shadow:0 0 0 0 rgba(34,197,94,.55)}
  50%{box-shadow:0 0 0 6px rgba(34,197,94,0)}
}
.chat-agent-info{min-width:0}
.chat-agent-name{
  font:600 15px/1.2 'Playfair Display','Inter',serif;
  color:var(--navy-900);
}
.chat-agent-role{
  font:500 11.5px/1.3 'Inter',sans-serif;
  color:rgba(6,22,51,.7);
  margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.chat-close{
  flex-shrink:0;display:grid;place-items:center;
  width:32px;height:32px;border-radius:50%;
  background:rgba(6,22,51,.10);border:1px solid rgba(6,22,51,.15);
  color:var(--navy-900);cursor:pointer;
  transition:background .15s ease, transform .15s ease;
}
.chat-close:hover{background:rgba(6,22,51,.18);transform:scale(1.05)}
.chat-close:focus-visible{outline:2px solid var(--navy-900);outline-offset:2px}
.chat-close svg{width:18px;height:18px}

/* ===== Тело ===== */
.chat-body{display:flex;flex-direction:column}
.chat-messages{
  max-height:420px;
  min-height:140px;
  overflow-y:auto;overflow-x:hidden;
  padding:16px;
  background:#F8F9FB;
  display:flex;flex-direction:column;gap:14px;
  scroll-behavior:smooth;
}
.chat-messages::-webkit-scrollbar{width:6px}
.chat-messages::-webkit-scrollbar-thumb{background:rgba(6,22,51,.15);border-radius:3px}

/* ===== Bubble ===== */
.chat-bubble{
  max-width:85%;
  padding:10px 14px;
  border-radius:16px;
  font-size:14px;line-height:1.45;
  word-wrap:break-word;
  animation:chat-bubble-in .25s ease;
}
@keyframes chat-bubble-in{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:none}
}
.chat-bubble p{margin:0}
.chat-bubble--agent{
  align-self:flex-start;
  background:#fff;
  color:var(--navy-900);
  border:1px solid rgba(10,35,66,.10);
  border-bottom-left-radius:6px;
  box-shadow:0 1px 2px rgba(6,22,51,.06);
}
.chat-bubble--user{
  align-self:flex-end;
  background:var(--navy-800);
  color:#fff;
  border-bottom-right-radius:6px;
  box-shadow:0 1px 2px rgba(6,22,51,.18);
}
.chat-time{
  display:block;
  margin-top:4px;
  font-size:11px;
  opacity:.55;
}
.chat-bubble--user .chat-time{color:rgba(255,255,255,.75)}

/* ===== Typing indicator ===== */
.chat-typing{
  align-self:flex-start;
  display:flex;align-items:center;gap:5px;
  padding:12px 14px;border-radius:16px;border-bottom-left-radius:6px;
  background:#fff;
  border:1px solid rgba(10,35,66,.10);
  box-shadow:0 1px 2px rgba(6,22,51,.06);
}
.chat-typing .dot{
  width:7px;height:7px;border-radius:50%;
  background:var(--gold-500);
  animation:chat-dot 1.2s ease-in-out infinite;
}
.chat-typing .dot:nth-child(2){animation-delay:.15s}
.chat-typing .dot:nth-child(3){animation-delay:.3s}
@keyframes chat-dot{
  0%,80%,100%{opacity:.3;transform:translateY(0) scale(.85)}
  40%{opacity:1;transform:translateY(-3px) scale(1)}
}

/* ===== Contact form (inline в messages) ===== */
.chat-card-inset{
  background:#fff;
  border:1px solid rgba(10,35,66,.10);
  border-radius:16px;
  padding:14px;
  box-shadow:0 1px 2px rgba(6,22,51,.06);
  animation:chat-bubble-in .25s ease;
}
.chat-card-inset > p{
  margin:0 0 12px;
  font-size:13.5px;line-height:1.5;
  color:var(--navy-900);
}
.chat-contact-form{display:flex;flex-direction:column;gap:10px}
.chat-field{display:block}
.chat-field-label{
  display:block;
  font-size:11.5px;font-weight:500;
  color:rgba(6,22,51,.6);
  margin-bottom:4px;
  letter-spacing:.02em;
  text-transform:uppercase;
}
.chat-field input{
  width:100%;
  padding:10px 12px;
  border:1px solid rgba(10,35,66,.18);
  border-radius:10px;
  font:500 14px/1.2 'Inter',sans-serif;
  color:var(--navy-900);
  background:#fff;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.chat-field input:focus{
  outline:none;
  border-color:var(--gold-500);
  box-shadow:0 0 0 3px rgba(201,169,110,.15);
}
.chat-field input:disabled{opacity:.6;cursor:not-allowed}
.chat-consent{
  display:flex;align-items:flex-start;gap:8px;
  font-size:11.5px;line-height:1.4;
  color:rgba(6,22,51,.65);
}
.chat-consent input[type="checkbox"]{margin-top:2px;flex-shrink:0}
.chat-consent a{color:var(--navy-800);text-decoration:underline}
.chat-submit{
  width:100%;
  padding:11px 14px;
  background:var(--navy-800);color:#fff;
  border:none;border-radius:10px;
  font:600 14px/1 'Inter',sans-serif;letter-spacing:.02em;
  cursor:pointer;
  box-shadow:0 6px 18px rgba(6,22,51,.22);
  transition:background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.chat-submit:hover{background:var(--navy-900)}
.chat-submit:active{transform:scale(.98)}
.chat-submit:disabled{background:rgba(6,22,51,.5);cursor:not-allowed;box-shadow:none}
.chat-error{
  font-size:12.5px;color:#C9382E;margin-top:4px;
}

/* ===== Success ===== */
.chat-success{
  display:flex;flex-direction:column;align-items:center;text-align:center;
  padding:24px 16px;
  background:#fff;
  border:1px solid rgba(10,35,66,.10);
  border-radius:16px;
  box-shadow:0 1px 2px rgba(6,22,51,.06);
  animation:chat-bubble-in .3s ease;
}
.chat-success-icon{
  width:64px;height:64px;border-radius:50%;
  background:rgba(34,197,94,.12);
  display:grid;place-items:center;
  margin-bottom:14px;
}
.chat-success-icon svg{width:36px;height:36px;color:#22C55E}
.chat-success p{
  margin:0;
  font-size:14px;line-height:1.5;
  color:var(--navy-900);
}
.chat-success-restart{
  margin-top:12px;
  background:none;border:none;cursor:pointer;
  color:var(--navy-800);text-decoration:underline;
  font:500 13px/1 'Inter',sans-serif;
}
.chat-success-restart:hover{color:var(--gold-500)}

/* ===== Input bar ===== */
.chat-input-form{
  padding:12px 14px;
  background:#fff;
  border-top:1px solid rgba(10,35,66,.10);
}
.chat-input-row{
  display:flex;align-items:center;gap:8px;
  background:#F0F2F5;
  border:1px solid rgba(10,35,66,.10);
  border-radius:24px;
  padding:4px 6px 4px 14px;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.chat-input-row:focus-within{
  border-color:var(--gold-500);
  box-shadow:0 0 0 3px rgba(201,169,110,.15);
}
.chat-input{
  flex:1;min-width:0;
  border:none;background:transparent;
  font:500 14px/1.2 'Inter',sans-serif;
  color:var(--navy-900);
  padding:9px 0;
}
.chat-input:focus{outline:none}
.chat-input::placeholder{color:rgba(6,22,51,.45)}
.chat-send{
  flex-shrink:0;display:grid;place-items:center;
  width:36px;height:36px;border-radius:50%;
  background:var(--gold-500);color:var(--navy-900);
  border:none;cursor:pointer;
  box-shadow:0 4px 12px rgba(201,169,110,.35);
  transition:transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.chat-send:hover{transform:scale(1.06);background:var(--gold-400)}
.chat-send:active{transform:scale(.96)}
.chat-send:focus-visible{outline:2px solid var(--navy-800);outline-offset:2px}
.chat-send svg{width:18px;height:18px}

/* ===== Honeypot ===== */
.chat-honeypot{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}

@media (prefers-reduced-motion:reduce){
  .chat-widget,.chat-bubble,.chat-card-inset,.chat-success{animation:none;transition:none}
  .chat-online-dot{animation:none}
  .chat-typing .dot{animation:none;opacity:.6}
}
