/* ============================================================
   NEXEL — AI sotuvchi-maslahatchi (chat oynasi)
   Sayt dizayn tizimidan foydalanadi (style.css dagi tokenlar)
   ============================================================ */

/* ---------- Ochish tugmasi ---------- */
.nxai-fab {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; z-index: 240;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--green-2) 0%, var(--green) 62%, #0a2c20 100%);
  box-shadow: 0 14px 34px -10px rgba(15, 40, 30, .55), 0 0 0 1px rgba(184, 145, 43, .35) inset;
  transition: transform .32s var(--ease), box-shadow .32s var(--ease);
}
.nxai-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 20px 44px -12px rgba(15, 40, 30, .6), 0 0 0 1px rgba(217, 180, 74, .6) inset; }
.nxai-fab:active { transform: translateY(0) scale(.97); }
.nxai-fab svg { width: 27px; height: 27px; fill: none; stroke: var(--gold-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nxai-fab__ring {
  position: absolute; inset: -4px; border-radius: 50%; pointer-events: none;
  border: 1.5px solid var(--gold); opacity: 0; animation: nxaiRing 3.4s var(--ease) infinite;
}
@keyframes nxaiRing {
  0%   { opacity: .55; transform: scale(1); }
  60%  { opacity: 0;   transform: scale(1.32); }
  100% { opacity: 0;   transform: scale(1.32); }
}
.nxai-fab__live {
  position: absolute; top: 3px; right: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: #3FCF8E; border: 2.5px solid var(--bg);
}
body.nxai-open .nxai-fab { transform: scale(.85); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .nxai-fab__ring { animation: none; } }

/* ---------- Birinchi tashrifda chiqadigan salom pufagi ---------- */
.nxai-tease {
  position: fixed; right: 22px; bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 239; max-width: 260px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px 18px 6px 18px;
  padding: 13px 34px 13px 15px; font-size: 13.5px; line-height: 1.5;
  box-shadow: var(--shadow-lg);
  animation: nxaiPop .5s var(--ease) both;
  cursor: pointer;
}
.nxai-tease b { color: var(--green); }
.nxai-tease__x {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  color: var(--muted); font-size: 17px; line-height: 1; display: grid; place-items: center;
}
.nxai-tease__x:hover { background: var(--bg-soft); color: var(--text); }
@keyframes nxaiPop { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }

/* ---------- Panel ---------- */
.nxai {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom));
  width: 390px; height: min(660px, calc(100vh - 120px));
  z-index: 260; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; box-shadow: 0 40px 90px -30px rgba(15, 40, 30, .45), var(--shadow);
  animation: nxaiIn .38s var(--ease) both;
}
@keyframes nxaiIn { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: none; } }
.nxai[hidden] { display: none; }

