/* Виджет чата asiaauto.kz ↔ ERP — стиль iMessage: светлый, воздух, скругления 16–20 px, мягкая тень. Токены сайта — aa/tokens.css (light/dark). Mobile-first. */
.aa-chat {
  --c-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Onest, Manrope, system-ui, sans-serif;
  --c-panel: #ffffff; --c-head: rgba(255,255,255,.86); --c-line: rgba(10,10,11,.09); --c-muted: #6e6e73; --c-field: #f2f2f4;
  --c-in-bg: #ececef; --c-in-fg: #0a0a0b; --c-out-bg: #1c1c1e; --c-out-fg: #ffffff; --c-ok: #30b158; --c-danger: #d70015;
  --c-shadow: 0 24px 64px rgba(10,10,11,.18), 0 2px 10px rgba(10,10,11,.08);
  --aa-chat-bottom: 72px; --aa-chat-right: 24px;
  position: fixed; right: var(--aa-chat-right); bottom: var(--aa-chat-bottom); z-index: 1040; font: 400 15px/21px var(--c-font); color: var(--c-in-fg); -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] .aa-chat { --c-panel: #151517; --c-head: rgba(21,21,23,.86); --c-line: rgba(245,245,247,.12); --c-muted: #9a9aa2; --c-field: #232326; --c-in-bg: #2a2a2d; --c-in-fg: #f5f5f7; --c-out-bg: #f5f5f7; --c-out-fg: #0a0a0b; --c-ok: #4cd37b; --c-danger: #ff6b6b; --c-shadow: 0 24px 64px rgba(0,0,0,.6), 0 2px 10px rgba(0,0,0,.4); }
.aa-chat[hidden] { display: none; }
.aa-chat *, .aa-chat *::before, .aa-chat *::after { box-sizing: border-box; }
.aa-chat button, .aa-chat input, .aa-chat select, .aa-chat textarea { font-family: var(--c-font); }
/* Кнопка «наверх» (#back-top, 40 px, right/bottom 16 px) — только на ПК: чат стоит над ней. На телефоне она скрыта, чат — над нижней панелью. */
@media (max-width: 768px) { .aa-chat { --aa-chat-bottom: calc(64px + 16px + env(safe-area-inset-bottom)); --aa-chat-right: 16px; } body.aa-page--cart .aa-chat, body.aa-page--checkout .aa-chat { --aa-chat-bottom: calc(64px + 88px + env(safe-area-inset-bottom)); } }

.aa-chat__fab { position: relative; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--c-out-bg); color: var(--c-out-fg); cursor: pointer; box-shadow: 0 10px 28px rgba(10,10,11,.22), 0 2px 6px rgba(10,10,11,.14); transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s; }
.aa-chat__fab:hover { transform: scale(1.06); }
.aa-chat__fab:active { transform: scale(.96); }
.aa-chat__fab:focus-visible, .aa-chat button:focus-visible, .aa-chat a:focus-visible { outline: 2px solid var(--c-in-fg); outline-offset: 2px; }
.aa-chat__badge { position: absolute; top: -3px; right: -3px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ff3b30; color: #fff; font: 700 12px/22px var(--c-font); text-align: center; box-shadow: 0 0 0 2px var(--c-panel); }
.aa-chat.is-open .aa-chat__fab { display: none; }

.aa-chat__panel { display: none; flex-direction: column; width: 384px; height: min(640px, calc(100vh - 120px)); background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 22px; box-shadow: var(--c-shadow); overflow: hidden; transform-origin: bottom right; }
.aa-chat.is-open .aa-chat__panel { display: flex; }
@media (max-width: 768px) {
  .aa-chat.is-open { inset: 0; right: 0; bottom: 0; }
  .aa-chat__panel { width: 100%; height: 100%; height: var(--aa-chat-h, 100dvh); border: 0; border-radius: 0; transform-origin: bottom center; }
}
@media (prefers-reduced-motion: no-preference) {
  .aa-chat.is-open .aa-chat__panel { animation: aa-chat-open .26s cubic-bezier(.2,.8,.2,1); }
  @keyframes aa-chat-open { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
  @media (max-width: 768px) { .aa-chat.is-open .aa-chat__panel { animation-name: aa-chat-sheet; } @keyframes aa-chat-sheet { from { opacity: 0; transform: translateY(32px); } to { opacity: 1; transform: none; } } }
  .aa-chat__msg, .aa-chat__form { animation: aa-chat-pop .22s cubic-bezier(.2,.8,.2,1) both; }
  @keyframes aa-chat-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

.aa-chat__head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--c-head); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--c-line); }
.aa-chat__ava { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--c-out-bg); color: var(--c-out-fg); display: flex; align-items: center; justify-content: center; font: 700 16px/1 var(--c-font); }
.aa-chat__title { flex: 1; min-width: 0; }
.aa-chat__title b { display: block; font: 600 16px/20px var(--c-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aa-chat__title span { display: flex; align-items: center; gap: 6px; font: 400 12.5px/16px var(--c-font); color: var(--c-muted); }
.aa-chat__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-ok); flex: none; }
.aa-chat__dot.is-off { background: #c7c7cc; }
.aa-chat__x { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--c-field); color: var(--c-muted); cursor: pointer; font: 400 20px/1 var(--c-font); }
.aa-chat__x:hover { background: var(--c-in-bg); color: var(--c-in-fg); }
.aa-chat__test { margin: 0; padding: 5px 16px; background: #fff4d6; color: #7a4b00; font: 600 12px/16px var(--c-font); text-align: center; }

.aa-chat__body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 8px; background: var(--c-panel); overscroll-behavior: contain; scroll-behavior: smooth; }
.aa-chat__msgs { display: flex; flex-direction: column; }
.aa-chat__msg { max-width: 78%; padding: 9px 14px; border-radius: 19px; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; margin-top: 2px; }
.aa-chat__msg.is-first { margin-top: 10px; }
.aa-chat__msg--out { align-self: flex-end; background: var(--c-out-bg); color: var(--c-out-fg); }
.aa-chat__msg--in { align-self: flex-start; background: var(--c-in-bg); color: var(--c-in-fg); }
.aa-chat__msg--out.is-last { border-bottom-right-radius: 6px; }
.aa-chat__msg--in.is-last { border-bottom-left-radius: 6px; }
.aa-chat__msg--system { align-self: center; max-width: 92%; margin-top: 12px; padding: 4px 10px; background: transparent; color: var(--c-muted); font: 400 12.5px/17px var(--c-font); text-align: center; }
.aa-chat__who { display: block; font: 600 12px/16px var(--c-font); color: var(--c-muted); margin: 8px 0 -2px 10px; }
.aa-chat__time { font: 400 11px/14px var(--c-font); color: var(--c-muted); margin: 3px 8px 0; }
.aa-chat__time--out { align-self: flex-end; }
.aa-chat__time--in { align-self: flex-start; }
.aa-chat__att { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px -6px -4px; }
.aa-chat__att a { display: block; }
.aa-chat__att img { width: 150px; max-width: 100%; height: 150px; object-fit: cover; border-radius: 14px; background: var(--c-field); display: block; }
.aa-chat__note { margin: 12px 8px 0; font: 400 12.5px/17px var(--c-font); color: var(--c-muted); text-align: center; }
.aa-chat__err { margin: 10px 8px 0; font: 600 13px/18px var(--c-font); color: var(--c-danger); text-align: center; }

