.opf-cw-root {
  --opf-cw-black: #0f0f0f;
  --opf-cw-black-soft: #2b2b2b;
  --opf-cw-ink: #161616;
  --opf-cw-ink-dim: #6e6e6e;
  --opf-cw-surface: #ffffff;
  --opf-cw-surface-alt: #f6f6f6;
  --opf-cw-border: #e3e3e3;
  --opf-cw-success: #2f7a52;
  --opf-cw-success-tint: #e8f2ec;
  --opf-cw-danger: #ad3a3a;
  --opf-cw-danger-tint: #fbeaea;
  --opf-cw-whatsapp: #25d366;

  position: fixed;
  bottom: 20px;
  z-index: 999999;
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.opf-cw-root * {
  box-sizing: border-box;
}

.opf-cw-position-bottom-right {
  right: 20px;
}

.opf-cw-position-bottom-left {
  left: 20px;
}

/* --- Toggle button --- */

/* !important below guards against the site theme's own global button
   reset (border-radius/background resets on `button`) winning by
   specificity — confirmed happening in production, not hypothetical. */
.opf-cw-toggle {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50% !important;
  border: none !important;
  background: linear-gradient(150deg, var(--opf-cw-black-soft), var(--opf-cw-black)) !important;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}

.opf-cw-toggle::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(15, 15, 15, 0.28);
  opacity: 0;
  animation: opf-cw-pulse 2.6s ease-out infinite;
}

