/* ==========================================================================
   WhatsApp widget — BEM (.wa-widget__*), colors from tokens.css with local
   fallbacks so the widget survives even without the token sheet.
   ========================================================================== */

.wa-widget {
  --wa-accent: var(--color-accent, #35566b);
  --wa-accent-hover: var(--color-accent-hover, #274257);
  --wa-surface: var(--color-surface, #ffffff);
  --wa-structure: var(--color-structure, #1d232a);
  --wa-border: var(--color-border, #e3e1db);
  --wa-text: var(--color-text-primary, #24292f);
  --wa-text-secondary: var(--color-text-secondary, #5a6470);
  --wa-text-inverse: var(--color-text-inverse, #ffffff);
  /* Text ON the accent. Distinct from --wa-text-inverse because the accent
     lightens in the dark theme while --wa-structure stays dark. */
  --wa-on-accent: var(--color-on-accent, #ffffff);
  --wa-radius: var(--radius-md, 8px);
  --wa-font: var(--font-body, system-ui, sans-serif);

  position: fixed;
  bottom: 20px;
  z-index: 150;
  font-family: var(--wa-font);
}
.wa-widget--right { right: 20px; }
.wa-widget--left { left: 20px; }

@media (min-width: 640px) {
  .wa-widget { bottom: 28px; }
  .wa-widget--right { right: 28px; }
  .wa-widget--left { left: 28px; }
}

@media (max-width: 767px) {
  .wa-widget--desktop-only { display: none; }
}

/* ---------- FAB (a real wa.me link) ---------- */
.wa-widget__fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  background-color: var(--wa-accent);
  color: var(--wa-on-accent);
  border: 1px solid var(--wa-accent);
  border-radius: 999px;
  padding: 14px;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: background-color 200ms ease, transform 200ms ease;
}
.wa-widget__fab:hover {
  background-color: var(--wa-accent-hover);
  color: var(--wa-on-accent);
}
.wa-widget__fab:focus-visible {
  outline: 2px solid var(--wa-accent);
  outline-offset: 3px;
}

.wa-widget__fab-icon { width: 26px; height: 26px; flex-shrink: 0; }

.wa-widget__fab-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: max-width 250ms ease, opacity 200ms ease, margin 250ms ease;
}
@media (min-width: 768px) {
  .wa-widget__fab { padding: 12px 18px 12px 14px; }
  .wa-widget__fab-label { max-width: 220px; opacity: 1; margin-left: 10px; }
}

.wa-widget__fab-ring {
  position: absolute;
  inset: -1px;
  border-radius: 999px;
  border: 1px solid var(--wa-accent);
  opacity: 0.6;
  animation: wa-widget-ring 3.2s ease-out infinite;
  pointer-events: none;
}
@keyframes wa-widget-ring {
  0%   { transform: scale(1);    opacity: 0.6; }
  70%  { transform: scale(1.25); opacity: 0;   }
  100% { transform: scale(1.25); opacity: 0;   }
}
@media (prefers-reduced-motion: reduce) {
  .wa-widget__fab-ring { animation: none; display: none; }
}

/* ---------- Modal shell ---------- */
.wa-widget__shell {
  position: fixed;
  inset: 0;
  z-index: 160;
}
.wa-widget__shell[hidden] { display: none; }

.wa-widget__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  border: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms ease;
}
.wa-widget__shell.is-open .wa-widget__backdrop { opacity: 1; }

.wa-widget__modal {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(12px);
  width: calc(100% - 1.5rem);
  max-width: 420px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--wa-surface);
  border: 1px solid var(--wa-border);
  border-radius: var(--wa-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.wa-widget--right .wa-widget__modal {
  left: auto;
  right: 20px;
  transform: translateY(12px);
}
.wa-widget--left .wa-widget__modal {
  left: 20px;
  transform: translateY(12px);
}
@media (min-width: 640px) {
  .wa-widget--right .wa-widget__modal { right: 28px; }
  .wa-widget--left .wa-widget__modal { left: 28px; }
}
.wa-widget__shell.is-open .wa-widget__modal {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.wa-widget--right .wa-widget__shell.is-open .wa-widget__modal,
.wa-widget--left .wa-widget__shell.is-open .wa-widget__modal {
  transform: translateY(0);
}

/* ---------- Header ---------- */
.wa-widget__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  background: var(--wa-structure);
  color: var(--wa-text-inverse);
}
.wa-widget__eyebrow {
  margin: 0 0 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
}
.wa-widget__title {
  margin: 0;
  font-family: var(--wa-font);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--wa-text-inverse);
}
.wa-widget__subtitle {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  opacity: 0.75;
  line-height: 1.45;
}
.wa-widget__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  color: var(--wa-text-inverse);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.wa-widget__close:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.5);
}

/* ---------- Body ---------- */
.wa-widget__body { padding: 18px 20px 20px; overflow-y: auto; }

.wa-widget__fieldset { border: 0; padding: 0; margin: 0; }

.wa-widget__label {
  display: block;
  padding: 0;
  margin-bottom: 10px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  /* Foreground on the modal surface — must NOT be --wa-structure, which is an
     always-dark surface colour and would vanish against the dark theme. */
  color: var(--wa-heading, var(--color-heading, #1d232a));
}

.wa-widget__reasons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wa-widget__reason {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--wa-border);
  border-radius: 4px;
  background: var(--wa-surface);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.wa-widget__reason:hover { border-color: var(--wa-accent); }
.wa-widget__reason:has(input:checked) {
  border-color: var(--wa-accent);
  background: color-mix(in srgb, var(--wa-accent) 6%, var(--wa-surface));
}

.wa-widget__reason input {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  border: 1px solid var(--wa-border);
  border-radius: 999px;
  background: var(--wa-surface);
  display: grid;
  place-content: center;
  transition: border-color 150ms ease;
}
.wa-widget__reason input:checked { border-color: var(--wa-accent); }
.wa-widget__reason input:checked::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--wa-accent);
}
.wa-widget__reason input:focus-visible {
  outline: 2px solid var(--wa-accent);
  outline-offset: 2px;
}
.wa-widget__reason-text {
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--wa-text);
}

.wa-widget__other,
.wa-widget__field { margin-top: 14px; }

.wa-widget__field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--wa-text);
}
.wa-widget__body input[type="text"],
.wa-widget__body textarea {
  width: 100%;
  padding: 11px 12px;
  background: var(--wa-surface);
  border: 1px solid var(--wa-border);
  border-radius: 4px;
  color: var(--wa-text);
  outline: none;
  transition: border-color 150ms ease;
}
.wa-widget__body input[type="text"]:focus,
.wa-widget__body textarea:focus { border-color: var(--wa-accent); }
.wa-widget__body textarea { resize: vertical; min-height: 72px; }

.wa-widget__send {
  margin-top: 16px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px 18px;
  background: var(--wa-accent);
  color: var(--wa-on-accent);
  border: 1px solid var(--wa-accent);
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
}
.wa-widget__send:hover:not(:disabled) {
  background: var(--wa-accent-hover);
  border-color: var(--wa-accent-hover);
}
.wa-widget__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
