/* ═══════════════════════════════════════════════════════════════════════
   SAYT YORDAMCHISI — suzuvchi tugma va chat oynasi
   Shablon: templates/assistant_widget.html · Mantiq: js/assistant.js
   Faqat uan.css tokenlari ishlatiladi — light / dark / glass o'z-o'zidan.
   ═══════════════════════════════════════════════════════════════════════ */

.asst{--asst-gap:20px;--asst-fab:56px}

/* ── Suzuvchi tugma ─────────────────────────────── */
.asst-fab{
  position:fixed;right:24px;bottom:calc(var(--tmt-h,30px) + var(--asst-gap));z-index:105;
  width:var(--asst-fab);height:var(--asst-fab);border-radius:50%;
  display:grid;place-items:center;border:0;cursor:pointer;
  background:var(--brand-solid);color:#fff;
  box-shadow:var(--sh-3),0 10px 26px -10px var(--btn-halo);
  -webkit-tap-highlight-color:transparent;
  transition:transform .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease), opacity .2s var(--ease);
}
.asst-fab:hover{background:var(--brand-solid-hover);transform:translateY(-2px);box-shadow:var(--sh-4),0 14px 30px -10px var(--btn-halo)}
.asst-fab:active{transform:scale(.94);transition-duration:.08s}
.asst-fab:focus-visible{outline:2px solid var(--focus);outline-offset:3px}
.asst-fab-ic{display:inline-flex;grid-area:1/1;transition:transform .22s var(--ease-out), opacity .18s var(--ease)}
.asst-ic-close{opacity:0;transform:rotate(-90deg) scale(.6)}
.asst-fab[aria-expanded="true"] .asst-ic-open{opacity:0;transform:rotate(90deg) scale(.6)}
.asst-fab[aria-expanded="true"] .asst-ic-close{opacity:1;transform:none}
/* Mobil menyu ochiq yoki klaviatura chiqqanda tugma xalal bermasin */
body:has(.mobile-drawer.open) .asst-fab,
html.kb-open .asst-fab{opacity:0;pointer-events:none}

/* ── Oyna ───────────────────────────────────────── */
.asst-panel{
  position:fixed;right:24px;z-index:105;
  bottom:calc(var(--tmt-h,30px) + var(--asst-gap) + var(--asst-fab) + 14px);
  width:392px;height:min(620px, calc(100vh - 190px));height:min(620px, calc(100dvh - 190px));
  display:flex;flex-direction:column;overflow:hidden;
  background:var(--surface);color:var(--ink);
  border:1px solid var(--line);border-radius:var(--r-lg);
  box-shadow:var(--sh-4);
  transform-origin:calc(100% - 28px) calc(100% + 40px);
  animation:asstIn .2s var(--ease-out);
}
.asst-panel[hidden]{display:none}
@keyframes asstIn{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}
[data-theme="glass"] .asst-panel{
  background:rgba(255,255,255,.86);
  backdrop-filter:blur(18px) saturate(1.4);-webkit-backdrop-filter:blur(18px) saturate(1.4);
  border-color:rgba(255,255,255,.6);
}

.asst-head{
  flex-shrink:0;display:flex;align-items:center;gap:10px;
  padding:12px 10px 12px 16px;border-bottom:1px solid var(--line);
}
/* Dumaloq ramka yo'q: avatar rasmining gapirish pufagi va quloqchinlari
   burchaklarga chiqib turadi — `border-radius:50%` + `overflow:hidden` ularni
   kesib, rasm buzilgandek ko'rinardi (foydalanuvchi fikri, 2026-09-21). */
.asst-avatar{
  width:52px;height:52px;flex-shrink:0;display:grid;place-items:center;
}
.asst-avatar img{width:52px;height:52px;display:block;object-fit:contain}
.asst-head-text{flex:1;min-width:0}
.asst-title{margin:0;font:700 15px/1.25 var(--font-display);letter-spacing:-.01em;color:var(--ink)}
.asst-sub{margin:2px 0 0;font-size:12px;line-height:1.35;color:var(--muted)}
.asst-icon-btn{
  width:40px;height:40px;flex-shrink:0;display:grid;place-items:center;border:0;border-radius:var(--r-sm);
  background:transparent;color:var(--muted);cursor:pointer;
  transition:background-color .16s var(--ease), color .16s var(--ease);
}
.asst-icon-btn:hover{background:var(--surface-2);color:var(--ink)}
.asst-icon-btn:focus-visible{outline:2px solid var(--focus);outline-offset:-2px}
.asst-icon-btn [data-icon]{display:inline-flex}

