.ai-ps-chat-widget {
  position: fixed;
  right: 22px;
  bottom: var(--ai-ps-chat-bottom-offset, 22px);
  z-index: 99999;
}

.ai-ps-chat-widget-inline {
  position: relative;
  right: auto;
  bottom: auto;
}

.ai-ps-chat-toggle {
  border: none;
  min-width: 120px;
  height: 56px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 62%, #1d4ed8 100%);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.34), inset 0 -1px 6px rgba(255, 255, 255, 0.24);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.ai-ps-chat-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 20px 40px rgba(37, 99, 235, 0.38), inset 0 -2px 10px rgba(255, 255, 255, 0.3);
  filter: saturate(1.08);
}

.ai-ps-chat-toggle-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 11px;
  font-weight: 800;
}

.ai-ps-chat-toggle-text {
  white-space: nowrap;
}

.ai-ps-chat-panel {
  width: min(420px, calc(100vw - 24px));
  height: min(580px, calc(100vh - var(--ai-ps-chat-bottom-offset, 22px) - 80px));
  height: min(580px, calc(100dvh - var(--ai-ps-chat-bottom-offset, 22px) - 80px));
  margin-top: 12px;
  border-radius: 24px;
  border: 1px solid #d6deea;
  background: #F7F9FB;
  box-shadow: 0 32px 64px rgba(15, 23, 42, 0.24);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  transition: width 0.22s ease, height 0.22s ease;
}

.ai-ps-chat-widget.ai-ps-chat-expanded .ai-ps-chat-panel {
  width: min(760px, calc(100vw - 44px));
  height: min(780px, calc(100vh - var(--ai-ps-chat-bottom-offset, 22px) - 60px));
  height: min(780px, calc(100dvh - var(--ai-ps-chat-bottom-offset, 22px) - 60px));
}

.ai-ps-chat-panel[hidden] {
  display: none !important;
}

.ai-ps-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid #e2e8f2;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(8px);
}