@keyframes opf-cw-pulse {
  0% {
    opacity: 0.5;
    transform: scale(0.9);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

.opf-cw-toggle:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 28px -8px rgba(0, 0, 0, 0.55), 0 3px 10px rgba(0, 0, 0, 0.2);
}

.opf-cw-toggle:active {
  transform: translateY(0) scale(1);
}

.opf-cw-toggle:focus-visible {
  outline: 2px solid var(--opf-cw-black);
  outline-offset: 3px;
}

/* The theme's own global CSS was shrinking the icon via `flex-shrink` (a
   plain `width` !important wasn't enough — confirmed live: computed width
   collapsed to 10px/0px despite the rule) and overriding fill colors with
   !important. Pin the flex-basis explicitly and use the extra `.opf-cw-root`
   prefix for higher specificity so ours wins. */
.opf-cw-root .opf-cw-toggle svg,
.opf-cw-root .opf-cw-toggle-icon {
  transition: transform 0.2s ease;
  position: relative;
  display: block !important;
  flex: 0 0 26px !important;
  width: 26px !important;
  height: 26px !important;
}

.opf-cw-root .opf-cw-toggle svg rect {
  fill: #fff !important;
}

.opf-cw-root .opf-cw-toggle svg circle {
  fill: #0f0f0f !important;
}

.opf-cw-root .opf-cw-toggle svg path {
  stroke: #0f0f0f !important;
}

.opf-cw-toggle-icon {
  width: 30px;
  height: 30px;
  /* Icon is black line art on transparent — invert to white for the black circle */
  filter: invert(1);
}

.opf-cw-toggle[aria-expanded='true'] svg,
.opf-cw-toggle[aria-expanded='true'] .opf-cw-toggle-icon {
  transform: scale(0.85) rotate(-8deg);
}

@media (prefers-reduced-motion: reduce) {
  .opf-cw-toggle::before {
    animation: none;
    display: none;
  }
}

/* --- Panel --- */

.opf-cw-panel {
  position: absolute;
  bottom: 76px;
  width: 366px;
  max-width: calc(100vw - 40px);
  height: 530px;
  max-height: 72vh;
  background: var(--opf-cw-surface);
  border-radius: 20px;
  box-shadow: 0 24px 56px -14px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.opf-cw-panel.opf-cw-panel--open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .opf-cw-panel,
  .opf-cw-toggle,
  .opf-cw-toggle svg {
    transition: none;
  }
}

.opf-cw-position-bottom-right .opf-cw-panel {
  right: 0;
}

.opf-cw-position-bottom-left .opf-cw-panel {
  left: 0;
}

/* --- Header --- */

.opf-cw-header {
  background: linear-gradient(150deg, var(--opf-cw-black-soft), var(--opf-cw-black));
  color: #fff;
  padding: 16px 16px 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.opf-cw--ltr .opf-cw-header {
  padding: 16px 18px 16px 16px;
}

.opf-cw-avatar {
  width: 42px;
  height: 40px;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 5px;
}

.opf-cw-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.opf-cw-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.opf-cw-header-title {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.opf-cw-header-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.opf-cw-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.opf-cw-close {
  background: rgba(255, 255, 255, 0.14) !important;
  border: none !important;
  color: #fff !important;
  width: 30px;
  height: 30px;
  border-radius: 50% !important;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  overflow: hidden;
}

.opf-cw-close:hover {
  background: rgba(255, 255, 255, 0.26);
}

.opf-cw-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* --- Messages --- */

.opf-cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: var(--opf-cw-surface-alt);
  scrollbar-width: thin;
  scrollbar-color: var(--opf-cw-border) transparent;
}

/* Flex items default to flex-shrink:1, so once the message list is tall
   enough to need the overflow-y:auto scrollbar above, the browser was
   squeezing bubbles/card rows down to near-zero height instead of just
   scrolling past them — this is what made product/branch carousels
   disappear intermittently. Every message item keeps its natural size and
   the container scrolls instead. */
.opf-cw-messages > * {
  flex-shrink: 0;
}

.opf-cw-messages::-webkit-scrollbar {
  width: 6px;
}

.opf-cw-messages::-webkit-scrollbar-thumb {
  background: var(--opf-cw-border);
  border-radius: 3px;
}

.opf-cw-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.opf-cw-bubble p {
  margin: 0 0 6px;
}

.opf-cw-bubble p:last-child {
  margin-bottom: 0;
}

.opf-cw-bubble strong {
  font-weight: 700;
}

.opf-cw-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.opf-cw-bubble--assistant a {
  color: var(--opf-cw-black);
  font-weight: 600;
}

.opf-cw-list {
  margin: 2px 0 8px;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.opf-cw-list:last-child {
  margin-bottom: 0;
}

.opf-cw--rtl .opf-cw-bubble--user {
  align-self: flex-start;
  background: var(--opf-cw-black);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.opf-cw--ltr .opf-cw-bubble--user {
  align-self: flex-end;
  background: var(--opf-cw-black);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.opf-cw-bubble--assistant {
  align-self: flex-start;
  background: var(--opf-cw-surface);
  color: var(--opf-cw-ink);
  border: 1px solid var(--opf-cw-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.opf-cw-bubble--thinking {
  display: flex;
  align-items: center;
  padding: 12px 16px;
}

.opf-cw-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.opf-cw-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--opf-cw-black);
  opacity: 0.35;
  animation: opf-cw-bounce 1.1s infinite ease-in-out;
}

.opf-cw-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.opf-cw-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes opf-cw-bounce {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .opf-cw-dots span {
    animation: none;
    opacity: 0.7;
  }
}

.opf-cw-bubble--error {
  background: var(--opf-cw-danger-tint);
  border-color: color-mix(in srgb, var(--opf-cw-danger) 35%, var(--opf-cw-border));
  color: var(--opf-cw-danger);
}

/* --- Welcome block --- */

.opf-cw-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 18px 6px 6px;
  align-self: stretch;
}

.opf-cw-welcome-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--opf-cw-surface-alt);
  border: 1px solid var(--opf-cw-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 6px;
}

.opf-cw-welcome-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--opf-cw-ink);
}

.opf-cw-welcome-subtitle {
  font-size: 12.5px;
  color: var(--opf-cw-ink-dim);
  max-width: 26ch;
  line-height: 1.5;
  margin-bottom: 10px;
}

.opf-cw-welcome-examples-label {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--opf-cw-ink-dim);
  margin-bottom: 4px;
}

.opf-cw-example-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: var(--opf-cw-surface);
  border: 1px solid var(--opf-cw-border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--opf-cw-ink);
  cursor: pointer;
  text-align: start;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.opf-cw-example-row + .opf-cw-example-row {
  margin-top: 6px;
}

.opf-cw-example-row:hover {
  background: var(--opf-cw-surface-alt);
  border-color: var(--opf-cw-black);
}

.opf-cw-example-row:focus-visible {
  outline: 2px solid var(--opf-cw-black);
  outline-offset: 2px;
}

.opf-cw-example-row-arrow {
  color: var(--opf-cw-ink-dim);
  flex-shrink: 0;
}

/* --- Product card carousel --- */

.opf-cw-cards-row {
  display: flex;
  align-items: center;
  gap: 4px;
  align-self: stretch;
  margin: 0 -13px;
  padding-inline: 4px;
}

.opf-cw-cards-arrow {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--opf-cw-border);
  background: var(--opf-cw-surface);
  color: var(--opf-cw-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, background 0.12s ease;
}

.opf-cw-cards-arrow:hover {
  transform: scale(1.08);
  background: var(--opf-cw-surface-alt);
}

.opf-cw-cards {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--opf-cw-border) transparent;
}

.opf-cw-cards::-webkit-scrollbar {
  height: 5px;
}

