/* @fermat/shopping-assistant chat styles — extracted from @fermat/react shared.css.
   Reset is scoped to the chat roots so it's a no-op in light DOM (funnel) but works
   inside a Shadow root (host resets don't pierce the boundary). */

/* --- Scoped reset (safe in light DOM; required in Shadow DOM) --- */
.fermat-chat-container,
.fermat-chat-container *,
.fermat-chat-container *::before,
.fermat-chat-container *::after,
.fermat-chat-mobile-fullscreen,
.fermat-chat-mobile-fullscreen *,
.fermat-chat-mobile-fullscreen *::before,
.fermat-chat-mobile-fullscreen *::after {
  box-sizing: border-box;
}

.fermat-chat-container button,
.fermat-chat-container input,
.fermat-chat-mobile-fullscreen button,
.fermat-chat-mobile-fullscreen input {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}

.fermat-chat-container a,
.fermat-chat-mobile-fullscreen a {
  color: inherit;
}

/* --- Extracted .fermat-chat-* block (shared.css 804-1563) --- */

.fermat-chat-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-chat-bubble, 9999);
  font-family: var(
    --font-brand-primary,
    var(--neue-montreal-font-stack),
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif
  );
}

.fermat-chat-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0a0a0a;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fermat-chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.fermat-chat-button:active {
  transform: scale(0.98);
}

.fermat-chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 480px;
  max-width: calc(100vw - 48px);
  height: 740px;
  max-height: calc(100vh - 120px);
  background: #fafafa;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fermat-chat-slide-up 0.25s ease-out;
  font-family: var(--fermat-body-fontFamily, inherit);
}

@keyframes fermat-chat-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fermat-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #0a0a0a;
  color: white;
}

.fermat-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fermat-chat-header-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
}

.fermat-chat-message-brand-logo {
  width: 16px;
  height: 16px;
  object-fit: contain;
  border-radius: 2px;
  flex-shrink: 0;
}

.fermat-chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.fermat-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fermat-chat-header-ai {
  font-weight: 400;
  opacity: 0.8;
  margin-left: 4px;
}

.fermat-chat-support-phone-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f6f5f3;
  color: #7a7973;
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px solid #eae9e6;
  transition: background 0.15s ease;
}

.fermat-chat-support-phone-bar:hover {
  background: #e8e8e8;
}

.fermat-chat-support-phone-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}

