/**
 * AI Sales Agent - Chat Widget Styles (Redesigned)
 *
 * CSS custom properties --aisales-primary, --aisales-primary-dark,
 * and --aisales-primary-glow are set via inline style on .aisales-chat-widget
 * from the admin-configured primary color.
 */

/* ─── Widget Container ─── */
.aisales-chat-widget {
  /* Fixed palette */
  --aisales-bg-chat: #F6F3EE;
  --aisales-bg-widget: #FFFFFF;
  --aisales-text-primary: #1A1A1A;
  --aisales-text-secondary: #6B6B6B;
  --aisales-text-light: #9A9A9A;
  --aisales-border: #E8E4DE;
  --aisales-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --aisales-font-display: 'Playfair Display', Georgia, serif;
  --aisales-shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --aisales-shadow-md: 0 8px 30px rgba(0,0,0,0.10);
  --aisales-shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
  --aisales-shadow-widget: 0 12px 48px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04);

  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: var(--aisales-font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--aisales-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Left position variant */
.aisales-chat-widget.position-left {
  right: auto;
  left: 20px;
}

/* ─── Theme Isolation: neutralise host-page button/link styles ─── */
.aisales-chat-widget button,
.aisales-chat-widget button:hover,
.aisales-chat-widget button:focus,
.aisales-chat-widget button:active {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font-family: var(--aisales-font-body);
  font-size: inherit;
  font-weight: inherit;
  font-style: normal;
  text-transform: none;
  text-decoration: none;
  text-shadow: none;
  letter-spacing: normal;
  line-height: inherit;
  box-shadow: none;
  min-height: 0;
  min-width: 0;
  vertical-align: baseline;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.aisales-chat-widget a {
  color: var(--aisales-primary);
  text-decoration: none;
}

.aisales-chat-widget a:hover {
  text-decoration: underline;
}

/* ─── Chat Toggle Button ─── */
.aisales-chat-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--aisales-primary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
}

.aisales-chat-button:hover {
  transform: scale(1.08);
  background-color: var(--aisales-primary-dark);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.aisales-chat-button svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.aisales-chat-button.active {
  transform: scale(0);
  opacity: 0;
}

/* ─── Chat Window ─── */
.aisales-chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 400px;
  height: 640px;
  background: var(--aisales-bg-widget);
  border-radius: 24px;
  box-shadow: var(--aisales-shadow-widget);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.aisales-chat-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Left position */
.aisales-chat-widget.position-left .aisales-chat-window {
  right: auto;
  left: 20px;
}

/* ─── Header ─── */
.aisales-chat-header {
  background: linear-gradient(135deg, var(--aisales-primary) 0%, var(--aisales-primary-dark) 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.aisales-chat-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.aisales-chat-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.2);
  overflow: hidden;
}

.aisales-chat-header-avatar svg {
  width: 22px;
  height: 22px;
  color: white;
}

.aisales-chat-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.aisales-chat-header-info {
  flex: 1;
  min-width: 0;
}

.aisales-chat-header-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: white;
  letter-spacing: -0.01em;
  margin: 0;
}

.aisales-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.aisales-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
  animation: aisales-pulse-dot 2s ease-in-out infinite;
}

@keyframes aisales-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.aisales-status-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
  font-weight: 400;
}

.aisales-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.aisales-chat-widget .aisales-header-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  padding: 0;
}

.aisales-chat-widget .aisales-header-btn:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

.aisales-chat-widget .aisales-header-btn svg {
  width: 18px;
  height: 18px;
}

.aisales-chat-widget .aisales-header-btn.new-chat-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.15);
}

.aisales-chat-widget .aisales-header-btn.new-chat-btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.3);
}

/* Header button tooltips */
.aisales-chat-widget .aisales-header-btn .aisales-tooltip {
  position: absolute;
  bottom: -36px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--aisales-text-primary);
  color: white;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.aisales-chat-widget .aisales-header-btn .aisales-tooltip::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--aisales-text-primary);
}

