/* AppSecWarrior live chat — floating widget */
.asw-chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 10090;
  font-family: var(--asw-font-body, "Chivo", "Segoe UI", sans-serif);
  color: var(--asw-ink, #121212);
}

.asw-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 18px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--asw-brand, #ea1e48);
  color: #fff;
  font-family: var(--asw-font-display, "Poppins", sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(234, 30, 72, 0.35);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.asw-chat-launcher:hover {
  background: #c9183d;
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(234, 30, 72, 0.42);
}

.asw-chat-launcher:active {
  transform: translateY(0);
}

.asw-chat-launcher-icon {
  display: inline-flex;
  line-height: 0;
}

.asw-chat-launcher[aria-expanded="true"] .asw-chat-launcher-open,
.asw-chat-launcher[aria-expanded="false"] .asw-chat-launcher-close {
  display: none;
}

.asw-chat-launcher[aria-expanded="true"] .asw-chat-launcher-label {
  display: none;
}

.asw-chat-launcher[aria-expanded="true"] {
  width: 56px;
  padding: 0;
  justify-content: center;
}

.asw-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(56px + 14px);
  width: min(380px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.97), rgba(247, 245, 243, 0.98)),
    #fff;
  border: 1px solid rgba(18, 18, 18, 0.08);
  box-shadow: 0 22px 50px rgba(12, 20, 53, 0.22);
  transform-origin: bottom right;
  animation: aswChatIn 0.28s ease;
}

.asw-chat-panel[hidden] {
  display: none !important;
}

@keyframes aswChatIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.asw-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, #121212 0%, #1f1f21 55%, #2a1218 100%);
  color: #fff;
}

.asw-chat-head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.asw-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  background: #0a0e1a;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.asw-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asw-chat-title {
  margin: 0;
  font-family: var(--asw-font-display, "Poppins", sans-serif);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}

.asw-chat-status {
  margin: 3px 0 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.72);
}

.asw-chat-status.is-online::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #3ddc97;
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.25);
  vertical-align: middle;
}

.asw-chat-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.asw-chat-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.asw-chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  background:
    radial-gradient(circle at 10% 0%, rgba(234, 30, 72, 0.06), transparent 42%),
    #f7f5f3;
}

.asw-chat-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: aswChatBubble 0.25s ease;
}

@keyframes aswChatBubble {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.asw-chat-bubble-bot {
  justify-self: start;
  background: #fff;
  border: 1px solid rgba(18, 18, 18, 0.08);
  color: #1f1f21;
  border-bottom-left-radius: 4px;
}

.asw-chat-bubble-user {
  justify-self: end;
  background: var(--asw-brand, #ea1e48);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.asw-chat-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.asw-chat-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(18, 18, 18, 0.12);
  background: #fff;
  color: #1f1f21;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.asw-chat-chip:hover,
.asw-chat-chip.is-active {
  border-color: rgba(234, 30, 72, 0.55);
  background: rgba(234, 30, 72, 0.08);
  color: var(--asw-brand, #ea1e48);
}

.asw-chat-form {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(18, 18, 18, 0.08);
  background: #fff;
}

.asw-chat-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.asw-chat-form input,
.asw-chat-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(18, 18, 18, 0.14);
  border-radius: 10px;
  background: #fafafa;
  color: #121212;
  font: inherit;
  font-size: 0.88rem;
  resize: vertical;
}

.asw-chat-form input:focus,
.asw-chat-form textarea:focus {
  outline: 2px solid rgba(234, 30, 72, 0.35);
  outline-offset: 1px;
  border-color: rgba(234, 30, 72, 0.45);
  background: #fff;
}

.asw-chat-form-actions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.asw-chat-send {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--asw-brand, #ea1e48);
  color: #fff;
  font-family: var(--asw-font-display, "Poppins", sans-serif);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.asw-chat-send:hover {
  background: #c9183d;
}

.asw-chat-send:disabled {
  opacity: 0.7;
  cursor: wait;
}

.asw-chat-form-note {
  margin: 0;
  font-size: 0.7rem;
  color: #6b6b6b;
  line-height: 1.35;
}

.asw-chat-form-status {
  margin: 8px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.asw-chat-form-status.is-ok {
  color: #0f7a45;
}

.asw-chat-form-status.is-err {
  color: #b42318;
}

.asw-chat .asw-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.asw-chat .screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 520px) {
  .asw-chat {
    right: 12px;
    bottom: 12px;
  }

  .asw-chat-panel {
    width: calc(100vw - 24px);
    max-height: min(70vh, 520px);
  }

  .asw-chat-fields {
    grid-template-columns: 1fr;
  }

  .asw-chat-launcher-label {
    display: none;
  }

  .asw-chat-launcher {
    width: 56px;
    padding: 0;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asw-chat-panel,
  .asw-chat-bubble,
  .asw-chat-launcher {
    animation: none;
    transition: none;
  }
}

/* Keep chat below age/cookie overlays */
body.asw-consent-open .asw-chat,
body.asw-cookie-banner-visible .asw-chat {
  opacity: 0.35;
  pointer-events: none;
}
