/* CarZora Assistant widget — AI-Native UI, CarZora brand system.
   All selectors prefixed .czbot- so they cannot collide with the site.
   Palette mirrors css/style.css :root (lime / black / beige). */

.czbot-root {
  --czbot-lime-400: #32cd32;
  --czbot-lime-500: #28b828;
  --czbot-lime-600: #228b22;
  --czbot-beige-100: #f9f7f0;
  --czbot-beige-200: #ebe7da;
  --czbot-black-900: #191919;
  --czbot-black-800: #2a2a2a;
  --czbot-gray-500: #6b6b6b;
  --czbot-gray-400: #8a8a8a;
  --czbot-border: #e6e3d6;
  --czbot-grad: linear-gradient(135deg, #32cd32 0%, #28b828 50%, #228b22 100%);
  --czbot-green: #32cd32;

  position: fixed;
  right: 2rem; /* aligned with .whatsapp-widget */
  bottom: calc(2rem + 51px + 0.625rem); /* 2rem gap + 51px WA button + 10px spacing */
  z-index: 2147483000;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Floating launcher ---- */
.czbot-bubble {
  width: auto;
  height: auto;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  overflow: visible;
  box-shadow: none;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.czbot-bubble img {
  width: 51px;
  height: 51px;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 50%;
  box-shadow: 0 10px 26px rgba(50, 205, 50, 0.42);
  transition: box-shadow 0.3s ease;
}
.czbot-bubble:hover img {
  box-shadow: 0 6px 16px rgba(50, 205, 50, 0.5);
}
.czbot-bubble:hover {
  transform: scale(1.05);
}
.czbot-bubble:focus-visible {
  outline: 3px solid var(--czbot-black-900);
  outline-offset: 3px;
}
.czbot-root.czbot-open .czbot-bubble {
  display: none;
}

/* ---- Speech bubble callout ---- */
.czbot-callout {
  position: absolute;
  bottom: 68px;
  right: 0;
  background: #fff;
  color: var(--czbot-black-900);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 6px 20px rgba(25, 25, 25, 0.14);
  white-space: nowrap;
  pointer-events: none;
  animation: czbot-callout-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.czbot-callout::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 18px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 0px solid transparent;
  border-top: 8px solid #fff;
}
.czbot-root.czbot-open .czbot-callout {
  display: none;
}
@keyframes czbot-callout-in {
  from { opacity: 0; transform: translateY(6px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes czbot-ping {
  0% {
    box-shadow: 0 0 0 0 rgba(50, 205, 50, 0.45);
  }
  70%,
  100% {
    box-shadow: 0 0 0 16px rgba(50, 205, 50, 0);
  }
}

/* ---- Panel ---- */
.czbot-panel[hidden] { display: none; }

.czbot-panel {
  width: 378px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid var(--czbot-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(25, 25, 25, 0.26);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: czbot-pop 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes czbot-pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes czbot-slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ---- Header (dark = brand + contrast-safe) ---- */
.czbot-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 16px;
  background: var(--czbot-black-900);
  color: #fff;
}
.czbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.czbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.czbot-headtext {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}
.czbot-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.czbot-status {
  font-size: 12px;
  color: var(--czbot-lime-400);
  display: flex;
  align-items: center;
  gap: 5px;
}
.czbot-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--czbot-lime-400);
  box-shadow: 0 0 0 0 rgba(50, 205, 50, 0.7);
  animation: czbot-ping 2s ease-out infinite;
}
.czbot-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.czbot-close:hover {
  background: rgba(255, 255, 255, 0.18);
}
.czbot-close:focus-visible {
  outline: 2px solid var(--czbot-lime-400);
  outline-offset: 2px;
}

/* ---- Message stream ---- */
.czbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--czbot-beige-100);
}

.czbot-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
  animation: czbot-rise 0.26s ease both;
}
@keyframes czbot-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.czbot-msg-user {
  justify-content: flex-end;
}
.czbot-msg-bot {
  justify-content: flex-start;
}
.czbot-msg-bot::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: url("/images/zora-avatar.webp") center / cover;
  flex-shrink: 0;
  align-self: flex-end;
}
.czbot-bubbletext {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.czbot-msg-user .czbot-bubbletext {
  background: var(--czbot-black-900);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.czbot-msg-bot .czbot-bubbletext {
  background: #fff;
  color: var(--czbot-black-900);
  border: 1px solid var(--czbot-border);
  border-bottom-left-radius: 5px;
}

/* ---- CTA ---- */
.czbot-cta {
  align-self: flex-start;
  margin: 2px 0 2px 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--czbot-grad);
  color: var(--czbot-black-900);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(34, 139, 34, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.czbot-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(34, 139, 34, 0.42);
}
.czbot-cta:focus-visible {
  outline: 2px solid var(--czbot-black-900);
  outline-offset: 2px;
}

/* ---- Typing indicator ---- */
.czbot-typing-row .czbot-bubbletext {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px;
}
.czbot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--czbot-lime-500);
  display: inline-block;
  animation: czbot-blink 1.3s infinite ease-in-out both;
}
.czbot-dot:nth-child(2) {
  animation-delay: 0.18s;
}
.czbot-dot:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes czbot-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---- Starter chips ---- */
.czbot-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--czbot-border);
  background: #fff;
}
.czbot-chip {
  border: 1px solid var(--czbot-border);
  background: var(--czbot-beige-100);
  color: var(--czbot-black-900);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease,
    color 0.18s ease;
}
.czbot-chip:hover {
  background: var(--czbot-lime-400);
  border-color: var(--czbot-lime-500);
  color: var(--czbot-black-900);
}
.czbot-chip:focus-visible {
  outline: 2px solid var(--czbot-lime-500);
  outline-offset: 2px;
}

/* ---- Input bar ---- */
.czbot-inputbar {
  display: flex;
  gap: 9px;
  padding: 13px 14px;
  border-top: 1px solid var(--czbot-border);
  background: #fff;
}
.czbot-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--czbot-border);
  border-radius: 999px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--czbot-black-900);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.czbot-input::placeholder {
  color: var(--czbot-gray-400);
}
.czbot-input:focus {
  border-color: var(--czbot-lime-500);
  box-shadow: 0 0 0 3px rgba(50, 205, 50, 0.18);
}
.czbot-input:disabled {
  background: var(--czbot-beige-100);
}
.czbot-send {
  border: none;
  background: var(--czbot-grad);
  color: var(--czbot-black-900);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  min-width: 44px;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.czbot-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(34, 139, 34, 0.38);
}
.czbot-send:focus-visible {
  outline: 2px solid var(--czbot-black-900);
  outline-offset: 2px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .czbot-root {
    right: 1.5rem; /* aligned with .whatsapp-widget mobile */
    bottom: calc(1.5rem + 48px + 0.625rem); /* 1.5rem gap + 48px WA button + 10px spacing */
  }
  .czbot-root.czbot-open {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100dvw;
    height: 100dvh;
  }
  .czbot-bubble img {
    width: 48px;
    height: 48px;
  }
  .czbot-callout {
    display: none;
  }
  .czbot-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    max-width: 100dvw;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    transform-origin: bottom center;
    animation: czbot-slide-up 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .czbot-header {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .czbot-close {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  .czbot-messages {
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .czbot-inputbar {
    padding-bottom: calc(13px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
  }
  .czbot-starters {
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .czbot-bubble::after,
  .czbot-status::before {
    animation: none;
  }
  .czbot-panel,
  .czbot-msg {
    animation: none;
  }
  .czbot-bubble:hover,
  .czbot-cta:hover,
  .czbot-send:hover {
    transform: none;
  }
}