.opf-cw-cards::-webkit-scrollbar-thumb {
  background: var(--opf-cw-border);
  border-radius: 3px;
}

.opf-cw-card {
  position: relative;
  flex: 0 0 auto;
  width: 148px;
  scroll-snap-align: start;
  background: var(--opf-cw-surface);
  border: 1px solid var(--opf-cw-border);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.opf-cw-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.28);
  border-color: var(--opf-cw-black);
}

.opf-cw-card-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.opf-cw-card-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--opf-cw-surface-alt);
}

.opf-cw-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.opf-cw-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px 40px;
}

.opf-cw-card-rating {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--opf-cw-ink);
}

.opf-cw-card-rating-star {
  color: #f5a623;
}

.opf-cw-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--opf-cw-ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.opf-cw-card-price {
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
  color: var(--opf-cw-black);
}

.opf-cw-card-price-old {
  text-decoration: line-through;
  color: var(--opf-cw-ink-dim);
  font-weight: 500;
  font-size: 11px;
}

.opf-cw-card-price-sale {
  color: var(--opf-cw-danger);
}

.opf-cw-card-stock {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--opf-cw-success-tint);
  color: var(--opf-cw-success);
  margin-top: 2px;
}

.opf-cw-card-stock::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.opf-cw-card-stock--out {
  background: var(--opf-cw-danger-tint);
  color: var(--opf-cw-danger);
}

/* --- Branch cards --- */

.opf-cw-branch-card {
  width: 176px;
  /* Product cards get correct auto-height as a flex item because their
     content is wrapped in .opf-cw-card-link (display:flex; column).
     Branch cards append .opf-cw-card-body/.opf-cw-branch-actions as plain
     block children directly, which collapses to near-zero height as a flex
     item of .opf-cw-cards (row) — force the same flex-column layout here. */
  display: flex;
  flex-direction: column;
}

.opf-cw-branch-card .opf-cw-card-body {
  padding: 12px 12px 10px;
  gap: 4px;
}

.opf-cw-branch-hours {
  font-size: 11px;
  color: var(--opf-cw-ink-dim);
  line-height: 1.4;
}

.opf-cw-branch-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 12px 12px;
}

.opf-cw-branch-action {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  transition: transform 0.12s ease;
}

.opf-cw-branch-action:hover {
  transform: translateY(-1px);
}

.opf-cw-branch-action--map {
  background: var(--opf-cw-black);
  color: #fff;
}

.opf-cw-branch-action--whatsapp {
  background: #e7f8ee;
  color: #1e8e4d;
}

/* --- Inline payment logos & WhatsApp buttons within message text --- */

.opf-cw-pay-logo {
  height: 16px;
  width: auto;
  vertical-align: middle;
  margin: 0 3px;
}

.opf-cw-wa-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--opf-cw-whatsapp);
  color: #fff;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  vertical-align: middle;
  transition: transform 0.12s ease;
}

.opf-cw-wa-button:hover {
  transform: translateY(-1px);
}

/* --- Escalation --- */

.opf-cw-escalation {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--opf-cw-whatsapp);
  color: #fff;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 13px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 4px 12px -3px rgba(37, 211, 102, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.opf-cw-escalation:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -3px rgba(37, 211, 102, 0.55);
}

/* --- Input row --- */

.opf-cw-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px;
  border-top: 1px solid var(--opf-cw-border);
  background: var(--opf-cw-surface);
  flex-shrink: 0;
}

.opf-cw-input {
  flex: 1;
  border: 1.5px solid var(--opf-cw-border);
  background: var(--opf-cw-surface-alt);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  color: var(--opf-cw-ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.opf-cw-input::placeholder {
  color: var(--opf-cw-ink-dim);
}

.opf-cw-input:focus {
  border-color: var(--opf-cw-black);
  background: var(--opf-cw-surface);
  box-shadow: 0 0 0 3px rgba(15, 15, 15, 0.08);
}

.opf-cw-send {
  background: var(--opf-cw-black) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 50% !important;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.opf-cw-root .opf-cw-send svg {
  display: inline-block !important;
  flex: 0 0 18px !important;
  width: 18px !important;
  height: 18px !important;
}

.opf-cw-root .opf-cw-send svg path,
.opf-cw-root .opf-cw-send svg polygon {
  fill: #fff !important;
}

.opf-cw--rtl .opf-cw-send svg {
  transform: scaleX(-1);
}

.opf-cw-send:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.04);
}

.opf-cw-send:focus-visible {
  outline: 2px solid var(--opf-cw-black);
  outline-offset: 2px;
}

.opf-cw-send:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

@media (max-width: 420px) {
  .opf-cw-panel {
    width: calc(100vw - 32px);
  }
}