.aisales-chat-widget .aisales-header-btn:hover .aisales-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Chat Messages / Body ─── */
.aisales-chat-messages {
  flex: 1;
  background: var(--aisales-bg-chat);
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  scroll-behavior: smooth;
}

.aisales-chat-messages::-webkit-scrollbar { width: 4px; }
.aisales-chat-messages::-webkit-scrollbar-track { background: transparent; }
.aisales-chat-messages::-webkit-scrollbar-thumb { background: var(--aisales-border); border-radius: 4px; }

/* Dot pattern overlay */
.aisales-chat-messages::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 2px 2px, rgba(0,0,0,0.02) 1px, transparent 0);
  background-size: 24px 24px;
  pointer-events: none;
}

/* ─── Messages ─── */
.aisales-message {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: aisales-msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  margin-bottom: 0;
  position: relative;
  clear: both;
}

@keyframes aisales-msg-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.aisales-message-user {
  flex-direction: row-reverse;
}

.aisales-message-bot {
  flex-direction: row;
  align-items: flex-start;
}

/* Bot message avatar */
.aisales-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--aisales-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.aisales-msg-avatar svg {
  width: 15px;
  height: 15px;
  color: white;
}

.aisales-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Message content wrapper — fill available space so bubbles align consistently */
.aisales-message > div:not(.aisales-msg-avatar) {
  min-width: 0;
  max-width: 78%;
}

/* Message content bubble */
.aisales-message-content {
  padding: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--aisales-text-primary);
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 80px;
}

.aisales-message-bot .aisales-message-content {
  background: var(--aisales-bg-widget);
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--aisales-shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
}

.aisales-message-user .aisales-message-content {
  background: var(--aisales-primary);
  color: white;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 12px var(--aisales-primary-glow);
}

/* Timestamp */
.aisales-msg-time {
  font-size: 0.68rem;
  color: var(--aisales-text-light);
  margin-top: 4px;
  padding: 0 4px;
}

.aisales-message-user .aisales-msg-time {
  text-align: right;
  margin-right: 12px;
}

/* ─── Markdown in bot messages ─── */
.aisales-message-bot .aisales-message-content p {
  margin: 0 0 8px 0;
}

.aisales-message-bot .aisales-message-content p:last-child {
  margin-bottom: 0;
}

.aisales-message-bot .aisales-message-content ul {
  margin: 4px 0 8px 0;
  padding-left: 20px;
  list-style-type: disc;
}

.aisales-message-bot .aisales-message-content ul:last-child {
  margin-bottom: 0;
}

.aisales-message-bot .aisales-message-content li {
  margin-bottom: 4px;
}

.aisales-message-bot .aisales-message-content a {
  color: var(--aisales-primary);
  text-decoration: none;
  word-break: break-all;
}

.aisales-message-bot .aisales-message-content a:hover {
  text-decoration: underline;
}

.aisales-message-user .aisales-message-content a {
  color: white;
  text-decoration: underline;
}

/* ─── Welcome Section & Quick Actions ─── */
.aisales-welcome-section {
  text-align: center;
  padding: 10px 0 6px;
  animation: aisales-msg-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.aisales-welcome-text {
  font-size: 0.82rem;
  color: var(--aisales-text-light);
}

.aisales-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  animation: aisales-msg-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.35s both;
}

.aisales-chat-widget .aisales-quick-action {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  background: white;
  border: 1.5px solid var(--aisales-border);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--aisales-text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--aisales-font-body);
}

.aisales-chat-widget .aisales-quick-action:hover {
  border-color: var(--aisales-primary);
  background: var(--aisales-primary-glow);
  color: var(--aisales-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--aisales-primary-glow);
}

.aisales-qa-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ─── Typing Indicator ─── */
.aisales-typing-indicator {
  display: none;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 0;
}

.aisales-typing-indicator.active {
  display: flex;
}

.aisales-typing-indicator .aisales-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--aisales-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.aisales-typing-indicator .aisales-message-content {
  background: var(--aisales-bg-widget);
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--aisales-shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: none;
}

