/* CFS (TheFootboxClub) chat widget — Míster visual identity — heredada de IRIS, light mode. */

/* === Tokens ===
   Brand colours used in this file:
     --iris-deep   #00b8d4   primary turquoise (icons, send button, focus, hovers)
     --iris-bright #00d4ff   accent only (gradient + pulse), too low contrast for body text
     --iris-soft   #4dd0e1   lighter turquoise (gradient center, soft accent)
   White heart 🤍 is the brand emoji (set in copy, not in CSS).
*/

.cfs-chat-root,
.cfs-chat-root * {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

/* === Míster avatar (concentric rings, periodic blink) === */
.cfs-iris {
  display: block;
  width: 100%;
  height: 100%;
}
.cfs-iris .iris-pupil {
  transform-origin: center;
  transform-box: view-box;
  animation: cfs-iris-blink 6s ease-in-out infinite;
}
@keyframes cfs-iris-blink {
  0%,
  95% {
    transform: scale(1);
  }
  96.5%,
  98% {
    transform: scale(0.7);
  }
  100% {
    transform: scale(1);
  }
}

/* === Floating bubble ===
   Chat-bubble silhouette: three corners are rounded large (28px on a 60x60)
   and the bottom-left corner is pinched (6px). The asymmetric shape reads as
   a speech balloon "talking toward" the page content on its left, while still
   feeling soft and modern. The iris avatar sits centred inside; the pulse,
   halo and entrance animation are unchanged. */
.cfs-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 28px 28px 28px 6px;
  background: radial-gradient(circle at 32% 32%, #4dd0e1 0%, #00d4ff 70%, #00b8d4 100%);
  color: #ffffff; /* iris inside the bubble inherits this → all-white iris on turquoise */
  border: none;
  cursor: pointer;
  z-index: 2147483646;
  box-shadow: 0 6px 20px rgba(0, 184, 212, 0.35);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cfs-bubble-enter 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
    cfs-bubble-pulse 2.4s ease-in-out 700ms infinite;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.cfs-chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 184, 212, 0.42);
}
.cfs-chat-bubble:active {
  transform: translateY(0);
}
.cfs-chat-bubble:focus-visible {
  outline: 3px solid rgba(0, 212, 255, 0.45);
  outline-offset: 3px;
}
/* The halo (box-shadow pulse) inherits the parent's border-radius so the
   ripple matches the chat-bubble silhouette, not a perfect circle. Modern
   browsers compute this automatically for box-shadow — included here as a
   safety: if any rule reset border-radius elsewhere, the halo would still
   match the shape. */
.cfs-chat-bubble-inner {
  width: 36px;
  height: 36px;
  display: block;
}
@keyframes cfs-bubble-enter {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes cfs-bubble-pulse {
  0%,
  100% {
    box-shadow: 0 6px 20px rgba(0, 184, 212, 0.35),
      0 0 0 0 rgba(0, 212, 255, 0.45);
  }
  50% {
    box-shadow: 0 6px 20px rgba(0, 184, 212, 0.35),
      0 0 0 16px rgba(0, 212, 255, 0);
  }
}

/* === Preview greeting balloon === */
.cfs-chat-preview {
  position: fixed;
  right: 92px;
  bottom: 28px;
  z-index: 2147483646;
  max-width: 280px;
  pointer-events: auto;
}
.cfs-chat-preview.hidden {
  display: none;
}
.cfs-chat-preview.entering {
  animation: cfs-preview-in 300ms ease-out;
}
.cfs-chat-preview.leaving {
  animation: cfs-preview-out 220ms ease-in forwards;
}
.cfs-chat-preview-bubble {
  position: relative;
  background: #ffffff;
  color: #333;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 36px 10px 14px;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.cfs-chat-preview-bubble::after {
  /* tail pointing toward the bubble */
  content: "";
  position: absolute;
  right: -7px;
  bottom: 14px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-right: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
  transform: rotate(-45deg);
}
.cfs-chat-preview-close {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #999;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 100ms ease, color 100ms ease;
}
.cfs-chat-preview-close:hover {
  background: #f4f4f4;
  color: #333;
}
.cfs-chat-preview-close:focus-visible {
  outline: 2px solid rgba(0, 184, 212, 0.5);
  outline-offset: 1px;
}
@keyframes cfs-preview-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes cfs-preview-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}