.aa-chat__foot { background: var(--c-head); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--c-line); padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
.aa-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 8px; }
.aa-chat__chip { position: relative; width: 60px; height: 60px; border-radius: 12px; overflow: hidden; background: var(--c-field); }
.aa-chat__chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aa-chat__chip.is-load::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.6); }
.aa-chat__chip button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font: 700 13px/20px var(--c-font); cursor: pointer; }
.aa-chat__row { display: flex; align-items: flex-end; gap: 8px; }
.aa-chat__clip { flex: none; width: 36px; height: 36px; margin-bottom: 1px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--c-field); color: var(--c-muted); cursor: pointer; }
.aa-chat__clip:hover { color: var(--c-in-fg); }
.aa-chat__pill { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 4px; padding: 3px 3px 3px 14px; border: 1px solid var(--c-line); border-radius: 20px; background: var(--c-panel); }
.aa-chat__pill:focus-within { border-color: rgba(120,120,128,.5); }
.aa-chat__ta { flex: 1; min-width: 0; min-height: 30px; max-height: 120px; resize: none; padding: 5px 0; border: 0; outline: none; background: transparent; color: var(--c-in-fg); font: 400 16px/20px var(--c-font); }
.aa-chat__ta::placeholder { color: var(--c-muted); }
.aa-chat__send { flex: none; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 50%; background: var(--c-out-bg); color: var(--c-out-fg); cursor: pointer; transition: opacity .15s, transform .15s; }
.aa-chat__send:disabled { opacity: .28; cursor: default; }
.aa-chat__send:not(:disabled):active { transform: scale(.92); }
.aa-chat__more { display: flex; justify-content: center; gap: 16px; margin-top: 6px; }
.aa-chat__link { border: 0; background: none; padding: 6px 4px; color: var(--c-muted); font: 400 12.5px/16px var(--c-font); cursor: pointer; }
.aa-chat__link:hover { color: var(--c-in-fg); text-decoration: underline; }