.aisales-typing-status {
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--aisales-text-secondary);
  min-height: 14px;
}

.aisales-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.aisales-typing-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aisales-text-light);
  animation: aisales-typing-bounce 1.4s infinite;
}

.aisales-typing-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.aisales-typing-dots .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes aisales-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ─── Input Area ─── */
.aisales-chat-input {
  padding: 14px 16px 8px;
  background: var(--aisales-bg-widget);
  border-top: 1px solid var(--aisales-border);
  flex-shrink: 0;
}

.aisales-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--aisales-bg-chat);
  border: 1.5px solid var(--aisales-border);
  border-radius: 14px;
  padding: 4px 4px 4px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.aisales-input-wrapper:focus-within {
  border-color: var(--aisales-primary);
  box-shadow: 0 0 0 3px var(--aisales-primary-glow);
  background: white;
}

.aisales-chat-widget textarea.aisales-chat-input-box {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.88rem;
  font-family: var(--aisales-font-body);
  color: var(--aisales-text-primary);
  padding: 8px 0;
  min-height: 20px;
  max-height: 100px;
  height: auto;
  width: auto;
  overflow-y: auto;
  line-height: 1.4;
  resize: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  transition: none;
  box-shadow: none;
  border-radius: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.aisales-chat-widget textarea.aisales-chat-input-box::placeholder {
  color: var(--aisales-text-light);
}

/* Send button */
.aisales-chat-widget .aisales-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--aisales-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 2px 8px var(--aisales-primary-glow);
  padding: 0;
}

.aisales-chat-widget .aisales-chat-send:hover {
  background: var(--aisales-primary-dark);
  transform: scale(1.05);
}

.aisales-chat-widget .aisales-chat-send svg {
  width: 18px;
  height: 18px;
}

.aisales-chat-widget .aisales-chat-send.disabled {
  background-color: var(--aisales-border);
  cursor: not-allowed;
  box-shadow: none;
}

.aisales-chat-widget .aisales-chat-send.disabled:hover {
  transform: none;
  background-color: var(--aisales-border);
}

/* ─── Widget Footer ─── */
.aisales-widget-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 2px 6px;
}

.aisales-powered-by {
  font-size: 0.68rem;
  color: var(--aisales-text-light);
  letter-spacing: 0.02em;
}

/* ─── Feedback Button (eye-catching pill) ─── */
.aisales-chat-widget button.aisales-feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--aisales-primary) 0%, var(--aisales-primary-dark) 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--aisales-font-body);
  letter-spacing: 0.01em;
  cursor: pointer;
  border: none;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  box-shadow: 0 2px 10px var(--aisales-primary-glow);
  animation: aisales-feedback-glow 3s ease-in-out infinite;
  flex-shrink: 0;
}

.aisales-chat-widget button.aisales-feedback-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 4px 18px var(--aisales-primary-glow);
  background: linear-gradient(135deg, var(--aisales-primary-dark) 0%, var(--aisales-primary) 100%);
  color: #fff;
}

.aisales-chat-widget button.aisales-feedback-btn:active {
  transform: scale(0.97);
}

.aisales-chat-widget button.aisales-feedback-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
  flex-shrink: 0;
}

@keyframes aisales-feedback-glow {
  0%, 100% { box-shadow: 0 2px 10px var(--aisales-primary-glow); }
  50% { box-shadow: 0 2px 20px var(--aisales-primary-glow), 0 0 30px var(--aisales-primary-glow); }
}

@media (prefers-reduced-motion: reduce) {
  .aisales-chat-widget button.aisales-feedback-btn { animation: none; }
}

/* ─── Feedback Overlay ─── */
.aisales-feedback-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.aisales-feedback-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.aisales-feedback-modal {
  background: var(--aisales-bg-widget);
  border-radius: 20px;
  padding: 28px 24px 24px;
  width: 320px;
  max-width: calc(100% - 32px);
  box-shadow: var(--aisales-shadow-lg);
  transform: translateY(24px) scale(0.92);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  position: relative;
}

