/* The floating control sits beside ByLaw's return-to-top button. */
#egwalpWidget {
    --egwa-right: max(78px, calc(env(safe-area-inset-right, 0px) + 70px));
    --egwa-bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 12px), var(--egwa-safe-bottom, 0px));
    --egwa-ink: #173c36;
    --egwa-font: var(--wdtFontTypo_Base, "DM Sans", Arial, sans-serif);
    position: fixed;
    z-index: 80;
    right: var(--egwa-right);
    bottom: var(--egwa-bottom);
    width: 46px;
    color: var(--egwa-ink);
    font-family: var(--egwa-font);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
}
#egwalpWidget *, #egwalpWidget *::before, #egwalpWidget *::after { box-sizing: border-box; }
#egwalpWidget button {
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    min-width: 0;
    min-height: 0;
    border: 0;
    border-radius: 50%;
    color: inherit;
    background: transparent;
    box-shadow: none;
    font: inherit;
    cursor: pointer;
    appearance: none;
}
#egwalpWidget button::before, #egwalpWidget button::after { content: none; }
#egwalpWidget :focus-visible { outline: 2px solid #007a5d; outline-offset: 3px; }
#egwalpWidget .egwalp-header :focus-visible { outline-color: #fff; outline-offset: -3px; }
#egwalpWidget .egwalp-icon, #egwalpWidget .egwalp-icon svg { display: block; width: 100%; height: 100%; }
#egwalpWidget .egwalp-icon path { fill: currentColor; }
#egwalpWidget .egwalp-floating-btn {
    width: 46px;
    height: 46px;
    color: #fff;
    background: linear-gradient(145deg, #148757, #086b49);
    border: 1px solid #148d5d;
    box-shadow: 0 4px 14px rgb(9 78 58 / 25%), inset 0 1px 0 rgb(255 255 255 / 20%);
    transition: background-color .18s ease, transform .18s ease;
}
#egwalpWidget .egwalp-floating-btn .egwalp-icon { width: 30px; height: 30px; }
#egwalpWidget .egwalp-floating-btn:hover { transform: translateY(-2px); background: #087247; }
#egwalpWidget .egwalp-chat-window {
    position: absolute;
    right: calc(18px - var(--egwa-right));
    bottom: calc(100% + 12px);
    width: min(335px, calc(100vw - 36px));
    max-height: calc(100vh - var(--egwa-bottom) - 70px);
    max-height: calc(100dvh - var(--egwa-bottom) - 70px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border: 1px solid #d5e4dd;
    border-radius: 18px;
    box-shadow: 0 16px 46px rgb(12 50 40 / 18%), 0 2px 7px rgb(7 60 42 / 8%);
    transform-origin: bottom right;
    animation: egwa-panel-in .18s ease-out;
}
#egwalpWidget .egwalp-chat-window[hidden] { display: none; }
@keyframes egwa-panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#egwalpWidget .egwalp-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 17px 13px 17px 18px;
    background: linear-gradient(110deg, #075e54, #0c6956);
    color: #fff;
}
#egwalpWidget .egwalp-avatar-wrap {
    position: relative;
    overflow: hidden;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border: 1px solid rgb(255 255 255 / 62%);
    border-radius: 50%;
    background: #faf9f4;
}
#egwalpWidget .egwalp-avatar {
    display: block;
    margin: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
}
#egwalpWidget .egwalp-avatar[src*="socio-corbata-roja"] {
    position: absolute;
    top: -16%;
    left: 50%;
    width: 245%;
    height: auto;
    max-width: none;
    transform: translateX(-52%);
}
#egwalpWidget .egwalp-avatar.is-logo { padding: 5px; object-fit: contain; object-position: center; }
#egwalpWidget .egwalp-agent-info { min-width: 0; flex: 1; }
#egwalpWidget .egwalp-agent-name {
    margin: 0;
    color: #fff;
    font-family: var(--wdtFontTypo_Alt, "Cormorant Garamond", Georgia, serif);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -.025em;
    text-transform: none;
}
#egwalpWidget .egwalp-agent-status { margin: 4px 0 0; color: #e2f3eb; font-size: 12px; line-height: 1.35; }
#egwalpWidget .egwalp-close { flex: 0 0 32px; width: 32px; height: 32px; color: #fff; }
#egwalpWidget .egwalp-close:hover { background: rgb(255 255 255 / 14%); }
#egwalpWidget .egwalp-close .egwalp-icon { width: 16px; height: 16px; }
#egwalpWidget .egwalp-body { padding: 16px 18px 19px; background: #f1f5ef; }
#egwalpWidget .egwalp-time { margin: 0 0 9px; color: #4b6459; font-size: 11px; text-align: center; }
#egwalpWidget .egwalp-message {
    width: fit-content;
    margin: 0;
    padding: 12px 15px;
    border-radius: 3px 14px 14px;
    background: #fff;
    color: #233f35;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-line;
    text-align: left;
}
#egwalpWidget .egwalp-input-area { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; background: #fff; }
#egwalpWidget input.egwalp-input {
    display: block;
    flex: 1;
    min-width: 0;
    width: auto;
    height: 41px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #cbd9cf;
    border-radius: 20px;
    background: #fff;
    box-shadow: none;
    color: #203c32;
    font: inherit;
    text-align: left;
}
#egwalpWidget .egwalp-input::placeholder { color: #607168; opacity: 1; }
#egwalpWidget .egwalp-send { flex: 0 0 40px; width: 40px; height: 40px; background: #08724d; color: #fff; }
#egwalpWidget .egwalp-send:hover { background: #075e45; }
#egwalpWidget .egwalp-send .egwalp-icon { width: 18px; height: 18px; }
#egwalpWidget .egwalp-footer { display: flex; justify-content: center; align-items: center; gap: 5px; padding: 0 10px 11px; color: #51655c; font-size: 11px; }
#egwalpWidget .egwalp-footer .egwalp-icon { width: 13px; height: 13px; }
#egwalpWidget .egwalp-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 600px) {
    #egwalpWidget { --egwa-right: max(68px, calc(env(safe-area-inset-right, 0px) + 62px)); width: 44px; }
    #egwalpWidget .egwalp-floating-btn { width: 44px; height: 44px; }
    #egwalpWidget .egwalp-floating-btn .egwalp-icon { width: 28px; height: 28px; }
    #egwalpWidget .egwalp-chat-window { right: calc(12px - var(--egwa-right)); width: min(335px, calc(100vw - 24px)); }
    #egwalpWidget input.egwalp-input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    #egwalpWidget .egwalp-chat-window { animation: none; }
    #egwalpWidget .egwalp-floating-btn { transition: none; }
    #egwalpWidget .egwalp-floating-btn:hover { transform: none; }
}

/* Preview the same widget inside WordPress settings. */
.egwalp-admin-preview {
    box-sizing: border-box;
    width: 100%;
    max-width: 425px;
    margin-block: 12px 24px;
}
.egwalp-admin-preview #egwalp-root[data-preview="1"] {
    position: relative;
    container-type: inline-size;
    min-height: 390px;
    border: 1px solid #d9dfda;
    border-radius: 16px;
    background: linear-gradient(150deg, #fafbf9, #eef3ee);
    isolation: isolate;
}
.egwalp-admin-preview #egwalp-root[data-preview="1"] #egwalpWidget {
    position: absolute;
    z-index: 1;
    right: 16px;
    bottom: 16px;
}
.egwalp-admin-preview #egwalpWidget .egwalp-chat-window {
    right: 0;
    width: min(335px, calc(100cqi - 32px));
    max-height: 292px;
}
