/* Product Assistant — frontend widget */

.pa-widget {
  --pa-bg: #ffffff;
  --pa-surface: #f6f7f9;
  --pa-border: #e2e5eb;
  --pa-text: #1f2937;
  --pa-muted: #6b7280;
  --pa-primary: #2563eb;
  --pa-primary-hover: #1d4ed8;
  --pa-user: #dbeafe;
  --pa-bot: #f3f4f6;
  --pa-radius: 14px;
  --pa-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  color: var(--pa-text);
  box-sizing: border-box;
}

.pa-widget *,
.pa-widget *::before,
.pa-widget *::after {
  box-sizing: border-box;
}

.pa-widget--inline {
  max-width: 480px;
  margin: 1.5rem 0;
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius);
  background: var(--pa-bg);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  direction: rtl;
  text-align: right;
}

.pa-widget--floating {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  width: min(380px, calc(100vw - 24px));
  font-size: 14px;
  direction: rtl;
  text-align: right;
}

.pa-widget__launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  float: right;
  direction: rtl;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  background: var(--pa-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--pa-shadow);
  transition: background 0.15s ease, transform 0.15s ease;
}

.pa-widget__launcher:hover {
  background: var(--pa-primary-hover);
  transform: translateY(-1px);
}

.pa-widget__launcher-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.pa-widget__panel {
  clear: both;
  margin-top: 0.65rem;
  background: var(--pa-bg);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius);
  box-shadow: var(--pa-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(560px, calc(100vh - 100px));
}

.pa-widget__panel.is-hidden,
.pa-widget__panel[hidden] {
  display: none !important;
}

.pa-widget--inline .pa-widget__panel {
  margin-top: 0;
  border: none;
  box-shadow: none;
  max-height: none;
}

.pa-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
}

.pa-widget__title {
  font-size: 0.95rem;
}

.pa-widget__close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.9;
}

.pa-widget__close:hover {
  opacity: 1;
}

.pa-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  background: var(--pa-surface);
  min-height: 180px;
  max-height: 340px;
}

.pa-msg {
  margin-bottom: 0.75rem;
  max-width: 95%;
}

.pa-msg--user {
  margin-left: auto;
}

.pa-msg__bubble {
  display: inline-block;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.pa-msg--user .pa-msg__bubble {
  background: var(--pa-user);
  border-bottom-right-radius: 4px;
}

.pa-msg--bot .pa-msg__bubble {
  background: var(--pa-bot);
  border-bottom-left-radius: 4px;
}

.pa-msg--error .pa-msg__bubble {
  background: #fee2e2;
  color: #991b1b;
}

.pa-msg--loading .pa-msg__bubble {
  color: var(--pa-muted);
  font-style: italic;
}

.pa-recs {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.pa-rec {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.65rem;
  padding: 0.65rem;
  background: #fff;
  border: 1px solid var(--pa-border);
  border-radius: 10px;
}

.pa-rec__img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #e5e7eb;
}

.pa-rec__img--placeholder {
  display: block;
}

.pa-rec__body {
  min-width: 0;
}

.pa-rec__name {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.pa-rec__name a {
  color: var(--pa-text);
  text-decoration: none;
}

.pa-rec__name a:hover {
  color: var(--pa-primary);
  text-decoration: underline;
}

.pa-rec__price {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  color: var(--pa-primary);
  font-weight: 600;
}

.pa-rec__reason {
  margin: 0;
  font-size: 0.8rem;
  color: var(--pa-muted);
  line-height: 1.4;
}

.pa-widget__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--pa-border);
  background: #fff;
  align-items: end;
}

.pa-widget__input {
  width: 100%;
  resize: vertical;
  min-height: 44px;
  max-height: 120px;
  border: 1px solid var(--pa-border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--pa-text);
  background: #fff;
}

.pa-widget__input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--pa-primary);
}

.pa-widget__submit {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  background: var(--pa-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  height: 44px;
}

.pa-widget__submit:hover:not(:disabled) {
  background: var(--pa-primary-hover);
}

.pa-widget__submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

@media (max-width: 480px) {
  .pa-widget--floating {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .pa-widget__form {
    grid-template-columns: 1fr;
  }

  .pa-widget__submit {
    width: 100%;
  }
}