.aisales-feedback-overlay.active .aisales-feedback-modal {
  transform: translateY(0) scale(1);
}

.aisales-chat-widget button.aisales-feedback-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--aisales-bg-chat);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
  z-index: 2;
  padding: 0;
}

.aisales-chat-widget button.aisales-feedback-close:hover {
  background: var(--aisales-border);
}

.aisales-chat-widget button.aisales-feedback-close svg {
  width: 14px;
  height: 14px;
  color: var(--aisales-text-secondary);
}

/* ─── Feedback: Choice View ─── */
.aisales-feedback-choice {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.aisales-feedback-choice.hidden { display: none; }

.aisales-feedback-heading {
  font-family: var(--aisales-font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--aisales-text-primary);
  margin-bottom: 2px;
  line-height: 1.3;
}

.aisales-feedback-subtext {
  font-size: 0.82rem;
  color: var(--aisales-text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
}

.aisales-chat-widget button.aisales-feedback-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  background: #25D366;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--aisales-font-body);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(37, 211, 102, 0.3);
}

.aisales-chat-widget button.aisales-feedback-wa-btn:hover {
  background: #20BD5A;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
}

.aisales-chat-widget button.aisales-feedback-wa-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.aisales-feedback-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--aisales-text-light);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.aisales-feedback-divider::before,
.aisales-feedback-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--aisales-border);
}

.aisales-chat-widget button.aisales-feedback-form-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--aisales-bg-chat);
  color: var(--aisales-text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--aisales-font-body);
  cursor: pointer;
  border: 1.5px solid var(--aisales-border);
  transition: all 0.2s ease;
}

.aisales-chat-widget button.aisales-feedback-form-btn:hover {
  border-color: var(--aisales-primary);
  background: var(--aisales-primary-glow);
  color: var(--aisales-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--aisales-primary-glow);
}

.aisales-chat-widget button.aisales-feedback-form-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

/* ─── Feedback: Form View ─── */
.aisales-feedback-form { display: none; flex-direction: column; gap: 16px; text-align: left; }
.aisales-feedback-form.active { display: flex; }

.aisales-feedback-form-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aisales-chat-widget button.aisales-feedback-back {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--aisales-bg-chat);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.aisales-chat-widget button.aisales-feedback-back:hover { background: var(--aisales-border); }

.aisales-chat-widget button.aisales-feedback-back svg {
  width: 16px;
  height: 16px;
  color: var(--aisales-text-secondary);
}

.aisales-feedback-form-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--aisales-text-primary);
}

/* Emoji rating */
.aisales-feedback-rating { display: flex; flex-direction: column; gap: 8px; }

.aisales-feedback-rating-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--aisales-text-secondary);
}

.aisales-feedback-emojis { display: flex; gap: 8px; }

.aisales-chat-widget button.aisales-feedback-emoji {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--aisales-bg-chat);
  border: 2px solid var(--aisales-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.4rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.aisales-chat-widget button.aisales-feedback-emoji:hover {
  transform: translateY(-3px) scale(1.1);
  border-color: var(--aisales-text-light);
  box-shadow: var(--aisales-shadow-sm);
  background: var(--aisales-bg-chat);
}

.aisales-chat-widget button.aisales-feedback-emoji.selected {
  border-color: var(--aisales-primary);
  background: var(--aisales-primary-glow);
  transform: scale(1.1);
  box-shadow: 0 2px 12px var(--aisales-primary-glow);
}

/* Textarea */
.aisales-chat-widget textarea.aisales-feedback-text {
  width: 100%;
  min-height: 80px;
  max-height: 120px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--aisales-border);
  background: var(--aisales-bg-chat);
  font-family: var(--aisales-font-body);
  font-size: 0.85rem;
  color: var(--aisales-text-primary);
  resize: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  outline: none;
  line-height: 1.5;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.aisales-chat-widget textarea.aisales-feedback-text:focus {
  border-color: var(--aisales-primary);
  box-shadow: 0 0 0 3px var(--aisales-primary-glow);
  background: #fff;
}

.aisales-chat-widget textarea.aisales-feedback-text::placeholder {
  color: var(--aisales-text-light);
}

/* File attachment */
.aisales-feedback-attach {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aisales-chat-widget button.aisales-feedback-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px dashed var(--aisales-border);
  background: var(--aisales-bg-chat);
  color: var(--aisales-text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--aisales-font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: flex-start;
}

.aisales-chat-widget button.aisales-feedback-attach-btn:hover {
  border-color: var(--aisales-primary);
  color: var(--aisales-primary);
  background: var(--aisales-primary-glow);
}

.aisales-chat-widget button.aisales-feedback-attach-btn svg {
  width: 15px;
  height: 15px;
}

.aisales-feedback-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aisales-feedback-previews:empty {
  display: none;
}

.aisales-feedback-preview-item {
  position: relative;
  flex-shrink: 0;
}

.aisales-feedback-preview-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid var(--aisales-border);
  display: block;
}

.aisales-chat-widget button.aisales-feedback-preview-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--aisales-text-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid #fff;
  padding: 0;
  transition: transform 0.15s ease;
}

