/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --sepua-color: #2563eb;
  --sepua-color-dark: color-mix(in srgb, var(--sepua-color) 75%, black);
  --sepua-color-light: color-mix(in srgb, var(--sepua-color) 10%, white);
  --sepua-radius: 20px;
  --sepua-shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
  --sepua-z: 2147483647;
  --sepua-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ─── Toggle button ─────────────────────────────────────────────────────────── */
.sepua-toggle {
  position: fixed;
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--sepua-color);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--sepua-color) 50%, transparent), 0 2px 8px rgba(0,0,0,0.12);
  z-index: var(--sepua-z);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), background 0.2s ease, box-shadow 0.2s ease;
}

.sepua-toggle--right { right: 28px; }
.sepua-toggle--left  { left: 28px; }

.sepua-toggle:hover {
  background: var(--sepua-color-dark);
  transform: scale(1.1);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--sepua-color) 60%, transparent), 0 2px 8px rgba(0,0,0,0.15);
}

.sepua-toggle--open {
  background: #374151;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* ─── Chat window ───────────────────────────────────────────────────────────── */
.sepua-window {
  position: fixed;
  bottom: 104px;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: var(--sepua-radius);
  box-shadow: var(--sepua-shadow);
  border: 1px solid rgba(0, 0, 0, 0.06);
  z-index: var(--sepua-z);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--sepua-font);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(.34,1.56,.64,1);
}

.sepua-window--right { right: 28px; }
.sepua-window--left  { left: 28px; }

.sepua-window--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.sepua-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--sepua-color);
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.sepua-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

.sepua-header__info {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.sepua-header__avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.sepua-header__ai-badge {
  position: absolute;
  bottom: -3px;
  right: -4px;
  background: #fff;
  color: var(--sepua-color);
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 5px;
  letter-spacing: 0.06em;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.sepua-header__avatar {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255,255,255,0.25);
}

.sepua-header__avatar svg {
  animation: sepua-twinkle 3s ease-in-out infinite;
  transform-origin: center;
}

@keyframes sepua-twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.1); }
}

.sepua-header__name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.sepua-header__status {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: rgba(255,255,255,0.85);
  margin-top: 1px;
  letter-spacing: 0.01em;
}

.sepua-header__close {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.15);
  border: none;
  color: rgba(255,255,255,0.9);
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.sepua-header__close:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* ─── Messages area ─────────────────────────────────────────────────────────── */
.sepua-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #faf9f7;
}

.sepua-messages::-webkit-scrollbar { width: 3px; }
.sepua-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }
.sepua-messages::-webkit-scrollbar-track { background: transparent; }

/* ─── Message bubbles ───────────────────────────────────────────────────────── */
.sepua-msg {
  display: flex;
  max-width: 88%;
}

.sepua-msg--user {
  align-self: flex-end;
  justify-content: flex-end;
}

.sepua-msg--assistant {
  align-self: flex-start;
}

.sepua-msg__bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.sepua-msg--user .sepua-msg__bubble {
  background: var(--sepua-color);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.sepua-msg--assistant .sepua-msg__bubble {
  background: #fff;
  color: #1f2937;
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
}

/* ─── Typing indicator ──────────────────────────────────────────────────────── */
.sepua-typing .sepua-msg__bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.sepua-dot {
  width: 7px;
  height: 7px;
  background: #c4c9d4;
  border-radius: 50%;
  display: inline-block;
  animation: sepua-bounce 1.3s infinite ease-in-out;
}

.sepua-dot:nth-child(2) { animation-delay: 0.18s; }
.sepua-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes sepua-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 1; }
  40%           { transform: translateY(-7px); opacity: 0.7; }
}

/* ─── Input area ────────────────────────────────────────────────────────────── */
.sepua-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.sepua-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--sepua-font);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f9fafb;
  color: #1f2937;
}

.sepua-input:focus {
  border-color: var(--sepua-color);
  background: #fff;
  box-shadow: 0 0 0 3px var(--sepua-color-light);
}

.sepua-input::placeholder { color: #9ca3af; }

.sepua-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--sepua-color);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--sepua-color) 40%, transparent);
}

.sepua-send:hover {
  background: var(--sepua-color-dark);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--sepua-color) 50%, transparent);
}

.sepua-send:active { transform: scale(0.92); }
.sepua-send:disabled { background: #e5e7eb; box-shadow: none; cursor: not-allowed; }

/* ─── Product cards ─────────────────────────────────────────────────────────── */
.sepua-products {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: thin;
  scrollbar-color: #e5e7eb transparent;
  -ms-overflow-style: none;
  align-self: flex-start;
  max-width: 100%;
}

.sepua-products::-webkit-scrollbar { height: 3px; }
.sepua-products::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }
.sepua-products::-webkit-scrollbar-track { background: transparent; }

.sepua-product-card {
  flex-shrink: 0;
  width: 160px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sepua-product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.13), 0 0 0 1px rgba(0,0,0,0.04);
}

.sepua-product-card__img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #f3f4f6;
}

.sepua-product-card__body {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sepua-product-card__name {
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.sepua-product-card__price {
  font-size: 13px;
  font-weight: 800;
  color: var(--sepua-color);
  margin-top: 2px;
}

.sepua-product-card__nostock {
  font-size: 11px;
  color: #9ca3af;
  font-style: italic;
  margin-top: 2px;
}

.sepua-product-card__cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f3f4f6;
  font-size: 11px;
  font-weight: 600;
  color: var(--sepua-color);
  letter-spacing: 0.01em;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.sepua-toast {
  position: fixed;
  bottom: 108px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1f2937;
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 13px;
  font-family: var(--sepua-font);
  z-index: var(--sepua-z);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.sepua-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sepua-toast--error { background: #ef4444; }

/* ─── Promo card ────────────────────────────────────────────────────────────── */
.sepua-promo {
  position: fixed;
  bottom: 104px;
  width: 240px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.13), 0 0 0 1px rgba(0,0,0,0.05);
  padding: 14px 14px 14px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  z-index: var(--sepua-z);
  font-family: var(--sepua-font);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.34,1.56,.64,1);
}

.sepua-promo--right { right: 28px; }
.sepua-promo--left  { left: 28px; }

.sepua-promo--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.sepua-promo::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 24px;
  width: 14px;
  height: 8px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.sepua-promo--left::after {
  right: auto;
  left: 24px;
}

.sepua-promo__close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 17px;
  color: #9ca3af;
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.sepua-promo__close:hover {
  background: #f3f4f6;
  color: #374151;
}

.sepua-promo__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sepua-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sepua-promo__body {
  flex: 1;
  min-width: 0;
  padding-right: 14px;
}

.sepua-promo__name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 3px;
}

.sepua-promo__msg {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.45;
  margin: 0;
}

/* ─── Mobile adjustments ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sepua-window {
    width: calc(100vw - 12px);
    bottom: 92px;
  }
  .sepua-window--right,
  .sepua-window--left {
    left: 6px;
    right: 6px;
  }
  .sepua-toggle--right { right: 18px; }
  .sepua-toggle--left  { left: 18px; }
}