/* === Panel === */
.cfs-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  color: #111;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483647;
  border: 1px solid rgba(0, 0, 0, 0.04);
  animation: cfs-panel-in 250ms ease-out;
}
.cfs-chat-panel.hidden {
  display: none;
}
@keyframes cfs-panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Header === */
.cfs-chat-header {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  gap: 8px;
}
.cfs-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.cfs-chat-header-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: #00b8d4; /* iris turquoise on white */
}
.cfs-chat-header-text {
  min-width: 0;
}
.cfs-chat-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.1;
}
.cfs-chat-header-name {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  letter-spacing: 0.02em;
}
.cfs-chat-header-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #46a35a;
}
.cfs-chat-header-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4cc36a;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(76, 195, 106, 0.5);
  animation: cfs-dot-pulse 2.4s ease-in-out infinite;
}
@keyframes cfs-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 195, 106, 0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(76, 195, 106, 0); }
}
.cfs-chat-header-sub {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cfs-chat-header-sub .cfs-wing {
  opacity: 0.7;
  flex-shrink: 0;
}
.cfs-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.cfs-chat-close,
.cfs-chat-new {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 6px;
  border-radius: 8px;
  line-height: 0;
  transition: background 100ms ease, color 100ms ease;
}
.cfs-chat-close:hover,
.cfs-chat-new:hover {
  background: #f4f4f4;
  color: #111;
}
.cfs-chat-close:focus-visible,
.cfs-chat-new:focus-visible {
  outline: 2px solid rgba(0, 184, 212, 0.5);
  outline-offset: 1px;
}

/* === Messages list === */
.cfs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #ffffff;
}
.cfs-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.cfs-chat-messages::-webkit-scrollbar-thumb {
  background: #e5e5e5;
  border-radius: 3px;
}
.cfs-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* Wrap = avatar slot + bubble. Avatar slot is 24px wide; for Míster messages
   after the first in a block, the slot is a transparent spacer so the bubble
   still aligns horizontally. */
.cfs-chat-msg-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: cfs-msg-in 150ms ease-out;
}
.cfs-chat-msg-wrap.user {
  justify-content: flex-end;
}
.cfs-chat-msg-wrap.assistant {
  justify-content: flex-start;
}
.cfs-chat-msg-avatar,
.cfs-chat-msg-avatar-spacer {
  width: 24px;
  flex-shrink: 0;
}
.cfs-chat-msg-avatar {
  height: 24px;
  color: #00b8d4;
  margin-bottom: 4px;
}
@keyframes cfs-msg-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cfs-chat-msg {
  max-width: 78%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cfs-chat-msg.user {
  background: #f0f0f0;
  color: #111;
  border-bottom-right-radius: 6px;
}
.cfs-chat-msg.assistant {
  background: #ffffff;
  color: #111;
  border: 1px solid #e6e6e6;
  border-bottom-left-radius: 6px;
}
.cfs-chat-msg.streaming::after {
  content: "▍";
  margin-left: 2px;
  animation: cfs-cursor-blink 0.9s steps(2) infinite;
  color: #00b8d4;
}
@keyframes cfs-cursor-blink {
  50% {
    opacity: 0;
  }
}
.cfs-chat-msg a {
  color: #006c80; /* AA on white */
  text-decoration: underline;
}

/* Typing indicator — 3 bouncing dots inside an empty assistant bubble */
.cfs-chat-msg.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  min-height: 0;
}
.cfs-chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bbb;
  display: inline-block;
  animation: cfs-typing-bounce 1.3s ease-in-out infinite;
}
.cfs-chat-typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}
.cfs-chat-typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes cfs-typing-bounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Tool call note */
.cfs-chat-tool {
  align-self: center;
  font-size: 11px;
  color: #888;
  font-style: italic;
  padding: 0;
  margin: 8px 0 4px;
}

