/* Webboll AI Chat — cephe widget'i */
#wbai-root {
  /* Bu degiskenler panelden gelen inline stille override edilir */
  --wbai-accent: #2563eb;
  --wbai-bg: #ffffff;
  --wbai-surface: #f1f5f9;
  --wbai-ink: #0f172a;
  --wbai-muted: #64748b;
  --wbai-line: #e2e8f0;
  --wbai-bot-bubble: #f1f5f9;
  --wbai-radius: 18px;
  --wbai-width: 380px;
  --wbai-height: 580px;
  --wbai-launcher: 60px;
  --wbai-shadow: 0 12px 40px -8px rgba(15, 23, 42, 0.28);
  position: fixed;
  /* konum (bottom/right vb.) panelden inline gelir; varsayilan alt-sag */
  bottom: 24px;
  right: 24px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--wbai-ink);
}

/* Launcher */
#wbai-launcher {
  width: var(--wbai-launcher); height: var(--wbai-launcher);
  border: none; border-radius: 50%;
  background: var(--wbai-accent);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--wbai-shadow);
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
}
#wbai-launcher:hover { transform: scale(1.06); }
#wbai-launcher:active { transform: scale(.96); }
#wbai-launcher:focus-visible { outline: 3px solid var(--wbai-accent); outline-offset: 3px; }
#wbai-root.open #wbai-launcher { transform: scale(.85); opacity: 0; pointer-events: none; }

/* Panel */
#wbai-panel {
  position: absolute;
  /* konum panelden inline gelir (bottom/top + right/left) */
  width: var(--wbai-width);
  max-width: calc(100vw - 32px);
  height: var(--wbai-height);
  max-height: calc(100vh - 48px);
  background: var(--wbai-bg);
  border-radius: var(--wbai-radius);
  box-shadow: var(--wbai-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: wbai-pop .26s cubic-bezier(.34,1.4,.64,1);
}
/* hidden attribute'u display:flex'i ezmeli - yoksa X paneli kapatmaz */
#wbai-panel[hidden] { display: none !important; }
#wbai-root [hidden] { display: none !important; }
/* Transform-origin'i launcher konumuna gore ayarla */
.wbai-pos-bottom-right #wbai-panel { transform-origin: bottom right; }
.wbai-pos-bottom-left  #wbai-panel { transform-origin: bottom left; }
.wbai-pos-top-right    #wbai-panel { transform-origin: top right; }
.wbai-pos-top-left     #wbai-panel { transform-origin: top left; }
@keyframes wbai-pop {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
#wbai-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: var(--wbai-accent);
  color: #fff;
}
.wbai-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; text-transform: uppercase;
}
.wbai-head-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.wbai-head-txt strong { font-size: 16px; }
#wbai-status { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; }
#wbai-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.3);
}
#wbai-close {
  background: none; border: none; color: #fff; font-size: 26px;
  cursor: pointer; line-height: 1; padding: 0 4px; opacity: .85;
}
#wbai-close:hover { opacity: 1; }

/* Messages */
#wbai-messages {
  flex: 1; overflow-y: auto;
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--wbai-bg);
  scroll-behavior: smooth;
}
.wbai-msg {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 16px;
  animation: wbai-fade .3s ease;
  word-wrap: break-word;
}
@keyframes wbai-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wbai-msg.bot {
  align-self: flex-start;
  background: var(--wbai-bot-bubble);
  color: var(--wbai-ink);
  border-bottom-left-radius: 5px;
}
.wbai-msg.user {
  align-self: flex-end;
  background: var(--wbai-accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.wbai-msg.system {
  align-self: center; text-align: center;
  background: transparent; color: var(--wbai-muted);
  font-size: 13px; max-width: 100%;
}

/* Typing indicator */
.wbai-typing { display: flex; gap: 4px; padding: 14px; align-self: flex-start; }
.wbai-typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--wbai-muted); opacity: .5;
  animation: wbai-bounce 1.2s infinite;
}
.wbai-typing span:nth-child(2) { animation-delay: .18s; }
.wbai-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes wbai-bounce { 0%,60%,100% { transform: translateY(0); opacity:.4; } 30% { transform: translateY(-5px); opacity:1; } }

/* Gate (SMS dogrulama) */
#wbai-gate {
  padding: 16px;
  border-top: 1px solid var(--wbai-line);
  background: var(--wbai-surface);
}
.wbai-gate-lead { font-size: 13px; color: var(--wbai-muted); margin: 0 0 10px; }
.wbai-gate-step { display: flex; gap: 8px; }
.wbai-gate-step input {
  flex: 1; padding: 11px 13px;
  border: 1px solid var(--wbai-line); border-radius: 12px;
  font-size: 15px; background: #fff; color: var(--wbai-ink);
}
.wbai-gate-step input:focus { outline: 2px solid var(--wbai-accent); outline-offset: -1px; border-color: transparent; }
.wbai-btn {
  padding: 11px 16px; border: none; border-radius: 12px;
  background: var(--wbai-accent); color: #fff; font-weight: 600;
  cursor: pointer; white-space: nowrap; font-size: 14px;
  transition: filter .15s;
}
.wbai-btn:hover { filter: brightness(1.08); }
.wbai-btn:disabled { opacity: .55; cursor: default; }
.wbai-gate-msg { font-size: 13px; margin: 10px 0 0; min-height: 18px; }
.wbai-gate-msg.err { color: #dc2626; }
.wbai-gate-msg.ok  { color: #16a34a; }

/* Composer */
#wbai-form {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--wbai-line);
  background: var(--wbai-bg);
}
#wbai-input {
  flex: 1; padding: 12px 15px;
  border: 1px solid var(--wbai-line); border-radius: 22px;
  font-size: 15px; background: var(--wbai-surface); color: var(--wbai-ink);
}
#wbai-input:focus { outline: 2px solid var(--wbai-accent); outline-offset: -1px; background: #fff; }
#wbai-input:disabled { opacity: .6; }
#wbai-send {
  width: 44px; height: 44px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--wbai-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .15s, filter .15s;
}
#wbai-send:hover:not(:disabled) { filter: brightness(1.08); }
#wbai-send:active:not(:disabled) { transform: scale(.92); }
#wbai-send:disabled { opacity: .45; cursor: default; }