.aisales-chat-widget button.aisales-feedback-preview-remove:hover {
  transform: scale(1.15);
  background: var(--aisales-text-primary);
  color: #fff;
}

.aisales-chat-widget button.aisales-feedback-preview-remove svg {
  width: 10px;
  height: 10px;
  stroke: #fff;
}

/* Submit */
.aisales-chat-widget button.aisales-feedback-submit {
  padding: 12px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--aisales-primary) 0%, var(--aisales-primary-dark) 100%);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--aisales-font-body);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px var(--aisales-primary-glow);
}

.aisales-chat-widget button.aisales-feedback-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--aisales-primary-glow);
  background: linear-gradient(135deg, var(--aisales-primary-dark) 0%, var(--aisales-primary) 100%);
  color: #fff;
}

.aisales-chat-widget button.aisales-feedback-submit:disabled,
.aisales-chat-widget button.aisales-feedback-submit:disabled:hover {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--aisales-border);
  color: var(--aisales-text-light);
}

/* ─── Feedback: Success View ─── */
.aisales-feedback-success { display: none; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0 4px; }
.aisales-feedback-success.active { display: flex; }

.aisales-feedback-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22C55E, #16A34A);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3);
  animation: aisales-success-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.aisales-feedback-success-icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
  stroke-width: 3;
}

@keyframes aisales-success-pop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.aisales-feedback-success-title {
  font-family: var(--aisales-font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--aisales-text-primary);
}

.aisales-feedback-success-desc {
  font-size: 0.82rem;
  color: var(--aisales-text-secondary);
  line-height: 1.5;
}


/* ─── New Chat Confirmation Modal ─── */
.aisales-new-chat-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.aisales-new-chat-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.aisales-new-chat-modal {
  background: white;
  border-radius: 20px;
  padding: 28px 24px 22px;
  width: 320px;
  box-shadow: var(--aisales-shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}

.aisales-new-chat-overlay.active .aisales-new-chat-modal {
  transform: translateY(0) scale(1);
}

.aisales-modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--aisales-primary-glow), rgba(0,0,0,0.02));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  border: 1.5px solid var(--aisales-primary-glow);
}

.aisales-modal-icon svg {
  width: 26px;
  height: 26px;
  color: var(--aisales-primary);
}

.aisales-modal-title {
  font-family: var(--aisales-font-body);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--aisales-text-primary);
  margin-bottom: 8px;
}

.aisales-modal-desc {
  font-size: 0.82rem;
  color: var(--aisales-text-secondary);
  line-height: 1.5;
  margin-bottom: 22px;
}

.aisales-modal-actions {
  display: flex;
  gap: 10px;
}

