/* Souqtopia's public AI assistant. Styles stay scoped to the widget. */
#seller-chat {
  --sq-gold: #dfb05c;
  --sq-gold-light: #f3d69d;
  --sq-muted: #c2bdca;
  font: 16px/1.6 -apple-system,BlinkMacSystemFont,'Segoe UI',Tahoma,Arial,sans-serif;
  color: #fff;
}
#seller-chat *, #seller-chat *::before, #seller-chat *::after { box-sizing: border-box; }
#seller-chat [hidden] { display: none !important; }
#seller-chat button, #seller-chat textarea { font: inherit; }
#seller-chat button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
#seller-chat button:disabled { opacity: .5; cursor: wait; }
#seller-chat :focus-visible:not(textarea) { outline: 2px solid var(--sq-gold-light); outline-offset: 3px; }
#seller-chat svg { display: block; flex-shrink: 0; }

.sq-chat-launch {
  position: fixed; inset-inline-end: 24px; bottom: max(24px,env(safe-area-inset-bottom)); z-index: 300;
  display: flex; align-items: center; gap: 12px; min-height: 60px; max-width: calc(100vw - 48px);
  padding: 8px 20px 8px 8px; padding-inline: 8px 20px;
  color: #fff; background: linear-gradient(135deg,#39313f,#211f2a);
  border: 1px solid #a48552; border-radius: 99px;
  box-shadow: 0 8px 32px #0006,0 0 0 4px #dfb05c0d;
  transition: border-color .18s,box-shadow .18s;
}
#seller-chat .sq-chat-launch { font-weight: 650; font-size: 15px; }
.sq-chat-launch > svg {
  width: 42px; height: 42px; padding: 9px; border-radius: 50%;
  color: #211f2a; background: linear-gradient(135deg,#f3d69d,#d4a34d);
  box-shadow: inset 0 1px 0 #fff6;
}
.sq-chat-launch:hover { border-color: var(--sq-gold-light); box-shadow: 0 10px 36px #0007,0 0 0 4px #dfb05c18; }

.sq-chat-panel {
  position: fixed; inset-inline-end: 20px; bottom: max(20px,env(safe-area-inset-bottom)); z-index: 301;
  width: min(460px,calc(100vw - 40px)); height: min(720px,calc(100dvh - 40px));
  display: flex; flex-direction: column; isolation: isolate;
  background: #211f2a; border: 1px solid #756144; border-radius: 24px; overflow: hidden;
  box-shadow: 0 24px 90px #0009,0 0 0 1px #fff04;
  animation: sq-chat-enter .18s ease-out;
}
.sq-chat-panel.is-expanded { width: min(680px,calc(100vw - 40px)); height: min(820px,calc(100dvh - 40px)); }
.sq-chat-head {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0; padding: 18px 16px;
  background: linear-gradient(110deg,#352d36,#282531 80%); border-bottom: 1px solid #dfb05c24;
}
.sq-chat-avatar {
  display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
  border: 1px solid #dfb05c55; border-radius: 15px; background: #dfb05c12;
  color: var(--sq-gold-light); box-shadow: 0 0 24px #dfb05c0d;
}
.sq-chat-avatar svg { width: 25px; height: 25px; }
.sq-chat-heading { flex: 1; min-width: 0; }
.sq-chat-heading strong { display: block; font-size: 16px; font-weight: 700; line-height: 1.5; }
.sq-chat-heading small { display: block; margin-top: 3px; color: var(--sq-gold); font-size: 12px; line-height: 1.5; }
.sq-chat-tools { display: flex; flex-wrap: nowrap; flex-shrink: 0; gap: 0; }
.sq-chat-icon {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--sq-muted);
  transition: background .15s,color .15s;
}
.sq-chat-icon svg { width: 20px; height: 20px; }
.sq-chat-icon:hover { background: #fff09; color: #fff; }
.sq-chat-icon[aria-pressed="true"] { color: var(--sq-gold-light); background: #dfb05c12; }

.sq-chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: 26px 20px; scrollbar-width: thin; scrollbar-color: #625562 transparent;
  background: radial-gradient(ellipse at 85% 0,#dfb05c09,transparent 60%);
}
.sq-chat-messages { display: flex; flex-direction: column; gap: 18px; }
.sq-chat-bubble {
  max-width: 90%; padding: 14px 16px; margin: 0; border-radius: 18px;
  font-size: 16px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; text-align: start;
}
.sq-chat-bubble:empty { display: none; }
.sq-chat-assistant { align-self: flex-start; background: #2e2a37; border: 1px solid #ffffff0d; border-start-start-radius: 5px; }
.sq-chat-user { align-self: flex-end; background: #e3bc79; color: #211f2a; border-end-end-radius: 5px; }
.sq-chat-bubble a { text-decoration: underline; text-underline-offset: 3px; color: inherit; }
.sq-chat-assistant a { color: var(--sq-gold-light); }
.sq-chat-bubble.sq-chat-welcome { max-width: 100%; padding: 0; border: 0; background: none; font-size: 19px; line-height: 1.85; color: #f4f0f6; }
.sq-chat-quick { display: grid; gap: 10px; margin-top: 24px; }
.sq-chat-quick button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px;
  padding: 12px 15px; text-align: start; border: 1px solid #605140; border-radius: 14px;
  background: linear-gradient(110deg,#dfb05c0b,#dfb05c02); color: #eee6da; transition: background .15s,border-color .15s;
}
#seller-chat .sq-chat-quick button { font-size: 15px; }
.sq-chat-quick button:hover { background: #dfb05c15; border-color: #ab8955; }
.sq-chat-quick svg { width: 18px; height: 18px; color: var(--sq-gold); }
#seller-chat[dir="rtl"] .sq-chat-quick svg { transform: scaleX(-1); }
.sq-chat-status { flex-shrink: 0; padding: 8px 20px; margin: 0; color: var(--sq-gold-light); font-size: 13px; line-height: 1.6; }
.sq-chat-status:empty { display: none; }
.sq-chat-status.is-busy::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-inline-end: 8px;
  border-radius: 50%; background: var(--sq-gold); vertical-align: middle; animation: sq-chat-thinking 1.2s ease-in-out infinite;
}
.sq-chat-form { flex-shrink: 0; padding: 14px 18px 0; margin: 0; }
.sq-chat-compose {
  display: flex; align-items: flex-end; gap: 6px; padding: 6px;
  border: 1px solid #6b5b69; border-radius: 18px; background: #2d2935; transition: border-color .15s,box-shadow .15s;
}
.sq-chat-compose:focus-within { border-color: var(--sq-gold); box-shadow: 0 0 0 3px #dfb05c12; }
#seller-chat textarea {
  flex: 1; min-width: 0; width: 100%; min-height: 48px; max-height: 120px; padding: 11px 10px;
  resize: none; overflow-y: auto; color: #fff; background: transparent; border: 0; border-radius: 10px;
  font-size: 16px; line-height: 26px; outline: none;
}
#seller-chat textarea::placeholder { color: #bfb7c7; opacity: 1; }
#seller-chat textarea:placeholder-shown { direction: inherit; text-align: start; }
.sq-chat-send {
  display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; margin-bottom: 2px;
  background: linear-gradient(145deg,#f0cd90,#dfb05c); color: #211f2a; border: 1px solid #f3d69d; border-radius: 13px;
}
.sq-chat-send svg { width: 23px; height: 23px; }
.sq-chat-send:hover { background: var(--sq-gold-light); }
.sq-chat-footer {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-shrink: 0; padding: 4px 20px 8px; margin: 0; border: 0;
}
.sq-chat-contact { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--sq-muted); font-size: 12px; text-decoration: none; }
.sq-chat-contact svg { width: 16px; height: 16px; color: var(--sq-gold); }
.sq-chat-contact:hover { color: var(--sq-gold-light); }
.sq-chat-privacy summary {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding-inline: 6px;
  color: var(--sq-muted); font-size: 12px; cursor: pointer; list-style: none; border-radius: 6px;
}
.sq-chat-privacy summary::-webkit-details-marker { display: none; }
.sq-chat-privacy summary:hover, .sq-chat-privacy[open] summary { color: var(--sq-gold-light); }
.sq-chat-notice {
  position: absolute; inset-inline: 18px; bottom: calc(100% + 4px); margin: 0; padding: 16px;
  max-height: min(180px,40dvh); overflow-y: auto; border: 1px solid #79644d; border-radius: 14px;
  color: #e1dbe8; background: #302a37; box-shadow: 0 8px 30px #0006; font-size: 13px; line-height: 1.8;
}
.sq-chat-notice a { color: var(--sq-gold-light); text-decoration: underline; }
.sq-chat-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@keyframes sq-chat-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sq-chat-thinking { 50% { opacity: .35; } }
@media (max-width: 600px), (hover: none) and (pointer: coarse) {
  .sq-chat-launch {
    /* Anchor the entire button above the visible edge, not the obscured page edge.
       translateY uses its actual height, including wrapped text or larger fonts. */
    top: calc(var(--sq-chat-viewport-bottom,100%) - 20px - env(safe-area-inset-bottom,0px));
    bottom: auto; transform: translateY(-100%);
  }
}
@media (max-width: 600px) {
  .sq-chat-launch { inset-inline-end: 14px; max-width: calc(100vw - 28px); min-height: 56px; padding-inline: 6px 17px; gap: 10px; }
  .sq-chat-launch > svg { width: 40px; height: 40px; }
  .sq-chat-panel, .sq-chat-panel.is-expanded {
    inset-inline-end: 8px; top: var(--sq-chat-top,8px); bottom: auto;
    width: calc(100vw - 16px); height: var(--sq-chat-height,calc(100dvh - 16px)); border-radius: 20px;
  }
  .sq-chat-head { padding: 14px 12px; gap: 6px; }
  .sq-chat-avatar { width: 36px; height: 36px; border-radius: 12px; }
  .sq-chat-avatar svg { width: 22px; height: 22px; }
  .sq-chat-heading strong { font-size: 15px; }
  .sq-chat-heading small { font-size: 11px; }
  .sq-chat-expand { display: none; }
  .sq-chat-scroll { padding: 22px 16px; }
  .sq-chat-bubble.sq-chat-welcome { font-size: 18px; }
  .sq-chat-form { padding: 12px 12px 0; }
  .sq-chat-footer { padding-inline: 14px; padding-bottom: max(4px,env(safe-area-inset-bottom)); gap: 6px; }
  .sq-chat-status { padding-inline: 16px; }
}
@media (max-height: 500px) {
  .sq-chat-head { padding-block: 6px; }
  .sq-chat-scroll { padding-block: 14px; }
  .sq-chat-form { padding-top: 6px; }
  .sq-chat-footer { padding-block: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #seller-chat *, #seller-chat *::before { animation: none !important; transition: none !important; }
}