/* ── Xabarlar ───────────────────────────────────── */
.asst-log{
  flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  display:flex;flex-direction:column;gap:10px;
  padding:16px 14px 12px;background:var(--paper);
}
[data-theme="glass"] .asst-log{background:transparent}
.asst-msg{
  max-width:92%;display:flex;flex-direction:column;gap:9px;
  padding:11px 13px;border-radius:14px 14px 14px 4px;
  background:var(--surface);border:1px solid var(--line);
  font-size:14px;line-height:1.55;color:var(--body);
  animation:asstMsg .18s var(--ease-out);
}
.asst-msg.is-user{
  align-self:flex-end;max-width:85%;
  border-radius:14px 14px 4px 14px;border-color:transparent;
  background:var(--brand-solid);color:#fff;
}
.asst-msg.is-wide{width:92%}
@keyframes asstMsg{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.asst-text{margin:0;white-space:pre-line;overflow-wrap:anywhere}
.asst-msg:not(.is-user) .asst-text{color:var(--ink)}

.asst-typing{display:inline-flex;gap:4px;padding:4px 2px}
.asst-typing i{width:6px;height:6px;border-radius:50%;background:var(--muted);opacity:.4;animation:asstDot 1s infinite}
.asst-typing i:nth-child(2){animation-delay:.15s}
.asst-typing i:nth-child(3){animation-delay:.3s}
@keyframes asstDot{0%,60%,100%{opacity:.35;transform:none}30%{opacity:1;transform:translateY(-3px)}}

/* Vakansiya mini-kartalari — .vcard ning ixcham ko'rinishi */
.asst-cards{display:flex;flex-direction:column;gap:8px}
.asst-card{
  display:grid;grid-template-columns:36px minmax(0,1fr);gap:10px;align-items:center;
  padding:10px 12px;border-radius:var(--r-md);text-decoration:none;
  border:1px solid color-mix(in srgb,var(--tc,var(--brand)) 18%,var(--line));
  background:linear-gradient(135deg,var(--surface) 55%,color-mix(in srgb,var(--tc,var(--brand)) 8%,var(--surface)));
  color:var(--ink);transition:border-color .16s var(--ease), transform .16s var(--ease);
}
.asst-card:hover{border-color:color-mix(in srgb,var(--tc,var(--brand)) 45%,var(--line));transform:translateY(-1px)}
.asst-card:focus-visible{outline:2px solid var(--tc,var(--focus));outline-offset:2px}
.asst-card-ic{
  width:36px;height:36px;border-radius:50%;display:grid;place-items:center;color:var(--tc,var(--brand));
  background:color-mix(in srgb,var(--tc,var(--brand)) 11%,var(--surface));
}
.asst-card-ic [data-icon]{display:inline-flex}
.asst-card-body{min-width:0;display:flex;flex-direction:column;gap:3px}
.asst-card-title{
  font:600 14px/1.3 var(--font-display);color:var(--ink);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.asst-card:hover .asst-card-title{color:var(--tc,var(--brand))}
.asst-card-meta{font-size:12px;line-height:1.4;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.asst-code{font:700 11px/1 var(--font-display);letter-spacing:.03em;color:var(--tc,var(--brand));margin-right:6px}

.asst-links{display:flex;flex-wrap:wrap;gap:6px}
.asst-link{
  display:inline-flex;align-items:center;gap:6px;min-height:36px;
  padding:7px 12px;border-radius:var(--r-sm);text-decoration:none;
  border:1px solid var(--line-strong);background:var(--surface);
  font-size:13px;font-weight:600;line-height:1.2;color:var(--brand);
  transition:background-color .16s var(--ease), border-color .16s var(--ease);
}
.asst-link:hover{background:var(--brand-soft);border-color:var(--brand-line)}
.asst-link [data-icon]{display:inline-flex;transition:transform .18s var(--ease)}
.asst-link:hover [data-icon]{transform:translateX(2px)}

/* Bosqichlar — ro'yxat va holat natijasi uchun */
.asst-steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0;position:relative}
.asst-step{position:relative;display:flex;align-items:center;gap:10px;padding:5px 0;font-size:13.5px;color:var(--ink)}
.asst-step + .asst-step::before{
  content:"";position:absolute;left:11px;top:-7px;height:14px;width:2px;background:var(--line);
}
.asst-step-n{
  position:relative;z-index:1;flex-shrink:0;width:24px;height:24px;border-radius:50%;
  display:grid;place-items:center;font:500 11px/1 var(--font-mono);
  background:var(--surface);border:2px solid var(--line-strong);color:var(--muted);
}
.asst-step.is-done .asst-step-n{background:var(--brand-soft);border-color:var(--brand);color:var(--brand)}
.asst-step.is-done + .asst-step::before{background:var(--brand)}
.asst-step.is-current .asst-step-n{background:var(--brand-solid);border-color:var(--brand-solid);color:#fff}
.asst-step.is-current{font-weight:600}
.asst-steps.is-result .asst-step:not(.is-done):not(.is-current){color:var(--muted)}

/* Kontakt kartasi */
.asst-contact{list-style:none;padding:0;display:flex;flex-direction:column;margin:0;border:1px solid var(--line);border-radius:var(--r-md);overflow:hidden}
.asst-contact-row{display:grid;grid-template-columns:18px minmax(0,1fr);gap:10px;align-items:start;padding:9px 12px}
.asst-contact-row + .asst-contact-row{border-top:1px solid var(--line)}
.asst-contact-row [data-icon]{display:inline-flex;color:var(--brand);margin-top:2px}
.asst-contact-k{display:block;font-size:11.5px;color:var(--muted);line-height:1.3}
.asst-contact-v{display:block;margin:1px 0 0;font-size:13.5px;line-height:1.45;color:var(--ink);overflow-wrap:anywhere}
.asst-contact a{color:var(--brand);font-weight:600;text-decoration:none}
.asst-contact a:hover{text-decoration:underline}

/* Holat formasi */
.asst-status{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:var(--r-md);background:var(--surface-2);border:1px solid var(--line)}
.asst-status-title{margin:0;font:700 13.5px/1.3 var(--font-display);color:var(--ink)}
.asst-field{display:flex;flex-direction:column;gap:5px}
.asst-field label{font-size:12px;font-weight:600;color:var(--body)}
.asst-field-hint{font-size:11.5px;color:var(--muted)}
.asst-field input{
  width:100%;min-height:44px;padding:9px 12px;border-radius:var(--r-sm);
  border:1px solid var(--line-strong);background:var(--surface);color:var(--ink);
  font:16px/1.3 var(--font-body);font-variant-numeric:tabular-nums;
}
.asst-field input:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 18%,transparent)}
.asst-submit{
  min-height:44px;border:0;border-radius:var(--r-sm);cursor:pointer;
  background:var(--brand-solid);color:#fff;font:600 14px/1.2 var(--font-body);
  transition:background-color .16s var(--ease);
}
.asst-submit:hover{background:var(--brand-solid-hover)}
.asst-submit:disabled{opacity:.6;cursor:progress}
.asst-submit:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.asst-error{margin:0;padding:9px 11px;border-radius:var(--r-sm);background:var(--err-bg);border:1px solid var(--err-line);color:var(--err);font-size:13px;line-height:1.45}

.asst-result{display:flex;flex-direction:column;gap:10px}
.asst-result-top{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.asst-result-k{font-size:11.5px;color:var(--muted)}
.asst-result-num{font:500 15px/1.3 var(--font-mono);color:var(--ink);letter-spacing:.02em}
.asst-result-title{font:600 14px/1.35 var(--font-display);color:var(--brand);text-decoration:none}
.asst-result-title:hover{text-decoration:underline}
.asst-note{margin:0;padding:9px 11px;border-radius:var(--r-sm);font-size:13px;line-height:1.5;
  background:var(--brand-soft);border:1px solid var(--brand-line);color:var(--ink)}
.asst-note.ok{background:var(--ok-bg);border-color:var(--ok-line)}
.asst-note.muted{background:var(--surface);border-color:var(--line)}

/* ── Tezkor tugmalar ────────────────────────────── */
/* Tugmalar soni qancha bo'lmasin (javob topilmaganda 5 ta), har doim BITTA
   qatorda turadi va yonga suriladi — javoblar uchun joy o'zgarmaydi. */
.asst-chips{flex-shrink:0;display:flex;flex-wrap:nowrap;gap:6px;padding:10px 12px 4px;background:var(--paper);
  overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
.asst-chips::-webkit-scrollbar{height:4px}
.asst-chips::-webkit-scrollbar-thumb{background:var(--line-strong);border-radius:4px}
[data-theme="glass"] .asst-chips{background:transparent}
.asst-chips:empty{display:none}
.asst-chip{
  min-height:36px;padding:7px 12px;border-radius:999px;cursor:pointer;
  border:1px solid var(--brand-line);background:var(--brand-soft);color:var(--brand);
  flex-shrink:0;white-space:nowrap;
  font:600 13px/1.25 var(--font-body);text-align:left;
  transition:background-color .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.asst-chip:hover{background:var(--brand-solid);border-color:var(--brand-solid);color:#fff}
.asst-chip:focus-visible{outline:2px solid var(--focus);outline-offset:2px}

/* ── Kiritish ───────────────────────────────────── */
.asst-form{flex-shrink:0;display:flex;gap:8px;padding:10px 12px;background:var(--paper)}
[data-theme="glass"] .asst-form{background:transparent}
.asst-input{
  flex:1;min-width:0;min-height:46px;padding:10px 14px;border-radius:var(--r-sm);
  border:1px solid var(--line-strong);background:var(--surface);color:var(--ink);
  font:16px/1.3 var(--font-body);
}
.asst-input::placeholder{color:var(--muted);opacity:1}
.asst-input:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 18%,transparent)}
.asst-send{
  width:46px;height:46px;flex-shrink:0;display:grid;place-items:center;border:0;border-radius:var(--r-sm);
  background:var(--brand-solid);color:#fff;cursor:pointer;transition:background-color .16s var(--ease);
}
.asst-send:hover{background:var(--brand-solid-hover)}
.asst-send:disabled{opacity:.55;cursor:default}
.asst-send:focus-visible{outline:2px solid var(--focus);outline-offset:2px}
.asst-send [data-icon]{display:inline-flex}
.asst-foot{flex-shrink:0;margin:0;padding:0 14px 10px;background:var(--paper);font-size:11px;line-height:1.4;color:var(--muted);text-align:center}
[data-theme="glass"] .asst-foot{background:transparent}

/* ── Mobil: to'liq ekran ────────────────────────── */
@media(max-width:760px){
  .asst{--asst-fab:52px;--asst-gap:12px}
  .asst-fab{right:14px;bottom:calc(var(--bnav-h) + var(--tmt-h) + var(--safe-b) + var(--asst-gap))}
  .asst-panel{
    inset:0;width:auto;height:auto;z-index:170;
    border:0;border-radius:0;box-shadow:none;
    padding-top:env(safe-area-inset-top,0px);
    animation-name:asstUp;
  }
  @keyframes asstUp{from{opacity:0;transform:translateY(24px)}to{opacity:1;transform:none}}
  .asst-form{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px))}
  html.asst-open,html.asst-open body{overflow:hidden}
  /* Sensorli ekranda surish barmoq bilan — aylantirish chizig'i kerak emas */
  .asst-chips{scrollbar-width:none;padding-bottom:2px}
  .asst-chips::-webkit-scrollbar{display:none}
  .asst-foot{display:none}
}

@media(prefers-reduced-motion:reduce){
  .asst-fab,.asst-fab-ic,.asst-panel,.asst-msg,.asst-card,.asst-link [data-icon]{animation:none;transition:none}
  .asst-typing i{animation:none;opacity:.6}
}
@media print{.asst{display:none !important}}
