/**
 * WhatsApp-style AI chat widget for TryOn.kz landing.
 */
.tkz-chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 180;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Launcher pill — ElevenLabs-style AI chat button (not WhatsApp) */
.tkz-chat__fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  height: 54px;
  padding: 0 1rem 0 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: linear-gradient(145deg, #2a2724 0%, #1c1917 55%, #12100e 100%);
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 14px 40px rgba(28, 25, 23, 0.38),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
  animation: tkzChatFloat 3.2s ease-in-out infinite;
}

.tkz-chat__fab:hover {
  animation: none;
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 18px 48px rgba(28, 25, 23, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.tkz-chat__fab:active {
  transform: translateY(0) scale(0.99);
}

.tkz-chat__fab.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(8px);
  animation: none;
}

.tkz-chat__fab.is-pulse::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.25));
  z-index: -1;
  animation: tkzChatRing 2.4s ease-out infinite;
  opacity: 0.7;
}

@keyframes tkzChatFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes tkzChatRing {
  0% { transform: scale(1); opacity: 0.65; }
  100% { transform: scale(1.12); opacity: 0; }
}

.tkz-chat__fab-icon {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.tkz-chat__fab-bubble {
  display: block;
  opacity: 0.96;
}

.tkz-chat__fab-sparkle {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f5f0e8 0%, #d6d0c7 100%);
  color: #1c1917;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  animation: tkzChatSparkle 2s ease-in-out infinite;
}

@keyframes tkzChatSparkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(8deg); }
}

.tkz-chat__fab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  padding-right: 0.15rem;
  text-align: left;
}

.tkz-chat__fab-title {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
}

.tkz-chat__fab-sub {
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.2;
  white-space: nowrap;
}

.tkz-chat__fab-live {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #4ade80;
  border: 2px solid #1c1917;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
  animation: tkzChatLive 2s ease-out infinite;
}

@keyframes tkzChatLive {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.tkz-chat__fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #faf8f5;
  z-index: 2;
}

.tkz-chat__panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: #ece5dd;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.tkz-chat__panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.tkz-chat__header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  background: #075e54;
  color: #fff;
  flex-shrink: 0;
}

.tkz-chat__header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.tkz-chat__header-info {
  flex: 1;
  min-width: 0;
}

.tkz-chat__header-info strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}

.tkz-chat__header-info span {
  display: block;
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 2px;
}

.tkz-chat__header-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.tkz-chat__header-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.tkz-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.65rem;
  background-color: #ece5dd;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d9d2cb' fill-opacity='0.45'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  -webkit-overflow-scrolling: touch;
}

.tkz-chat__row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.55rem;
  max-width: 88%;
}

.tkz-chat__row.is-bot {
  align-self: flex-start;
  align-items: flex-start;
}

.tkz-chat__row.is-user {
  align-self: flex-end;
  align-items: flex-end;
  margin-left: auto;
}

.tkz-chat__bubble {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.tkz-chat__row.is-bot .tkz-chat__bubble {
  background: #fff;
  color: #111;
  border-top-left-radius: 2px;
}

.tkz-chat__row.is-user .tkz-chat__bubble {
  background: #dcf8c6;
  color: #111;
  border-top-right-radius: 2px;
}

.tkz-chat__time {
  font-size: 0.62rem;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 2px;
  padding: 0 4px;
}

.tkz-chat__bubble--typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-height: 32px;
  padding: 0.55rem 0.75rem;
}

.tkz-chat__bubble--typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: tkzChatDot 1.2s infinite ease-in-out;
}

.tkz-chat__bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.tkz-chat__bubble--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes tkzChatDot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.tkz-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem;
  background: #f0ebe4;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.tkz-chat__quick button,
.tkz-chat__quick a {
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(7, 94, 84, 0.25);
  background: #fff;
  color: #075e54;
  cursor: pointer;
}

.tkz-chat__quick a:hover,
.tkz-chat__quick button:hover {
  background: #e8f5f3;
}

.tkz-chat__lead {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  background: #f7f3ee;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.tkz-chat__lead input {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.78rem;
  background: #fff;
}

.tkz-chat__lead button {
  border: 0;
  border-radius: 8px;
  padding: 0 0.75rem;
  background: #075e54;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tkz-chat__lead button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tkz-chat__composer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem;
  background: #f0f0f0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.tkz-chat__composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font-size: 0.86rem;
  background: #fff;
}

.tkz-chat__composer input:focus {
  outline: 2px solid rgba(7, 94, 84, 0.35);
  outline-offset: 0;
}

.tkz-chat__composer button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.tkz-chat__composer button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 420px) {
  .tkz-chat__fab {
    height: 50px;
    padding: 0 0.75rem 0 0.5rem;
    gap: 0.5rem;
  }

  .tkz-chat__fab-sub {
    display: none;
  }

  .tkz-chat__fab-title {
    font-size: 0.78rem;
  }

  .tkz-chat__fab-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

}

@media (max-width: 480px) {
  .tkz-chat__panel {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: min(92dvh, 640px);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }

  .tkz-chat__panel.is-open {
    transform: translateY(0);
  }

  .tkz-chat__lead {
    grid-template-columns: 1fr;
  }

  .tkz-sticky-cta.is-visible ~ .tkz-chat,
  .tkz-chat {
    bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px));
  }
}