/* Sarlavha */
.nxai__top {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 15px 16px; color: #fff;
  background: linear-gradient(120deg, var(--green) 0%, var(--green-2) 74%, #12654a 100%);
}
.nxai__top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold-2), transparent);
}
.nxai__ava {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(217, 180, 74, .5);
}
.nxai__ava svg { width: 21px; height: 21px; fill: none; stroke: var(--gold-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nxai__id { flex: 1; min-width: 0; line-height: 1.25; }
.nxai__id b { display: block; font-family: var(--font-logo); font-size: 14px; letter-spacing: .04em; font-weight: 400; }
.nxai__id span { display: flex; align-items: center; gap: 6px; font-size: 11.5px; opacity: .78; }
.nxai__id i {
  width: 6px; height: 6px; border-radius: 50%; background: #4ADE80; display: inline-block;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); animation: nxaiLive 2.4s ease-out infinite;
}
@keyframes nxaiLive { 70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.nxai__ico {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  opacity: .75; transition: background .2s var(--ease), opacity .2s var(--ease); flex: none;
}
.nxai__ico:hover { background: rgba(255, 255, 255, .14); opacity: 1; }
.nxai__ico svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Xabarlar maydoni */
.nxai__body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 16px 6px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.nxai__body::-webkit-scrollbar { width: 8px; }
.nxai__body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 2px solid var(--surface-2); }

.nxai-msg { max-width: 90%; animation: nxaiMsg .3s var(--ease) both; }
@keyframes nxaiMsg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nxai-msg__b {
  padding: 11px 14px; font-size: 14px; line-height: 1.58; letter-spacing: -.004em;
  border-radius: 16px; word-break: break-word;
}
.nxai-msg--a { align-self: flex-start; }
.nxai-msg--a .nxai-msg__b {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px 16px 16px 5px;
  box-shadow: var(--shadow-sm);
}
.nxai-msg--u { align-self: flex-end; }
.nxai-msg--u .nxai-msg__b {
  background: var(--green); color: #fff; border-radius: 16px 16px 5px 16px;
}
.nxai-msg__b p + p { margin-top: 8px; }
.nxai-msg__b b, .nxai-msg__b strong { font-weight: 700; }
.nxai-msg--a .nxai-msg__b b { color: var(--green); }
.nxai-msg__b ul { margin: 7px 0 2px; display: flex; flex-direction: column; gap: 5px; }
.nxai-msg__b li { position: relative; padding-left: 15px; }
.nxai-msg__b li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.nxai-msg--u .nxai-msg__b li::before { background: var(--gold-2); }
.nxai-msg__b a { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
.nxai-msg--u .nxai-msg__b a { color: #fff; }

/* "yozmoqda" nuqtalari */
.nxai-typing { display: flex; gap: 4px; padding: 4px 2px; }
.nxai-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: nxaiDot 1.3s var(--ease) infinite;
}
.nxai-typing span:nth-child(2) { animation-delay: .16s; }
.nxai-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes nxaiDot { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Mahsulot kartochkasi (chat ichida) */
.nxai-card {
  display: flex; align-items: center; gap: 11px; margin: 9px 0 3px; padding: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
  animation: nxaiMsg .3s var(--ease) both;
}
.nxai-card:hover { border-color: var(--gold); transform: translateY(-1px); box-shadow: var(--shadow); }
.nxai-card__pic {
  width: 62px; height: 62px; flex: none; border-radius: 10px; overflow: hidden;
  background: var(--photo-bg); border: 1px solid var(--line-2); display: grid; place-items: center; cursor: pointer;
}
.nxai-card__pic img { width: 100%; height: 100%; object-fit: contain; }
.nxai-card__pic svg { width: 28px; height: 28px; fill: none; stroke: var(--muted); stroke-width: 1.4; }
.nxai-card__in { flex: 1; min-width: 0; cursor: pointer; }
.nxai-card__brand { display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.nxai-card__name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13px; font-weight: 600; line-height: 1.3; margin: 2px 0 4px; color: var(--text);
}
.nxai-card__price { font-size: 13.5px; font-weight: 800; color: var(--green); letter-spacing: -.02em; }
.nxai-card__old { font-size: 11px; color: var(--muted); text-decoration: line-through; margin-left: 6px; font-weight: 500; }
.nxai-card__add {
  flex: none; align-self: center; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(184, 145, 43, .3);
  transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.nxai-card__add:active { transform: scale(.92); }
.nxai-card__add:hover { background: var(--gold); color: #fff; }
.nxai-card__add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nxai-card__add.is-in { background: var(--green); color: #fff; border-color: var(--green); }

/* Tez javob tugmalari */
.nxai__chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 4px 16px 12px; background: var(--surface-2); }
.nxai__chips:empty { display: none; }
.nxai-chip {
  padding: 7px 13px; border-radius: var(--r-full); font-size: 12.5px; font-weight: 600; line-height: 1.2;
  background: var(--surface); color: var(--green); border: 1px solid var(--line);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.nxai-chip:hover { border-color: var(--gold); background: var(--gold-soft); transform: translateY(-1px); }

/* Yozish qatori */
.nxai__bar {
  display: flex; align-items: flex-end; gap: 9px; padding: 11px 12px;
  border-top: 1px solid var(--line); background: var(--surface);
}
.nxai__bar textarea {
  flex: 1; resize: none; max-height: 118px; padding: 11px 14px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 18px;
  font-size: 14px; line-height: 1.45; outline: none;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.nxai__bar textarea:focus { border-color: var(--green-2); background: var(--surface); }
.nxai__bar textarea::placeholder { color: var(--muted); }
.nxai__send {
  width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--green); color: #fff;
  transition: transform .2s var(--ease), background .2s var(--ease), opacity .2s var(--ease);
}
.nxai__send:hover:not(:disabled) { background: var(--green-2); transform: scale(1.06); }
.nxai__send:disabled { opacity: .38; cursor: default; }
.nxai__send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.nxai__foot {
  padding: 0 16px 11px; font-size: 11px; color: var(--muted); text-align: center; background: var(--surface);
}
.nxai__foot a { color: var(--green); font-weight: 600; }
.nxai__foot a:hover { color: var(--gold); }

/* ---------- Mobil: to'liq ekran ---------- */
@media (max-width: 640px) {
  .nxai {
    right: 0; left: 0; bottom: 0; top: 0; width: auto; height: 100%;
    border-radius: 0; border: 0;
  }
  .nxai__top { padding-top: calc(15px + env(safe-area-inset-top)); }
  .nxai__foot { padding-bottom: calc(11px + env(safe-area-inset-bottom)); }
  .nxai-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
  .nxai-tease { right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
  .nxai-msg { max-width: 92%; }
}
/* mahsulot sahifasida pastda "sotib olish" paneli bor — tugma uning ustida turadi */
@media (max-width: 860px) {
  body:has(.buybar) .nxai-fab { bottom: calc(88px + env(safe-area-inset-bottom)); }
  body:has(.buybar) .nxai-tease { bottom: calc(152px + env(safe-area-inset-bottom)); }
}
