/**
 * Smartphone Italia — floating WhatsApp operator button + message panel (20260710-whatsapp-panel)
 * Uses si-responsive.css chat/bottom-nav tokens for stacking.
 */

#si-whatsapp-widget,
.si-whatsapp-widget {
    position: fixed;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: var(--si-chat-bottom-desktop);
    z-index: 99988;
}

#si-whatsapp-float,
.si-whatsapp-float {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.45);
    cursor: pointer;
    transition: transform var(--si-transition, 0.3s ease), box-shadow var(--si-transition, 0.3s ease), background var(--si-transition, 0.3s ease);
    -webkit-tap-highlight-color: transparent;
}

#si-whatsapp-float:hover,
#si-whatsapp-float:focus-visible,
.si-whatsapp-float:hover,
.si-whatsapp-float:focus-visible {
    background: #1ebe57;
    color: #fff;
    transform: scale(1.06);
    box-shadow: 0 6px 22px rgba(37, 211, 102, 0.5);
    outline: none;
}

#si-whatsapp-float[aria-expanded="true"],
.si-whatsapp-float[aria-expanded="true"] {
    background: #1ebe57;
    transform: scale(1.02);
}

.si-whatsapp-float__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.si-whatsapp-float__icon svg {
    display: block;
}

.si-whatsapp-panel {
    position: absolute;
    right: 0;
    bottom: calc(56px + 12px);
    width: min(320px, calc(100vw - 32px));
    padding: 16px;
    border-radius: 14px;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.si-whatsapp-panel.si-whatsapp-panel--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.si-whatsapp-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.si-whatsapp-panel__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: #128c7e;
}

.si-whatsapp-panel__title-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    flex-shrink: 0;
}

.si-whatsapp-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #666;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.si-whatsapp-panel__close:hover,
.si-whatsapp-panel__close:focus-visible {
    background: #f0f0f0;
    color: #333;
    outline: none;
}

.si-whatsapp-panel__hint {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.4;
    color: #555;
}

.si-whatsapp-panel__input {
    display: block;
    width: 100%;
    min-height: 96px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #d8e8de;
    border-radius: 10px;
    background: #f9fdfb;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.si-whatsapp-panel__input::placeholder {
    color: #8a9a90;
}

.si-whatsapp-panel__input:focus {
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
    outline: none;
}

.si-whatsapp-panel__send {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    background: #25d366;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.si-whatsapp-panel__send:hover,
.si-whatsapp-panel__send:focus-visible {
    background: #1ebe57;
    outline: none;
}

.si-whatsapp-panel__send:active {
    transform: scale(0.98);
}

.si-whatsapp-panel__send:disabled,
.si-whatsapp-panel__send[aria-disabled="true"] {
    background: #a8dcc0;
    cursor: not-allowed;
    transform: none;
}

.si-whatsapp-panel__send:disabled:hover,
.si-whatsapp-panel__send:disabled:focus-visible,
.si-whatsapp-panel__send[aria-disabled="true"]:hover,
.si-whatsapp-panel__send[aria-disabled="true"]:focus-visible {
    background: #a8dcc0;
}

.si-whatsapp-panel__send-icon {
    display: flex;
    align-items: center;
    line-height: 0;
}

#si-whatsapp-backdrop,
.si-whatsapp-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99987;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

#si-whatsapp-backdrop.si-whatsapp-backdrop--open,
.si-whatsapp-backdrop.si-whatsapp-backdrop--open {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 991px) {
    body.si-bottom-nav-active #si-whatsapp-widget,
    body.si-bottom-nav-active .si-whatsapp-widget {
        bottom: var(--si-chat-bottom-mobile);
    }
}

@media (min-width: 992px) {
    #si-whatsapp-widget,
    .si-whatsapp-widget {
        right: max(24px, env(safe-area-inset-right, 0px));
    }
}

body.modal-open #si-whatsapp-widget,
body.slp-modal-open #si-whatsapp-widget,
body.modal-open .si-whatsapp-widget,
body.slp-modal-open .si-whatsapp-widget {
    z-index: 99980;
    opacity: 0.35;
    pointer-events: none;
}

body.modal-open #si-whatsapp-backdrop,
body.slp-modal-open #si-whatsapp-backdrop {
    display: none;
}