.aisales-chat-widget .aisales-modal-btn {
  flex: 1;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--aisales-font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.aisales-chat-widget .aisales-modal-btn.cancel {
  background: var(--aisales-bg-chat);
  color: var(--aisales-text-secondary);
  border: 1.5px solid var(--aisales-border);
}

.aisales-chat-widget .aisales-modal-btn.cancel:hover {
  background: var(--aisales-border);
  color: var(--aisales-text-primary);
}

.aisales-chat-widget .aisales-modal-btn.confirm {
  background: var(--aisales-primary);
  color: white;
  box-shadow: 0 2px 10px var(--aisales-primary-glow);
}

.aisales-chat-widget .aisales-modal-btn.confirm:hover {
  background: var(--aisales-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--aisales-primary-glow);
}

/* ─── Toast Notification ─── */
.aisales-toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--aisales-text-primary);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--aisales-shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 60;
  white-space: nowrap;
}

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

.aisales-toast svg {
  width: 16px;
  height: 16px;
  color: #4ADE80;
  flex-shrink: 0;
}

/* ─── Product Recommendations ─── */
@keyframes aisales-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.aisales-product-recommendations {
  margin-top: -12px;
  margin-bottom: 0;
  margin-left: 40px;
  display: flex;
  overflow-x: auto;
  padding: 4px 0 10px;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  gap: 10px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.aisales-product-recommendations::-webkit-scrollbar {
  display: none;
}

.aisales-product-card {
  flex: 0 0 140px;
  background: rgba(128, 128, 128, 0.08);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(128, 128, 128, 0.2);
  padding: 8px;
  scroll-snap-align: start;
}

.aisales-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.aisales-product-image {
  width: 80px;
  height: 80px;
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(128, 128, 128, 0.06);
}

.aisales-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.aisales-product-no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--aisales-primary) 0%, var(--aisales-primary-dark) 100%);
  color: #fff;
  font-size: 28px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 6px;
}

.aisales-product-shimmer {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: aisales-shimmer 1.5s infinite;
}

.aisales-product-fallback-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(128, 128, 128, 0.06);
  border-radius: 6px;
  color: rgba(128, 128, 128, 0.4);
}

.aisales-product-fallback-icon svg {
  width: 32px;
  height: 32px;
}

.aisales-product-info {
  padding: 6px 4px 4px;
}

.aisales-product-title {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--aisales-text-primary);
}

.aisales-product-price {
  font-size: 12px;
  font-weight: 700;
  color: var(--aisales-primary);
  margin-top: 2px;
}

/* ─── Category Recommendations ─── */
.aisales-category-recommendations {
  margin-top: 10px;
  margin-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.aisales-category-card {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  background-color: var(--aisales-bg-widget);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: var(--aisales-shadow-sm);
}

.aisales-category-card:hover {
  background-color: var(--aisales-primary-glow);
  border-color: var(--aisales-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--aisales-primary-glow);
}

.aisales-category-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--aisales-text-primary);
  margin-bottom: 4px;
}

.aisales-category-count {
  font-size: 0.78rem;
  color: var(--aisales-text-secondary);
}

/* ─── Chat Persistence ─── */
.aisales-restoration-indicator {
  background-color: var(--aisales-primary-glow);
  color: var(--aisales-primary);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  text-align: center;
  margin-bottom: 0;
  border: 1px solid var(--aisales-primary-glow);
}

/* ─── Legacy class compat (old header actions) ─── */
.aisales-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aisales-chat-close {
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  transition: all 0.2s ease;
}

.aisales-chat-close:hover {
  background: rgba(255,255,255,0.2);
}

.aisales-chat-close svg {
  width: 18px;
  height: 18px;
  fill: white;
}

/* ─── Responsive (Mobile Full-Screen) ─── */
@media (max-width: 576px) {
  .aisales-chat-window {
    width: 100%;
    height: 70vh;
    height: 70dvh;
    bottom: 0;
    right: 0;
    left: 0;
    border-radius: 20px 20px 0 0;
    max-height: 70vh;
    max-height: 70dvh;
  }

  .aisales-chat-widget.position-left .aisales-chat-window {
    left: 0;
  }

  .aisales-chat-button {
    bottom: 10px;
    right: 10px;
  }

  .aisales-chat-widget.position-left .aisales-chat-button {
    right: auto;
    left: 10px;
  }
}