#wbai-branding {
  text-align: center; font-size: 11px; color: var(--wbai-muted);
  padding: 6px 0 10px; background: var(--wbai-bg); letter-spacing: .2px;
}

/* Mobil: panel tam ekran, konumdan bagimsiz */
@media (max-width: 480px) {
  #wbai-panel {
    position: fixed;
    width: 100vw; height: 100dvh; max-height: 100dvh; max-width: 100vw;
    border-radius: 0;
    top: 0; left: 0; right: auto; bottom: auto;
  }
}

/* Erisilebilirlik: azaltilmis hareket */
@media (prefers-reduced-motion: reduce) {
  #wbai-panel, .wbai-msg, #wbai-launcher { animation: none; transition: none; }
  .wbai-typing span { animation: none; opacity: .6; }
}

/* Urun kartlari */
.wbai-cards {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 4px 0 8px;
  animation: wbai-fade .3s ease;
}
.wbai-card {
  border: 1px solid var(--wbai-line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.wbai-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px -6px rgba(15,23,42,.22);
}
.wbai-card-img {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--wbai-surface);
  overflow: hidden;
}
.wbai-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.wbai-card-badge {
  position: absolute; top: 8px; left: 8px;
  background: #dc2626; color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.wbai-card-body {
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
  flex: 1;
}
.wbai-card-name {
  font-size: 13px; font-weight: 600;
  color: var(--wbai-ink); text-decoration: none;
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.wbai-card-name:hover { color: var(--wbai-accent); }
.wbai-card-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: auto;
}
.wbai-card-price { font-size: 15px; font-weight: 700; color: var(--wbai-accent); }
.wbai-card-old {
  font-size: 12px; color: var(--wbai-muted);
  text-decoration: line-through;
}
.wbai-card-stock { font-size: 11px; padding: 2px 7px; border-radius: 20px; }
.wbai-card-stock.in  { background: #dcfce7; color: #16a34a; }
.wbai-card-stock.out { background: #fee2e2; color: #dc2626; }
.wbai-card-cart {
  margin-top: 4px;
  display: block; text-align: center;
  background: var(--wbai-accent); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 7px; border-radius: 10px;
  text-decoration: none;
  transition: filter .15s;
}
.wbai-card-cart:hover { filter: brightness(1.08); }

@media (max-width: 380px) {
  .wbai-cards { grid-template-columns: 1fr; }
}

/* Tiklanabilir secenek butonlari */
.wbai-choices {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 8px;
  animation: wbai-fade .3s ease;
}
.wbai-choice {
  border: 1.5px solid var(--wbai-accent);
  background: #fff;
  color: var(--wbai-accent);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.wbai-choice:hover {
  background: var(--wbai-accent);
  color: #fff;
}
.wbai-choice:active { transform: scale(.96); }

/* Launcher custom gorsel */
.wbai-launcher-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Karsilama balonu */
#wbai-bubble {
  position: absolute;
  bottom: calc(var(--wbai-launcher) + 14px);
  right: 0;
  max-width: 240px;
  background: #fff;
  color: var(--wbai-ink);
  padding: 12px 34px 12px 14px;
  border-radius: 16px;
  box-shadow: 0 8px 28px -6px rgba(15,23,42,.28);
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid var(--wbai-line);
}
/* Sol/ust konumlarda balon konumu */
.wbai-pos-bottom-left #wbai-bubble,
.wbai-pos-top-left #wbai-bubble { right: auto; left: 0; }
.wbai-pos-top-right #wbai-bubble,
.wbai-pos-top-left #wbai-bubble { bottom: auto; top: calc(var(--wbai-launcher) + 14px); }

#wbai-bubble.wbai-bubble-in {
  animation: wbai-bubble-pop .35s cubic-bezier(.34,1.4,.64,1);
}
@keyframes wbai-bubble-pop {
  from { opacity: 0; transform: translateY(10px) scale(.9); }
  to   { opacity: 1; transform: none; }
}
#wbai-bubble-text { cursor: pointer; }
#wbai-bubble-close {
  position: absolute; top: 6px; right: 8px;
  background: none; border: none;
  font-size: 18px; line-height: 1; cursor: pointer;
  color: var(--wbai-muted); padding: 2px;
}
#wbai-bubble-close:hover { color: var(--wbai-ink); }

/* Balonda kuyruk (ok) */
#wbai-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px; right: 20px;
  width: 14px; height: 14px;
  background: #fff;
  border-right: 1px solid var(--wbai-line);
  border-bottom: 1px solid var(--wbai-line);
  transform: rotate(45deg);
}
.wbai-pos-bottom-left #wbai-bubble::after { right: auto; left: 20px; }
.wbai-pos-top-right #wbai-bubble::after,
.wbai-pos-top-left #wbai-bubble::after {
  bottom: auto; top: -7px;
  border: none;
  border-left: 1px solid var(--wbai-line);
  border-top: 1px solid var(--wbai-line);
}