.aa-chat__form { display: flex; flex-direction: column; gap: 10px; padding: 4px 4px 16px; }
.aa-chat__hello { margin: 4px 4px 2px; font: 600 20px/26px var(--c-font); letter-spacing: -.01em; }
.aa-chat__lead { margin: 0 4px 4px; color: var(--c-muted); font: 400 14px/19px var(--c-font); }
.aa-chat__form label { display: flex; flex-direction: column; gap: 4px; font: 500 12.5px/16px var(--c-font); color: var(--c-muted); }
.aa-chat__form input[type=text], .aa-chat__form input[type=tel], .aa-chat__form select, .aa-chat__form textarea { width: 100%; min-height: 46px; padding: 11px 14px; border: 1.5px solid transparent; border-radius: 14px; background: var(--c-field); color: var(--c-in-fg); font: 400 16px/22px var(--c-font); -webkit-appearance: none; appearance: none; }
.aa-chat__form select { background-image: linear-gradient(45deg, transparent 50%, var(--c-muted) 50%), linear-gradient(135deg, var(--c-muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.aa-chat__form textarea { min-height: 84px; resize: vertical; }
.aa-chat__form input:focus, .aa-chat__form select:focus, .aa-chat__form textarea:focus { outline: none; border-color: var(--c-in-fg); background: var(--c-panel); }
.aa-chat__form [aria-invalid=true] { border-color: var(--c-danger); }
.aa-chat__fe { font: 500 12.5px/16px var(--c-font); color: var(--c-danger); }
.aa-chat__form .aa-chat__consent { flex-direction: row; align-items: flex-start; gap: 10px; margin-top: 2px; color: var(--c-muted); font: 400 12.5px/17px var(--c-font); }
.aa-chat__consent input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--c-out-bg); }
.aa-chat__consent a { color: var(--c-in-fg); text-decoration: underline; }
.aa-chat__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.aa-chat__offline { margin: 0; padding: 9px 12px; border-radius: 12px; background: #fff4d6; color: #7a4b00; font: 500 13px/18px var(--c-font); }
.aa-chat__go { min-height: 50px; margin-top: 4px; border: 0; border-radius: 16px; background: var(--c-out-bg); color: var(--c-out-fg); font: 600 16px/22px var(--c-font); cursor: pointer; transition: transform .15s, opacity .15s; }
.aa-chat__go:active { transform: scale(.98); }
.aa-chat__go:disabled { opacity: .5; }
