/*
 * Sensei WhatsApp Chat.
 *
 * Every default is wrapped in :where() so it has the specificity of a single class at most: any design
 * setting (printed on the module's order class) wins, whatever order the stylesheets load in.
 * Custom properties are scoped to .ds-wa, never :root:
 *   --ds-wa-offset-x / -y  Horizontal / Vertical Offset of the floating widget (widget.advanced.offsetX/Y)
 *   --ds-wa-align          Inline alignment (widget.advanced.alignment): flex-start | center | flex-end
 *   --ds-wa-box-margin     the matching inline margin of the inline chat box: 0 auto | auto | auto 0
 * Floating: .ds-wa is position: fixed; public/js/WhatsAppChat.js lifts it into the top layer (popover) so
 * transforms/filters/animations on any ancestor cannot re-anchor it. Logical properties mirror it on RTL sites.
 */

/*
 * Floating: the module wrapper leaves no gap in the layout — out of flow, so it is no flex/grid item either
 * (no column gap). !important: the wrapper's own Position/Sizing/Spacing settings must not bring the gap back.
 */
.ds_whatsapp_chat.ds_whatsapp_chat--floating {
    position: absolute !important;
    width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
}

:where(.ds_whatsapp_chat) .ds-wa,
:where(.ds_whatsapp_chat) .ds-wa *,
:where(.ds_whatsapp_chat) .ds-wa *::before,
:where(.ds_whatsapp_chat) .ds-wa *::after {
    box-sizing: border-box;
}

:where(.ds_whatsapp_chat) .ds-wa {
    --ds-wa-offset-x: 20px;
    --ds-wa-offset-y: 20px;
    --ds-wa-online: #25d366; /* These three: Status Dot defaults, mirrored in module.json statusDot defaultPrintedStyle. */
    --ds-wa-offline: #a0a7ad;
    --ds-wa-dot-size: 12px;
    --ds-wa-focus: #25d366; /* Fields Focus Color default, mirrored in module.json field defaultPrintedStyle. */
    --ds-wa-align: flex-start;
    display: flex;
    gap: 16px;
    font-size: 16px;
    line-height: 1.4;
    text-align: start;
}

/* Floating widget: overrides the UA [popover] styles (inset, margin, border, padding, colors, overflow) too. */
:where(.ds_whatsapp_chat) .ds-wa--floating {
    position: fixed;
    z-index: 2147483000;
    inset: auto;
    inset-block-end: var(--ds-wa-offset-y);
    inset-inline-end: var(--ds-wa-offset-x);
    flex-direction: column;
    align-items: flex-end;
    width: auto;
    max-width: calc(100vw - 2 * var(--ds-wa-offset-x));
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
    /* Only the button and the open box take clicks; the page underneath stays clickable. */
    pointer-events: none;
}

:where(.ds_whatsapp_chat) .ds-wa--floating > * {
    pointer-events: auto;
}

/* Inline widget: the chat box drops down over the following content, or opens upwards (Chat Box Position). */
:where(.ds_whatsapp_chat) .ds-wa--inline {
    position: relative;
    flex-direction: row;
    justify-content: var(--ds-wa-align);
}

/* Absolute with both inline insets at 0 and a set width: the auto margin aligns it like the button. */
:where(.ds_whatsapp_chat) .ds-wa--inline .ds-wa__box {
    position: absolute;
    z-index: 999;
    inset-block-start: var(--ds-wa-box-start, calc(100% + 12px));
    inset-block-end: var(--ds-wa-box-end, auto);
    inset-inline: 0;
    margin-inline: var(--ds-wa-box-margin, 0 auto);
}

/* Button ---------------------------------------------------------------- */

:where(.ds_whatsapp_chat) .ds-wa__button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: none;
    min-width: 56px;
    min-height: 56px;
    margin: 0;
    /* Padding, radius, background and shadow: Button Style defaults, mirrored in module.json button defaultPrintedStyle. */
    padding: 14px;
    border: 0;
    border-radius: 999px;
    background-color: #25d366;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

:where(.ds_whatsapp_chat) .ds-wa__button:hover {
    transform: translateY(-2px);
}

:where(.ds_whatsapp_chat) .ds-wa__button:focus-visible,
:where(.ds_whatsapp_chat) .ds-wa__send:focus-visible,
:where(.ds_whatsapp_chat) .ds-wa__close:focus-visible {
    outline: 3px solid #128c7e;
    outline-offset: 3px;
}