/* === Input === */
.cfs-chat-input-wrap {
  border-top: 1px solid #f0f0f0;
  padding: 10px 12px 10px;
  background: #ffffff;
}
.cfs-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cfs-chat-input {
  flex: 1;
  resize: none;
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: 18px;
  border: 1px solid #e1e1e1;
  background: #fafafa;
  color: #111;
  font-family: inherit;
  max-height: 120px;
  outline: none;
  transition: border-color 100ms ease, background 100ms ease;
}
.cfs-chat-input::placeholder {
  color: #aaa;
}
.cfs-chat-input:focus {
  border-color: #00b8d4;
  background: #fff;
}
.cfs-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #00b8d4;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 100ms ease, transform 100ms ease;
}
.cfs-chat-send:hover {
  background: #00a5be;
}
.cfs-chat-send:active {
  transform: scale(0.95);
}
.cfs-chat-send:disabled {
  background: #c0d8de;
  cursor: not-allowed;
}
.cfs-chat-send:focus-visible {
  outline: 2px solid rgba(0, 184, 212, 0.6);
  outline-offset: 2px;
}
.cfs-chat-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cfs-chat-footer {
  font-size: 10px;
  color: #ccc;
  text-align: center;
  margin-top: 8px;
}

/* === Cards (product, order, update) — light & soft === */
.cfs-chat-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 8px;
}
.cfs-chat-card {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid #ececec;
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.cfs-chat-card.product:hover {
  border-color: #00b8d4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.cfs-chat-card-img {
  width: 64px;
  height: 64px;
  background-size: cover;
  background-position: center;
  background-color: #f4f4f4;
  border-radius: 10px;
  flex-shrink: 0;
}
.cfs-chat-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1;
}
.cfs-chat-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  line-height: 1.3;
}
.cfs-chat-card-price {
  font-size: 13px;
  margin-top: 2px;
  color: #111;
}
.cfs-chat-card-meta {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}
.cfs-chat-card-meta a {
  color: #111;
  text-decoration: underline;
}
.cfs-chat-card-items {
  list-style: disc;
  padding-left: 18px;
  margin: 6px 0 0;
  font-size: 12px;
  color: #444;
}
.cfs-chat-card-items li {
  margin: 2px 0;
}
.cfs-chat-card.order {
  border-left: 3px solid #00b8d4;
}
.cfs-chat-card.update {
  border-left: 3px solid #2e7d32;
  background: #f4faf4;
}
.cfs-chat-card.update .cfs-chat-card-title {
  color: #2e7d32;
}

/* === Mobile (<600px): full-screen panel === */
@media (max-width: 600px) {
  .cfs-chat-panel {
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .cfs-chat-header {
    padding: 16px 14px;
  }
  .cfs-chat-close {
    padding: 10px;
  }
  .cfs-chat-bubble {
    width: 52px;
    height: 52px;
    border-radius: 24px 24px 24px 5px;
    right: 14px;
    bottom: 14px;
  }
  .cfs-chat-bubble-inner {
    width: 30px;
    height: 30px;
  }
  .cfs-chat-preview {
    right: 78px;
    bottom: 18px;
    max-width: calc(100vw - 100px);
  }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  .cfs-iris .iris-pupil,
  .cfs-chat-bubble,
  .cfs-chat-panel,
  .cfs-chat-preview,
  .cfs-chat-preview.entering,
  .cfs-chat-preview.leaving,
  .cfs-chat-msg-wrap,
  .cfs-chat-typing-dot,
  .cfs-chat-header-dot,
  .cfs-chat-msg.streaming::after {
    animation: none !important;
    transition: none !important;
  }
}