.fermat-chat-support-new-chat {
  display: none;
  background: var(--fermat-color-secondary-bg, #f6f5f3);
  color: var(--fermat-color-secondary-text, #7a7973);
  border: 1px solid var(--fermat-color-secondary-text, #7a7973);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.fermat-chat-support-new-chat:hover {
  opacity: 0.8;
}

.fermat-chat-reset-button {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fermat-chat-reset-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: white;
}

.fermat-chat-close-button {
  background: transparent;
  color: white;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.fermat-chat-close-button:hover {
  opacity: 1;
}

.fermat-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fermat-chat-welcome-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fermat-chat-welcome-section .fermat-chat-message {
  font-size: 13px;
}

.fermat-chat-recs-card {
  background: #f6f5f3;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fermat-chat-recs-heading {
  margin: 0;
  font-size: 13px;
  width: 100%;
  line-height: 1.4;
  color: #0a0a0a;
}

.fermat-chat-carousel-fill,
.fermat-chat-recs-card .fermat-chat-carousel {
  overflow-x: unset;
}

.fermat-chat-recs-card .fermat-chat-carousel-card-image {
  aspect-ratio: 4 / 3;
}

.fermat-chat-suggestions {
  margin-top: 0;
  padding: 0 4px;
}

.fermat-chat-suggestions-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 500;
  color: #0a0a0a;
}

.fermat-chat-suggestions-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
}

.fermat-chat-suggestion-pill {
  background: white;
  border: 1px solid #eae9e6;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-family: inherit;
  color: #0a0a0a;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-align: left;
  line-height: 18px;
  white-space: nowrap;
}

.fermat-chat-suggestion-pill:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.fermat-chat-messages > div {
  display: flex;
  flex-direction: column;
}

.fermat-chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.fermat-chat-message p {
  margin: 0;
}

.fermat-chat-message-user {
  align-self: flex-end;
  background: #0a0a0a;
  color: white;
  border-bottom-right-radius: 4px;
}

.fermat-chat-message-assistant {
  align-self: flex-start;
  max-width: 92%;
  background: white;
  color: #0a0a0a;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #eae9e6;
  border-bottom-left-radius: 4px;
}

.fermat-chat-markdown {
  font-size: 14px;
  line-height: 1.6;
}

.fermat-chat-markdown p {
  margin: 0 0 8px 0;
}

.fermat-chat-markdown p:last-child {
  margin-bottom: 0;
}

.fermat-chat-markdown ul,
.fermat-chat-markdown ol {
  margin: 8px 0;
  padding-left: 20px;
}

.fermat-chat-markdown li {
  margin-bottom: 4px;
}

.fermat-chat-markdown strong {
  font-weight: 600;
}

.fermat-chat-markdown code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Monaco, monospace;
  font-size: 13px;
}

.fermat-chat-markdown pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.fermat-chat-markdown pre code {
  background: none;
  padding: 0;
}

.fermat-chat-markdown a {
  color: #2563eb;
  text-decoration: underline;
}

.fermat-chat-markdown h1,
.fermat-chat-markdown h2,
.fermat-chat-markdown h3,
.fermat-chat-markdown h4 {
  margin: 12px 0 8px 0;
  font-weight: 600;
}

.fermat-chat-markdown h1 {
  font-size: 18px;
}

.fermat-chat-markdown h2 {
  font-size: 16px;
}

.fermat-chat-markdown h3 {
  font-size: 15px;
}

.fermat-chat-markdown h4 {
  font-size: 14px;
}

.fermat-chat-loading {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.fermat-chat-loading-dot {
  width: 8px;
  height: 8px;
  background: #888;
  border-radius: 50%;
  animation: fermat-chat-bounce 1.4s infinite ease-in-out both;
}

.fermat-chat-loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.fermat-chat-loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes fermat-chat-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.fermat-chat-error {
  background: #fef2f2;
  color: #dc2626;
  padding: 12px 16px;
  font-size: 13px;
  border-top: 1px solid #fecaca;
}

.fermat-chat-error p {
  margin: 0;
}

.fermat-chat-input-wrapper {
  border-top: 1px solid #e5e5e5;
  background: white;
  flex-shrink: 0;
}

.fermat-chat-input-form {
  padding: 16px 16px 8px;
}

.fermat-chat-input-inner {
  position: relative;
  display: flex;
  align-items: center;
}

.fermat-chat-disclaimer {
  margin: 0;
  padding: 0 16px 10px;
  font-size: 12px;
  color: #777;
  text-align: center;
}

.fermat-chat-input {
  flex: 1;
  width: 100%;
  padding: 10px 40px 10px 12px;
  border: 1px solid #e2e2dc;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fermat-chat-input:focus {
  border-color: #0a0a0a;
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.08);
}

.fermat-chat-input::placeholder {
  color: #a6a59e;
}

.fermat-chat-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.fermat-chat-send-button {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: opacity 0.15s ease;
}

.fermat-chat-send-button:hover:not(:disabled) {
  opacity: 0.7;
}

.fermat-chat-send-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Product carousel in chat messages */

.fermat-chat-carousel-wrapper {
  padding: 8px 0 4px 0;
  max-width: 85%;
}

.fermat-chat-carousel-wrapper:has(.fermat-chat-carousel-fill) {
  max-width: 100%;
}

.fermat-chat-carousel-heading {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.fermat-chat-carousel {
  display: flex;
  gap: 10px;
  padding-bottom: 4px;
}

.fermat-chat-carousel-card {
  flex: 0 0 140px;
  width: 140px;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.fermat-chat-carousel-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fermat-chat-carousel-card-image {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f5f5f5;
}

.fermat-chat-carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fermat-chat-carousel-card-info {
  padding: 8px 10px;
}

.fermat-chat-carousel-card-name {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: #0a0a0a;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fermat-chat-carousel-card-price {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.fermat-chat-carousel-unit-price {
  font-size: 12px;
  font-weight: 600;
  color: #0a0a0a;
}

.fermat-chat-carousel-list-price {
  font-size: 11px;
  color: #999;
  text-decoration: line-through;
}

.fermat-chat-carousel-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.fermat-chat-carousel-card-actions {
  padding: 0 8px 8px;
}

.fermat-chat-carousel-atc-btn {
  width: 100%;
  padding: 5px 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #0a0a0a;
  border-radius: 6px;
  background: #0a0a0a;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
  line-height: 1.2;
}

.fermat-chat-carousel-atc-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.fermat-chat-carousel-atc-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.fermat-chat-carousel-atc-added {
  background: #16a34a;
  border-color: #16a34a;
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .fermat-chat-container {
    bottom: 16px;
    right: 16px;
  }

  .fermat-chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 68px;
    right: -8px;
  }

  .fermat-chat-button {
    width: 52px;
    height: 52px;
  }

  .fermat-chat-carousel-card {
    flex: 0 0 120px;
    width: 120px;
  }

  .fermat-chat-support-phone-bar span {
    font-size: 11px;
  }

  /* Prevent iOS Safari auto-zoom on input focus (font-size < 16px) */
  .fermat-chat-input {
    font-size: 16px;
  }
}

/* Mobile: hide the floating chat bubble — tab bar handles chat instead */
@media (max-width: 767px) {
  .fermat-chat-container {
    display: none;
  }
}

/* Mobile full-screen chat (used when the "Chat" tab is active) */
.fermat-chat-mobile-fullscreen {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  font-family: var(
    --font-brand-primary,
    var(--neue-montreal-font-stack),
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif
  );
}

/* Desktop: hide the mobile fullscreen chat */
@media (min-width: 768px) {
  .fermat-chat-mobile-fullscreen {
    display: none;
  }
}

.fermat-chat-mobile-fullscreen .fermat-chat-header {
  display: none;
}

.fermat-chat-mobile-fullscreen .fermat-chat-close-button {
  display: none;
}

.fermat-chat-mobile-fullscreen .fermat-chat-support-phone-bar {
  justify-content: space-between;
  background: #0a0a0a;
  color: white;
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.fermat-chat-mobile-fullscreen .fermat-chat-support-phone-bar:hover {
  background: #0a0a0a;
  opacity: 0.9;
}

.fermat-chat-mobile-fullscreen .fermat-chat-support-new-chat {
  display: inline-flex;
  background: var(--fermat-color-secondary-bg, #0a0a0a);
  color: var(--fermat-color-secondary-text, white);
  border-color: var(--fermat-color-secondary-text, rgba(255, 255, 255, 0.6));
}

.fermat-chat-mobile-fullscreen .fermat-chat-panel {
  position: static;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}

/* Widget-owned mounting (shopping-assistant): mobile launcher + self-managed full-screen overlay */
.fermat-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-chat-bubble, 9999);
}

.fermat-chat-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-chat-bubble, 9999);
  background: #fafafa;
}