:where(.ds_whatsapp_chat) .ds-wa__icon {
    display: inline-flex;
    flex: none;
    width: 28px; /* Icon Size / Color defaults: mirrored in module.json icon defaultPrintedStyle. */
    height: 28px;
    color: inherit;
}

:where(.ds_whatsapp_chat) .ds-wa__icon svg,
:where(.ds_whatsapp_chat) .ds-wa__close svg,
:where(.ds_whatsapp_chat) .ds-wa__send svg {
    display: block;
    width: 100%;
    height: 100%;
}

:where(.ds_whatsapp_chat) .ds-wa__label {
    display: inline-block;
    padding-inline-end: 6px;
    white-space: nowrap;
}

/*
 * Label: On Hover — collapsed, but still read by screen readers (no display: none).
 * The label sits in a 0fr → 1fr grid track, so it grows to exactly its own width (a max-width cap would finish
 * early on expand and stall on collapse). It stays one line tall throughout, so the button height never moves.
 */
:where(.ds_whatsapp_chat) .ds-wa--label-hover .ds-wa__button {
    display: inline-grid;
    grid-template-columns: auto 0fr;
    column-gap: 0;
    transition: grid-template-columns 0.3s ease, column-gap 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

:where(.ds_whatsapp_chat) .ds-wa--label-hover .ds-wa__button:hover,
:where(.ds_whatsapp_chat) .ds-wa--label-hover .ds-wa__button:focus-visible {
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    /* The label growing out is the hover effect here; the lift on top of it reads as a jump in size. */
    transform: none;
}

:where(.ds_whatsapp_chat) .ds-wa--label-hover .ds-wa__label {
    min-width: 0;
    padding-inline-end: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, padding 0.3s ease;
}

:where(.ds_whatsapp_chat) .ds-wa--label-hover .ds-wa__button:hover .ds-wa__label,
:where(.ds_whatsapp_chat) .ds-wa--label-hover .ds-wa__button:focus-visible .ds-wa__label {
    padding-inline-end: 6px;
    opacity: 1;
}

/* Label: Never — icon only, the label stays the accessible name. */
:where(.ds_whatsapp_chat) .ds-wa--label-hidden .ds-wa__label,
:where(.ds_whatsapp_chat) .ds-wa__offline,
:where(.ds_whatsapp_chat) .ds-wa__live,
:where(.ds_whatsapp_chat) .ds-wa:not(.ds-wa--field-labels) .ds-wa-field__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* One Agent, direct link, offline and chatting while offline not allowed: greyed out like a list entry; its offline
   text (tooltip) is read only then. */
:where(.ds_whatsapp_chat) .ds-wa__button[aria-disabled="true"] {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.6;
}

:where(.ds_whatsapp_chat) .ds-wa__button[aria-disabled="true"]:hover {
    transform: none;
}

:where(.ds_whatsapp_chat) .ds-wa__button:not([aria-disabled="true"]) .ds-wa__offline {
    display: none;
}

/* Background, padding, border and radius are Badge Style defaults (module.json badge default); flex keeps the count centred whatever they are. */
:where(.ds_whatsapp_chat) .ds-wa__badge {
    position: absolute;
    inset-block-start: -6px;
    inset-inline-end: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    min-height: 26px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

:where(.ds_whatsapp_chat) .ds-wa--seen .ds-wa__badge {
    display: none;
}

/* Chat box -------------------------------------------------------------- */

:where(.ds_whatsapp_chat) .ds-wa__box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
    overflow: hidden;
    border-radius: 16px;
    background-color: #fff;
    color: #111b21;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22); /* Mirrored in module.json chatBox defaultPrintedStyle. */
    font-size: 15px;
}

/* Inline, the box drops down within the module: no wider than its column (360px fits most). After the base rule,
   with the specificity of a single class, so Chat Box > Sizing still wins. */
:where(.ds_whatsapp_chat .ds-wa--inline) .ds-wa__box {
    max-width: min(100%, calc(100vw - 32px));
}

:where(.ds_whatsapp_chat) .ds-wa__box[hidden] {
    display: none;
}

:where(.ds_whatsapp_chat) .ds-wa--open .ds-wa__box {
    animation: ds-wa-open 0.2s ease-out;
}

@keyframes ds-wa-open {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

:where(.ds_whatsapp_chat) .ds-wa__header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
    min-height: 56px;
    padding: 14px 16px;
    background-color: #075e54;
    color: #fff;
}

:where(.ds_whatsapp_chat) .ds-wa__avatar {
    display: block;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

:where(.ds_whatsapp_chat) .ds-wa__heading {
    flex: 1 1 auto;
    min-width: 0;
}

:where(.ds_whatsapp_chat) .ds-wa__name {
    color: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

:where(.ds_whatsapp_chat) .ds-wa__status {
    color: inherit;
    font-size: 13px;
    line-height: 1.3;
    opacity: 0.85;
}

:where(.ds_whatsapp_chat) .ds-wa__close,
:where(.ds_whatsapp_chat) .ds-wa__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    margin: 0 -6px 0 auto;
    margin-inline: auto -6px;
    padding: 6px;
    border: 0;
    border-radius: 50%;
    background-color: transparent;
    color: inherit; /* White by default: Close & Back Icon Color default in module.json closeButton defaultPrintedStyle. */
    cursor: pointer;
    transition: background-color 0.2s ease;
}

:where(.ds_whatsapp_chat) .ds-wa__close:hover,
:where(.ds_whatsapp_chat) .ds-wa__back:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* The button is its icon plus the padding (32px by default), so Close & Back Icon Size can grow it. */
:where(.ds_whatsapp_chat) .ds-wa__close svg,
:where(.ds_whatsapp_chat) .ds-wa__back svg {
    flex: none;
    width: 20px; /* Close & Back Icon Size default: mirrored in module.json closeButton defaultPrintedStyle. */
    height: 20px;
}

/* The back button sits at the start of the header; its arrow points the other way on RTL sites. */
:where(.ds_whatsapp_chat) .ds-wa__back {
    margin: 0;
    margin-inline: -6px 0;
}

:where(.ds_whatsapp_chat) .ds-wa__back:dir(rtl) svg {
    transform: scaleX(-1);
}

:where(.ds_whatsapp_chat) .ds-wa__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 20px 16px 16px;
    overflow-y: auto;
    background-color: #efeae2;
}

:where(.ds_whatsapp_chat) .ds-wa__greeting {
    position: relative;
    align-self: flex-start;
    max-width: 88%;
    margin-inline-start: 8px;
    border-radius: 0 8px 8px 8px;
    border-start-start-radius: 0;
    border-start-end-radius: 8px;
    color: #111b21;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Bubble tail: takes the bubble's background color. */
:where(.ds_whatsapp_chat) .ds-wa__greeting::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: -8px;
    width: 8px;
    height: 13px;
    background: inherit;
    background-clip: border-box;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

:where(.ds_whatsapp_chat) .ds-wa__greeting:dir(rtl)::before {
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

:where(.ds_whatsapp_chat) .ds-wa__fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

:where(.ds_whatsapp_chat) .ds-wa__fields:empty {
    display: none;
}

/* Agent list ------------------------------------------------------------ */

:where(.ds_whatsapp_chat) .ds-wa__list-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: none;
    padding: 18px 16px 18px 20px;
    padding-inline: 20px 16px;
    background-color: #075e54;
    color: #fff;
}

:where(.ds_whatsapp_chat) .ds-wa__list-avatar {
    display: block;
    flex: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

:where(.ds_whatsapp_chat) .ds-wa__list-heading {
    flex: 1 1 auto;
    min-width: 0;
}

:where(.ds_whatsapp_chat) .ds-wa__list-title {
    color: inherit;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
}

:where(.ds_whatsapp_chat) .ds-wa__list-intro {
    margin-top: 4px;
    color: inherit;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0.9;
    white-space: pre-line;
}

:where(.ds_whatsapp_chat) .ds-wa__agents {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* !important: Divi's column rules (e.g. .et_pb_gutters3 .et_pb_column_1_2.et_block_column .et_pb_module) add a
   margin-bottom to every module; Agents have no Spacing settings, so nothing of ours is overridden. */
:where(.ds_whatsapp_chat) .ds-wa__agents > * {
    margin: 0 !important;
}

:where(.ds_whatsapp_chat) .ds-wa-agent {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 0;
    /* Padding, border and background (with :hover): Item Style defaults, mirrored in module.json listItem defaultPrintedStyle. */
    padding: 14px 16px;
    border: 0;
    border-bottom: 1px solid #f0f2f5;
    background-color: #fff;
    color: #111b21;
    font: inherit;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__item:hover {
    background-color: #f5f6f6;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__item:focus-visible {
    outline: 3px solid #128c7e;
    outline-offset: -3px;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__avatar {
    display: block;
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__avatar--glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background-color: #25d366;
    color: #fff;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__avatar--glyph svg {
    display: block;
    width: 100%;
    height: 100%;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__role {
    color: #667781;
    font-size: 12px;
    line-height: 1.3;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

/*
 * List or chat window (behavior, so not in :where()): one Agent shows its chat window; two or more (--multi)
 * show the list until an Agent is opened (--agent-open + --active, public/js/WhatsAppChat.js / edit.jsx).
 */
.ds-wa .ds-wa-agent__panel {
    display: none;
}

.ds-wa:not(.ds-wa--multi) .ds-wa-agent__panel,
.ds-wa .ds-wa-agent--active .ds-wa-agent__panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.ds-wa:not(.ds-wa--multi) .ds-wa-agent__item,
.ds-wa:not(.ds-wa--multi) .ds-wa__back,
.ds-wa.ds-wa--agent-open .ds-wa__list-header,
.ds-wa.ds-wa--agent-open .ds-wa-agent__item,
.ds-wa.ds-wa--agent-open .ds-wa-agent:not(.ds-wa-agent--active) {
    display: none;
}

/* A chat window scrolls its own body. */
.ds-wa:not(.ds-wa--multi) .ds-wa__agents,
.ds-wa.ds-wa--agent-open .ds-wa__agents {
    overflow: hidden;
}

/*
 * Online status ---------------------------------------------------------
 * .ds-wa-agent--online / --offline come from the Agent's Availability (PHP first, public/js/WhatsAppChat.js every
 * minute). The dot and the screen reader text only with Show Online Status (.ds-wa--status); the offline look and
 * the "Available from …" line always. The greyed-out look only for --blocked: offline and chatting while offline is
 * not allowed; an offline Agent that allows chatting looks normal apart from its dot and line.
 */

:where(.ds_whatsapp_chat) .ds-wa-agent__avatar-wrap {
    position: relative;
    display: inline-flex;
    flex: none;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__dot {
    position: absolute;
    inset-block-end: 1px;
    inset-inline-end: 1px;
    width: var(--ds-wa-dot-size);
    height: var(--ds-wa-dot-size);
    border: 2px solid #fff; /* Mirrored in module.json statusDot defaultPrintedStyle. */
    border-radius: 50%;
    background-color: var(--ds-wa-offline);
}

:where(.ds_whatsapp_chat) .ds-wa-agent--online .ds-wa-agent__dot {
    background-color: var(--ds-wa-online);
}

:where(.ds_whatsapp_chat) .ds-wa-agent__availability {
    color: inherit;
    font-size: 12px;
    font-style: italic;
    line-height: 1.3;
    opacity: 0.8;
}

:where(.ds_whatsapp_chat) .ds-wa-agent--blocked .ds-wa-agent__item {
    background-color: #f7f8f9;
}

:where(.ds_whatsapp_chat) .ds-wa-agent--blocked .ds-wa-agent__avatar,
:where(.ds_whatsapp_chat) .ds-wa-agent--blocked .ds-wa-agent__text {
    opacity: 0.55;
}

:where(.ds_whatsapp_chat) .ds-wa-agent--blocked .ds-wa-agent__avatar {
    filter: grayscale(1);
}

:where(.ds_whatsapp_chat) .ds-wa-agent__item[aria-disabled="true"],
:where(.ds_whatsapp_chat) .ds-wa__send:disabled {
    cursor: not-allowed;
}

:where(.ds_whatsapp_chat) .ds-wa__send:disabled {
    opacity: 0.5;
}

:where(.ds_whatsapp_chat) .ds-wa-agent__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Behavior (not in :where()): which parts show for the current state. */
.ds-wa:not(.ds-wa--status) .ds-wa-agent__dot,
.ds-wa:not(.ds-wa--status) .ds-wa-agent__sr,
.ds-wa .ds-wa-agent--online .ds-wa-agent__availability,
.ds-wa .ds-wa-agent--online .ds-wa-agent__sr--offline,
.ds-wa .ds-wa-agent--offline .ds-wa-agent__sr--online {
    display: none;
}

/* Fields ---------------------------------------------------------------- */

:where(.ds_whatsapp_chat) .ds-wa-field {
    margin: 0;
}

:where(.ds_whatsapp_chat) .ds-wa-field__label {
    display: block;
    margin: 0 0 4px;
    color: #3b4a54;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

:where(.ds_whatsapp_chat) .ds-wa-field--required .ds-wa-field__label::after {
    content: " *";
    color: #b3261e;
}

/*
 * "form <tag>.ds-wa-field__input" has the specificity (0,1,2), its states (0,2,2): above the theme's own
 * input[type=text] / select / textarea rules (0,1,1) and their :focus (0,2,1), which otherwise restyle the text input,
 * and still below the Fields design settings on the module's order class (0,2,0) / (0,3,0).
 */
:where(.ds_whatsapp_chat) form input.ds-wa-field__input,
:where(.ds_whatsapp_chat) form textarea.ds-wa-field__input,
:where(.ds_whatsapp_chat) form select.ds-wa-field__input {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 44px;
    margin: 0;
    padding: 11px 14px;
    background-color: #fff;
    color: #111b21;
    font: inherit;
    /* 16px: iOS Safari zooms the page into any focused field set smaller. */
    font-size: 16px;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

:where(.ds_whatsapp_chat) form textarea.ds-wa-field__input {
    min-height: 96px;
    resize: vertical;
}

/*
 * Dropdown: the native arrow is replaced by a chevron that sits as far from the end edge as the text sits from the
 * start edge (14px), so the two mirror each other; on RTL sites both swap sides.
 */
:where(.ds_whatsapp_chat) form select.ds-wa-field__input {
    padding-inline-end: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 12 8%27%3E%3Cpath fill=%27none%27 stroke=%27%2354656f%27 stroke-width=%271.6%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M1 1.5l5 5 5-5%27/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    cursor: pointer;
}

:where(.ds_whatsapp_chat) form select.ds-wa-field__input:dir(rtl) {
    background-position: left 14px center;
}

/*
 * The open list. A native <select> popup cannot be styled; browsers with customizable selects (appearance:
 * base-select — Chromium 134+) get a card that matches the chat box, all others keep the native list. Still a native
 * <select>: keyboard, screen readers and form behavior are unchanged, no JS.
 */
@supports (appearance: base-select) {
    :where(.ds_whatsapp_chat) form select.ds-wa-field__input,
    :where(.ds_whatsapp_chat) form select.ds-wa-field__input::picker(select) {
        appearance: base-select;
    }

    /* The field keeps its own chevron (background image above). */
    :where(.ds_whatsapp_chat) form select.ds-wa-field__input::picker-icon {
        display: none;
    }

    :where(.ds_whatsapp_chat) form select.ds-wa-field__input::picker(select) {
        margin-block: 6px;
        padding: 6px;
        border: 1px solid #e2e6e9;
        border-radius: 12px;
        background-color: #fff;
        color: #111b21;
        box-shadow: 0 12px 32px rgba(11, 20, 26, 0.16);
    }

    :where(.ds_whatsapp_chat) form select.ds-wa-field__input option {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 8px;
        font-size: 14px;
        line-height: 1.4;
        cursor: pointer;
    }

    :where(.ds_whatsapp_chat) form select.ds-wa-field__input option:hover,
    :where(.ds_whatsapp_chat) form select.ds-wa-field__input option:focus-visible {
        background-color: #f0f2f5;
        outline: none;
    }

    :where(.ds_whatsapp_chat) form select.ds-wa-field__input option:checked {
        background-color: rgba(37, 211, 102, 0.12);
        color: #075e54;
        font-weight: 600;
    }

    /* The checkmark at the end of the selected option. */
    :where(.ds_whatsapp_chat) form select.ds-wa-field__input option::checkmark {
        order: 1;
        margin-inline-start: auto;
        color: #25d366;
    }

    /* The empty first entry (the placeholder). */
    :where(.ds_whatsapp_chat) form select.ds-wa-field__input option[value=""] {
        color: #667781;
        font-weight: 400;
    }
}

:where(.ds_whatsapp_chat) form input.ds-wa-field__input::placeholder,
:where(.ds_whatsapp_chat) form textarea.ds-wa-field__input::placeholder,
:where(.ds_whatsapp_chat) form select.ds-wa-field__input::placeholder {
    /* 4.5:1 on the white field - with Show Label off (the default) it's the only visible label. */
    color: #667781;
    opacity: 1;
}

:where(.ds_whatsapp_chat) form input.ds-wa-field__input:focus,
:where(.ds_whatsapp_chat) form textarea.ds-wa-field__input:focus,
:where(.ds_whatsapp_chat) form select.ds-wa-field__input:focus {
    border-color: var(--ds-wa-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-wa-focus) 20%, transparent);
}

:where(.ds_whatsapp_chat) form input.ds-wa-field__input[aria-invalid="true"],
:where(.ds_whatsapp_chat) form textarea.ds-wa-field__input[aria-invalid="true"],
:where(.ds_whatsapp_chat) form select.ds-wa-field__input[aria-invalid="true"] {
    border-color: #d93025;
}

:where(.ds_whatsapp_chat) form input.ds-wa-field__input[aria-invalid="true"]:focus,
:where(.ds_whatsapp_chat) form textarea.ds-wa-field__input[aria-invalid="true"]:focus,
:where(.ds_whatsapp_chat) form select.ds-wa-field__input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.15);
}

@media (prefers-reduced-motion: reduce) {
    :where(.ds_whatsapp_chat) form .ds-wa-field__input {
        transition: none;
    }
}

:where(.ds_whatsapp_chat) .ds-wa-field__error {
    margin: 4px 0 0;
    /* 4.5:1 on the chat background (#efeae2). */
    color: #b3261e;
    font-size: 12px;
    line-height: 1.3;
}

:where(.ds_whatsapp_chat) .ds-wa-field__error[hidden] {
    display: none;
}

/* Chat button ----------------------------------------------------------- */

:where(.ds_whatsapp_chat) .ds-wa__send {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    border: 0;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

:where(.ds_whatsapp_chat) .ds-wa__send svg {
    flex: none;
    width: 20px;
    height: 20px;
}

@media (prefers-reduced-motion: reduce) {
    :where(.ds_whatsapp_chat) .ds-wa__button,
    :where(.ds_whatsapp_chat) .ds-wa__label,
    :where(.ds_whatsapp_chat) .ds-wa__send,
    :where(.ds_whatsapp_chat) .ds-wa__close {
        transition: none;
    }

    :where(.ds_whatsapp_chat) .ds-wa__button:hover {
        transform: none;
    }

    :where(.ds_whatsapp_chat) .ds-wa--open .ds-wa__box {
        animation: none;
    }
}

/*
 * Sensei WhatsApp Chat: Visual Builder only (imported by edit.jsx, so it never ships to the frontend stylesheet).
 */

/* Visual Builder only: hint when there is no usable number, and the in-flow handle of a floating widget. */
:where(.ds_whatsapp_chat) .ds-wa-vb-hint,
:where(.ds_whatsapp_chat) .ds-wa-vb-handle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px dashed #25d366;
    border-radius: 8px;
    background-color: rgba(37, 211, 102, 0.08);
    color: #075e54;
    font-size: 13px;
    line-height: 1.4;
}

:where(.ds_whatsapp_chat) .ds-wa-vb-hint svg,
:where(.ds_whatsapp_chat) .ds-wa-vb-handle svg {
    flex: none;
    width: 18px;
    height: 18px;
    color: #25d366;
}

/*
 * Visual Builder: Divi makes everything inside a module click-through until it is edited (its mousetrap takes the
 * clicks), but a floating button lies outside the module's box. Let clicks reach it (edit.jsx opens the settings).
 */
#page-container .et-fb-root-area .ds-wa--floating[data-ds-wa-vb] .ds-wa__button {
    pointer-events: auto;
}

/* In the Visual Builder the floating wrapper keeps its handle (or the hint) in the layout so it stays selectable. */
.ds_whatsapp_chat.ds_whatsapp_chat--floating:has(.ds-wa-vb-handle, .ds-wa-vb-hint) {
    position: relative !important;
    width: auto !important;
    height: auto !important;
}

