/* Front customer chat — Light / Dark / SoftWhite share markup; colors are --site-* only. */

.iph-front-chat-fab {
  position: fixed;
  right: max(1.15rem, env(safe-area-inset-right));
  bottom: max(1.15rem, env(safe-area-inset-bottom));
  z-index: 1040;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--site-navy, #0b0454);
  color: var(--site-bg, #f7f7f7);
  box-shadow: 0 0.55rem 1.35rem var(--site-shadow, rgba(11, 4, 84, 0.18));
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.iph-front-chat-fab i {
  font-size: 1.35rem;
  line-height: 1;
}

.iph-front-chat-fab:hover,
.iph-front-chat-fab:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.iph-front-chat-fab:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-navy, #0b0454) 35%, transparent);
}

body:has(#iphFrontChatOffcanvas.show) .iph-front-chat-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.offcanvas.iph-front-chat-offcanvas {
  width: min(100vw, 26rem);
  background: var(--site-surface, #fff);
  color: var(--site-text, #1a1a1a);
  border-left: 1px solid var(--site-border, rgba(11, 4, 84, 0.12));
  box-shadow: -0.75rem 0 2rem var(--site-shadow, rgba(11, 4, 84, 0.08));
}

.iph-front-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: var(--site-surface, #fff);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--site-navy, #0b0454) 12%, var(--site-surface, #fff)),
    var(--site-surface, #fff)
  );
  border-bottom: 1px solid var(--site-border, rgba(11, 4, 84, 0.12));
}

.iph-front-chat-mark {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--site-navy, #0b0454);
  color: var(--site-bg, #f7f7f7);
  font-size: 1.1rem;
}

.iph-front-chat-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.iph-front-chat-offcanvas .offcanvas-title {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--site-text, #1a1a1a);
}

.iph-front-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--site-text-muted, #6c757d);
}

.iph-front-chat-status::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--site-wa, #25d366);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-wa, #25d366) 28%, transparent);
  flex: none;
}

.iph-front-chat-status[data-status="WaitingHuman"]::before {
  background: var(--site-accent, #c52d2f);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-accent, #c52d2f) 28%, transparent);
}

.iph-front-chat-status[data-status="HumanActive"]::before {
  background: var(--site-navy, #0b0454);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-navy, #0b0454) 22%, transparent);
}

.iph-front-chat-status[data-status="Closed"]::before {
  background: var(--site-text-muted, #6c757d);
  box-shadow: none;
}

.iph-front-chat-close {
  flex: none;
  opacity: 0.72;
}

.iph-front-chat-offcanvas .offcanvas-body {
  min-height: 0;
  background: var(--site-bg, #f7f7f7);
}

.iph-front-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 0.9rem 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--site-border-strong, rgba(11, 4, 84, 0.2)) transparent;
}

.iph-front-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  max-width: 100%;
}

.iph-front-chat-row--user {
  justify-content: flex-end;
}

.iph-front-chat-row--assistant {
  justify-content: flex-start;
}

.iph-front-chat-row--system {
  justify-content: center;
}

.iph-front-chat-row.is-enter {
  animation: iph-front-chat-in 0.28s ease;
}

.iph-front-chat-avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: color-mix(in srgb, var(--site-navy, #0b0454) 14%, var(--site-surface, #fff));
  color: var(--site-navy, #0b0454);
  border: 1px solid var(--site-border, rgba(11, 4, 84, 0.12));
  font-size: 0.8rem;
}

.iph-front-chat-bubble {
  max-width: min(82%, 19.5rem);
  margin: 0;
  padding: 0.62rem 0.8rem;
  border-radius: 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.925rem;
  line-height: 1.5;
}

.iph-front-chat-bubble--user {
  border-bottom-right-radius: 0.35rem;
  background: var(--site-navy, #0b0454);
  color: var(--site-bg, #f7f7f7);
}

.iph-front-chat-bubble--assistant {
  border-bottom-left-radius: 0.35rem;
  background: var(--site-surface, #fff);
  color: var(--site-text, #1a1a1a);
  border: 1px solid var(--site-border, rgba(11, 4, 84, 0.12));
  box-shadow: 0 1px 2px var(--site-shadow, rgba(11, 4, 84, 0.06));
}

.iph-front-chat-bubble--system {
  max-width: 90%;
  background: transparent;
  border: 1px dashed var(--site-border-strong, rgba(11, 4, 84, 0.2));
  color: var(--site-text-muted, #6c757d);
  font-size: 0.78rem;
  text-align: center;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
}

.iph-front-chat-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--site-text-muted, #6c757d);
}

.iph-front-chat-stars button {
  border: none;
  background: transparent;
  padding: 0;
  line-height: 1;
  color: var(--site-text-muted, #6c757d);
  cursor: pointer;
}

.iph-front-chat-stars button.is-on {
  color: var(--site-accent, #c52d2f);
}

.iph-front-chat-best.is-on {
  font-weight: 600;
  color: var(--site-navy, #0b0454);
}

.iph-front-chat-load-older {
  text-align: center;
  font-size: 0.75rem;
  color: var(--site-text-muted, #6c757d);
  padding: 0.2rem 0 0.65rem;
}

.iph-front-chat-composer {
  flex: none;
  padding: 0.55rem 0.85rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--site-surface, #fff);
  border-top: 1px solid var(--site-border, rgba(11, 4, 84, 0.12));
}

.iph-front-chat-emoji {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.15rem;
  margin-bottom: 0.45rem;
}

.iph-front-chat-emoji button {
  border: 0;
  margin: 0;
  padding: 0.15rem 0;
  border-radius: 0.55rem;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1.35;
  cursor: pointer;
}

.iph-front-chat-emoji button:hover:not(:disabled),
.iph-front-chat-emoji button:focus-visible {
  background: color-mix(in srgb, var(--site-navy, #0b0454) 12%, var(--site-bg, #f7f7f7));
  outline: none;
}

.iph-front-chat-emoji button:disabled {
  opacity: 0.4;
  cursor: default;
}

.iph-front-chat-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  border: 1px solid var(--site-border-strong, rgba(11, 4, 84, 0.2));
  border-radius: 1.15rem;
  background: var(--site-bg, #f7f7f7);
}

.iph-front-chat-composer-box:focus-within {
  border-color: var(--site-navy, #0b0454);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-navy, #0b0454) 20%, transparent);
}

.iph-front-chat-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 2.45rem;
  max-height: 7.5rem;
  margin: 0;
  padding: 0.45rem 0;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--site-text, #1a1a1a);
  box-shadow: none;
  line-height: 1.45;
}

.iph-front-chat-input:focus {
  outline: none;
  box-shadow: none;
}

.iph-front-chat-input::placeholder {
  color: var(--site-text-muted, #6c757d);
}

.iph-front-chat-send {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.45rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--site-navy, #0b0454);
  color: var(--site-bg, #f7f7f7);
  font-weight: 650;
  line-height: 1;
}

.iph-front-chat-send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.iph-front-chat-send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-navy, #0b0454) 28%, transparent);
}

.iph-front-chat-send:disabled,
.iph-front-chat-send.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.iph-front-chat-pending {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--site-text-muted, #6c757d);
}

.iph-front-chat-pending-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}

.iph-front-chat-pending-dots span {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: iph-front-chat-dot 1.2s infinite ease-in-out;
}

.iph-front-chat-pending-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.iph-front-chat-pending-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes iph-front-chat-in {
  from { opacity: 0; transform: translateY(0.35rem); }
  to { opacity: 1; transform: none; }
}

@keyframes iph-front-chat-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-0.15rem); }
}

html[data-appearance="dark"] .iph-front-chat-offcanvas .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

@media (max-width: 575.98px) {
  .offcanvas.iph-front-chat-offcanvas {
    width: 100%;
    border-left: 0;
  }

  .iph-front-chat-send-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .iph-front-chat-send {
    width: 2.45rem;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .iph-front-chat-fab,
  .iph-front-chat-row.is-enter,
  .iph-front-chat-pending-dots span {
    animation: none;
    transition: none;
  }
}