.ai-ps-chat-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ai-ps-chat-new,
.ai-ps-chat-resize {
  border: 1px solid #c7d3e3;
  background: #ffffff;
  border-radius: 999px;
  height: 30px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.ai-ps-chat-new:hover,
.ai-ps-chat-resize:hover {
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.ai-ps-chat-header-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-ps-chat-header-title-wrap strong {
  font-size: 14px;
  color: #0f172a;
}

.ai-ps-chat-widget .ai-ps-chat-brand-link {
  display: inline-flex !important;
  width: fit-content !important;
  color: inherit !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

.ai-ps-chat-widget .ai-ps-chat-brand-link:hover strong,
.ai-ps-chat-widget .ai-ps-chat-brand-link:focus-visible strong {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-ps-chat-header-subtitle {
  font-size: 11px;
  color: #64748b;
}

.ai-ps-chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c7d3e3;
  background: #ffffff;
  border-radius: 999px;
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  color: #334155;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.ai-ps-chat-close:hover {
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.ai-ps-chat-close:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.ai-ps-chat-close svg {
  width: 16px;
  height: 16px;
}

.ai-ps-chat-messages {
  overflow-y: auto;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ai-ps-chat-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.ai-ps-chat-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
}

.ai-ps-chat-msg-assistant {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

.ai-ps-chat-typing {
  align-self: flex-start;
  color: #64748b;
  font-size: 12px;
  padding: 4px 2px;
}

.ai-ps-chat-products {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 4px;
}

.ai-ps-chat-product {
  display: grid;
  grid-template-columns: 75px 1fr;
  gap: 10px;
  text-decoration: none;
  color: #111827;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px;
}

.ai-ps-chat-product-hidden {
  display: none;
}

.ai-ps-chat-product-image,
.ai-ps-chat-product-image img,
.ai-ps-chat-product-image-placeholder {
  width: 75px;
  height: 75px;
  border-radius: 8px;
  object-fit: cover;
}

.ai-ps-chat-product-image-placeholder {
  background: #e2e8f0;
}

.ai-ps-chat-product-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.ai-ps-chat-product-price {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.ai-ps-chat-sources {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
}

.ai-ps-chat-sources-label {
  flex: 0 0 auto;
  color: #6b7280;
  font-weight: 500;
}

.ai-ps-chat-sources > svg {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: #6b7280;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-ps-chat-source-links {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.ai-ps-chat-source-separator {
  flex: 0 0 auto;
  color: #9ca3af;
}

.ai-ps-chat-source {
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  color: #6b7280;
  background: transparent;
  border: 0;
  border-radius: 0;
  text-decoration: none;
  text-overflow: ellipsis;
}

.ai-ps-chat-source:hover {
  color: #4b5563;
  text-decoration: underline;
}

.ai-ps-chat-source:focus-visible {
  color: #4b5563;
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.ai-ps-chat-widget .ai-ps-chat-products-toggle {
  appearance: none !important;
  -webkit-appearance: none !important;
  justify-self: start;
  width: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 2px 0 0 !important;
  padding: 2px 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #64748b !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.3 !important;
  text-decoration: underline !important;
  text-underline-offset: 2px;
  cursor: pointer;
}

.ai-ps-chat-widget .ai-ps-chat-products-toggle::after {
  content: "\2193";
  margin-inline-start: 4px;
  font-size: 10px;
  line-height: 1;
  opacity: 0.7;
}

.ai-ps-chat-widget .ai-ps-chat-products-toggle:hover {
  color: #334155 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.ai-ps-chat-widget .ai-ps-chat-products-toggle:active {
  color: #0f172a !important;
  background: transparent !important;
  box-shadow: none !important;
}

.ai-ps-chat-widget .ai-ps-chat-products-toggle:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  box-shadow: none !important;
}

.ai-ps-chat-form {
  border-top: 1px solid #dde7f3;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.9);
}

.ai-ps-chat-input-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.ai-ps-chat-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #bfd0e4;
  border-radius: 999px;
  padding: 10px 14px;
  padding-inline-end: 52px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-ps-chat-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}

.ai-ps-chat-send {
  position: absolute;
  top: 50%;
  inset-inline-end: 5px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  flex: 0 0 36px;
  box-sizing: border-box;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.25);
  transition: box-shadow 0.18s ease, background 0.18s ease;
}

.ai-ps-chat-send:hover {
  transform: translateY(-50%);
  box-shadow: 0 7px 15px rgba(37, 99, 235, 0.32);
}

.ai-ps-chat-send:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.ai-ps-chat-send svg {
  width: 18px;
  height: 18px;
}

.ai-ps-chat-send-stop-icon {
  display: none;
}

.ai-ps-chat-send.ai-ps-chat-send-stop .ai-ps-chat-send-arrow {
  display: none;
}

.ai-ps-chat-send.ai-ps-chat-send-stop .ai-ps-chat-send-stop-icon {
  display: block;
}

.ai-ps-chat-send.ai-ps-chat-send-stop {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 8px 16px rgba(185, 28, 28, 0.25);
}

.ai-ps-chat-send.ai-ps-chat-send-stop:hover {
  box-shadow: 0 10px 18px rgba(185, 28, 28, 0.3);
}

@media (max-width: 640px) {
  .ai-ps-chat-widget {
    right: 8px;
    bottom: var(--ai-ps-chat-bottom-offset, 8px);
  }

  .ai-ps-chat-toggle {
    min-width: 108px;
    height: 52px;
    padding: 0 12px;
  }

  .ai-ps-chat-panel {
    width: min(100vw - 16px, 420px);
    height: min(74vh, 540px, calc(100dvh - var(--ai-ps-chat-bottom-offset, 8px) - 72px));
  }

  .ai-ps-chat-widget.ai-ps-chat-expanded .ai-ps-chat-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - var(--ai-ps-chat-bottom-offset, 8px) - 60px);
    height: calc(100dvh - var(--ai-ps-chat-bottom-offset, 8px) - 60px);
  }
}

/* Theme override shield: keep widget controls isolated from aggressive theme button/input styles. */
.ai-ps-chat-widget,
.ai-ps-chat-widget * {
  box-sizing: border-box;
}

.ai-ps-chat-widget {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.ai-ps-chat-widget * {
  font-family: inherit !important;
}

.ai-ps-chat-widget button,
.ai-ps-chat-widget input,
.ai-ps-chat-widget a {
  font-family: inherit !important;
  text-transform: none !important;
}
.ai-ps-chat-widget button {
  font-size: 16px !important;
}
.ai-ps-chat-widget .ai-ps-chat-toggle {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: none !important;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 62%, #1d4ed8 100%) !important;
  color: #fff !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  min-width: 105px !important;
  height: 36px !important;
  padding: 0 14px !important;
  line-height: 1 !important;
  font-size: 14px;
}

.ai-ps-chat-widget .ai-ps-chat-close {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 1px solid #c7d3e3 !important;
  background: #ffffff !important;
  color: #334155 !important;
  border-radius: 999px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  padding: 0 !important;
  overflow: hidden !important;
  line-height: 1 !important;
}

.ai-ps-chat-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid #e5e7eb;
  color: #64748b;
  font-size: 11px;
}

.ai-ps-chat-feedback-button {
  appearance: none !important;
  -webkit-appearance: none !important;
  display: inline !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 1px 2px !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: inherit !important;
  cursor: pointer !important;
  font: inherit !important;
  font-size: 15px !important;
  line-height: 1 !important;
  opacity: .62;
}

.ai-ps-chat-feedback-button:hover {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 1;
}

.ai-ps-chat-feedback-button:disabled {
  cursor: wait !important;
  opacity: .35;
}

.ai-ps-chat-feedback-button:focus,
.ai-ps-chat-feedback-button:focus-visible,
.ai-ps-chat-feedback-button:active {
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.ai-ps-chat-feedback-saved {
  color: #526174;
}

.ai-ps-chat-widget .ai-ps-chat-new,
.ai-ps-chat-widget .ai-ps-chat-resize {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 1px solid #c7d3e3 !important;
  background: #ffffff !important;
  color: #334155 !important;
  border-radius: 999px !important;
  width: auto !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 12px !important;
  line-height: 1 !important;
}

.ai-ps-chat-widget .ai-ps-chat-resize {
  min-width: 30px !important;
  padding: 0 !important;
  font-size: 16px !important;
}

.rtl .ai-ps-chat-widget .ai-ps-chat-resize {
  transform: rotateY(180deg);
}

.ai-ps-chat-widget .ai-ps-chat-input {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 1px solid #bfd0e4 !important;
  background: #fff !important;
  color: #0f172a !important;
  border-radius: 999px !important;
  width: 100% !important;
  min-height: 46px !important;
  padding: 10px 14px !important;
  padding-inline-end: 52px !important;
  box-shadow: none !important;
}

.ai-ps-chat-widget .ai-ps-chat-send {
  appearance: none !important;
  -webkit-appearance: none !important;
  position: absolute !important;
  top: 50% !important;
  inset-inline-end: 5px !important;
  transform: translateY(-50%) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: none !important;
  background: linear-gradient(135deg, #0284c7, #2563eb) !important;
  color: #fff !important;
  flex: 0 0 36px !important;
  box-sizing: border-box !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 999px !important;
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  overflow: hidden !important;
  line-height: 1 !important;
}

.ai-ps-chat-widget .ai-ps-chat-send::before,
.ai-ps-chat-widget .ai-ps-chat-send::after {
  content: none !important;
  display: none !important;
}

.ai-ps-chat-widget .ai-ps-chat-product {
  text-decoration: none !important;
  color: #111827 !important;
}

@media (max-width: 380px) {
  .ai-ps-chat-header {
    padding: 10px;
  }

  .ai-ps-chat-header-actions {
    gap: 4px;
  }

  .ai-ps-chat-header-subtitle {
    display: none;
  }

  .ai-ps-chat-widget .ai-ps-chat-new {
    padding: 0 8px !important;
  }
}
