/* FabuRobotics Store Advisor chat widget. Palette and radii mirror styles.css. */

.sa-root * { box-sizing: border-box; }

.sa-root { position: fixed; bottom: 24px; right: 24px; z-index: 1500; font-family: 'Inter', sans-serif; color: #1e293b; line-height: 1.5; }

/* Keep the site's scroll-to-top button clear of the launcher. */
.scroll-to-top { bottom: 96px !important; }

/* Launcher */
.sa-launch { position: relative; width: 56px; height: 56px; border: none; border-radius: 50%; background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; cursor: pointer; box-shadow: 0 10px 25px #2563eb4c; display: flex; align-items: center; justify-content: center; transition: transform .2s, box-shadow .2s; }
.sa-launch:hover { transform: translateY(-2px); }
.sa-launch svg { width: 28px; height: 28px; }
.sa-launch-label { position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%); background: #1e293b; color: #fff; font-size: 0.875rem; font-weight: 500; padding: 0.5rem 0.875rem; border-radius: 50px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sa-launch:hover .sa-launch-label,
.sa-launch:focus-visible .sa-launch-label { opacity: 1; }

/* Panel */
.sa-panel { position: absolute; bottom: 72px; right: 0; width: 380px; max-width: calc(100vw - 32px); height: 70vh; max-height: 640px; display: flex; flex-direction: column; background: #fff; border-radius: 20px; box-shadow: 0 20px 60px #00000033; overflow: hidden; z-index: 1; transform-origin: bottom right; transition: opacity .2s, transform .2s; }
.sa-panel[hidden] { display: none; }
.sa-panel.sa-closing,
.sa-panel.sa-opening { opacity: 0; transform: translateY(12px) scale(0.96); }

.sa-head { display: flex; align-items: center; gap: 0.5rem; padding: 1rem 1rem 1rem 1.25rem; background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; }
.sa-head-text { flex: 1; min-width: 0; }
.sa-title { margin: 0; font-size: 1.05rem; font-weight: 600; }
.sa-subtitle { margin: 0; font-size: 0.8rem; opacity: 0.92; }
.sa-icon-btn { width: 36px; height: 36px; border: none; border-radius: 50%; background: #ffffff26; color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .2s; flex: none; }
.sa-icon-btn:hover { background: #ffffff4c; }
.sa-icon-btn svg { width: 18px; height: 18px; }

/* Messages */
.sa-log { flex: 1; overflow-y: auto; padding: 1rem; background: #f8fafc; display: flex; flex-direction: column; gap: 0.625rem; }
.sa-msg { max-width: 85%; padding: 0.625rem 0.875rem; border-radius: 16px; font-size: 0.925rem; word-wrap: break-word; overflow-wrap: anywhere; }
.sa-msg p { margin: 0 0 0.5rem; }
.sa-msg p:last-child, .sa-msg ul:last-child, .sa-msg ol:last-child { margin-bottom: 0; }
.sa-msg ul, .sa-msg ol { margin: 0 0 0.5rem; padding-left: 1.25rem; }
.sa-msg code { font-family: ui-monospace, Consolas, monospace; font-size: 0.85em; background: #2563eb14; color: #1d4ed8; padding: 0.05rem 0.3rem; border-radius: 4px; }
.sa-msg a { color: #1d4ed8; text-decoration: underline; }
.sa-user { align-self: flex-end; background: #2563eb; color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.sa-bot { align-self: flex-start; background: #fff; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.sa-sys { align-self: center; max-width: 100%; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-size: 0.85rem; text-align: center; }
.sa-typing { display: inline-flex; gap: 4px; align-items: center; padding: 0.875rem; }
.sa-typing i { width: 7px; height: 7px; border-radius: 50%; background: #64748b; animation: sa-bounce 1.2s infinite ease-in-out; }
.sa-typing i:nth-child(2) { animation-delay: 0.15s; }
.sa-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes sa-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* Suggestion chips */
.sa-chips { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.sa-chip { background: #fff; color: #2563eb; border: 2px solid #2563eb; border-radius: 50px; padding: 0.5rem 0.875rem; font: inherit; font-size: 0.85rem; font-weight: 500; text-align: left; cursor: pointer; transition: background .2s, color .2s; }
.sa-chip:hover { background: #2563eb; color: #fff; }

/* Composer */
.sa-form { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid #e2e8f0; background: #fff; position: relative; }
.sa-input { flex: 1; resize: none; min-height: 44px; max-height: 7.5rem; padding: 0.625rem 0.875rem; border: 2px solid #e2e8f0; border-radius: 8px; font: inherit; font-size: 0.925rem; line-height: 1.4; color: #1e293b; transition: border-color .3s; }
.sa-input::placeholder { color: #64748b; }
.sa-input:focus { outline: none; border-color: #2563eb; }
.sa-send { width: 44px; height: 44px; flex: none; border: none; border-radius: 50%; background: #2563eb; color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .2s, opacity .2s; }
.sa-send:hover { background: #1d4ed8; }
.sa-send:disabled, .sa-input:disabled { opacity: 0.55; cursor: not-allowed; }
.sa-send svg { width: 20px; height: 20px; }
.sa-count { position: absolute; top: -1.4rem; right: 0.875rem; font-size: 0.75rem; color: #64748b; background: #f8fafce6; padding: 0 0.25rem; border-radius: 4px; }
.sa-count.sa-max { color: #b91c1c; font-weight: 600; }

/* Inline mode (data-mount): fills its container, no launcher or close button. */
.sa-inline { position: static; height: 100%; }
.sa-inline .sa-launch, .sa-inline [data-act="close"] { display: none; }
.sa-inline .sa-panel { position: static; width: auto; max-width: none; height: 100%; max-height: none; border: 1px solid #e2e8f0; box-shadow: 0 5px 25px #00000014; }

/* Focus and utility */
.sa-root :focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.sa-head :focus-visible { outline-color: #fff; }
.sa-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Full-screen sheet on small screens */
@media (max-width: 639px) {
  .sa-root { bottom: 16px; right: 16px; }
  .sa-root:not(.sa-inline) .sa-panel {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    transform-origin: bottom center;
  }
  .sa-msg { max-width: 90%; }
  /* Buttons side by side; footer gets room for them. */
  .scroll-to-top { bottom: 16px !important; right: 88px !important; }
  .footer { padding-bottom: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  .sa-root *, .sa-root *::before, .sa-root *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
