/* ESF WhatsApp Widget */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.esf-wa {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Floating Button ─────────────────────────────────── */

.esf-wa__btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #25d366;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,211,102,0.45);
    transition: background 0.2s, transform 0.2s;
    animation: esf-wa-btn-pulse 2.5s infinite;
}

.esf-wa__btn:hover {
    background: #20c55a;
    transform: scale(1.08);
    animation: none;
}

.esf-wa__btn--hidden { display: none !important; }

@keyframes esf-wa-btn-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(37,211,102,0.5); }
    70%  { box-shadow: 0 0 0 14px rgba(37,211,102,0); }
    100% { box-shadow: 0 0 0 0   rgba(37,211,102,0); }
}

/* ── Badge ───────────────────────────────────────────── */

.esf-wa__badge {
    position: absolute;
    bottom: 46px;
    right: 0;
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    transition: opacity 0.2s, transform 0.2s;
}

.esf-wa__badge--in {
    animation: esf-wa-badge-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.esf-wa__badge--out {
    opacity: 0 !important;
    transform: scale(0) !important;
}

@keyframes esf-wa-badge-pop {
    0%   { opacity:0; transform: scale(0); }
    65%  { opacity:1; transform: scale(1.25); }
    100% { opacity:1; transform: scale(1); }
}

/* ── Popup ───────────────────────────────────────────── */

.esf-wa__popup {
    width: 320px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    margin-bottom: 12px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    transform-origin: bottom right;
}

.esf-wa__popup--open {
    display: flex;
    animation: esf-wa-popup-in 0.28s cubic-bezier(0.34,1.2,0.64,1) forwards;
}

@keyframes esf-wa-popup-in {
    from { opacity:0; transform: translateY(14px) scale(0.94); }
    to   { opacity:1; transform: translateY(0)    scale(1); }
}

/* ── Header ──────────────────────────────────────────── */

.esf-wa__header {
    background: #075e54;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.esf-wa__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #128c7e;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.esf-wa__avatar svg { display: block; }
.esf-wa__btn svg   { display: block; width: 28px; height: 28px; flex-shrink: 0; }

.esf-wa__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

.esf-wa__agent { flex: 1; min-width: 0; }

.esf-wa__agent-name {
    display: block;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.esf-wa__agent-status {
    display: block;
    font-size: 12px;
    opacity: 0.82;
    line-height: 1.3;
}

.esf-wa__close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.75;
    padding: 4px 6px;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.esf-wa__close:hover { opacity: 1; }

/* ── Chat Area ───────────────────────────────────────── */

.esf-wa__chat {
    background: #e5dcd5;
    padding: 14px 14px 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Typing bubble */
.esf-wa__typing {
    background: #fff;
    border-radius: 0 10px 10px 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0,0,0,0.13);
    position: relative;
    margin-left: 2px;
}

.esf-wa__typing::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 8px;
    height: 13px;
    background: #fff;
    clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.esf-wa__typing span {
    width: 7px;
    height: 7px;
    background: #8696a0;
    border-radius: 50%;
    animation: esf-wa-typing 1.3s infinite ease-in-out;
}

.esf-wa__typing span:nth-child(2) { animation-delay: 0.18s; }
.esf-wa__typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes esf-wa-typing {
    0%,60%,100% { transform: translateY(0);   opacity: 0.35; }
    30%          { transform: translateY(-5px); opacity: 1; }
}

/* Greeting bubble */
.esf-wa .esf-wa__greeting {
    background: #fff;
    border-radius: 0 10px 10px 10px;
    padding: 8px 48px 20px 10px !important;
    font-size: 14px;
    line-height: 1.55;
    color: #111827;
    box-shadow: 0 1px 2px rgba(0,0,0,0.13);
    max-width: 88%;
    word-break: break-word;
    position: relative !important;
    margin-left: 2px;
}

.esf-wa .esf-wa__greeting strong {
    font-weight: 700 !important;
    font-style: normal;
}

.esf-wa .esf-wa__greeting::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 8px;
    height: 13px;
    background: #fff;
    clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.esf-wa .esf-wa__greeting-meta {
    position: absolute !important;
    bottom: 5px !important;
    right: 8px !important;
    display: block !important;
    float: none !important;
    font-size: 11px;
    color: #8696a0;
    white-space: nowrap;
    line-height: 1;
    pointer-events: none;
}

/* ── Form Area ───────────────────────────────────────── */

.esf-wa__form {
    background: #efe8e2;
    padding: 12px 14px 14px;
    display: none;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid #ddd5cd;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.esf-wa__form--in {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.esf-wa__input {
    width: 100%;
    padding: 10px 16px;
    border: 1.5px solid #d4cbc5;
    border-radius: 22px !important;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #111;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
}

.esf-wa__input:focus {
    outline: none;
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
}

.esf-wa__input--error { border-color: #ef4444 !important; }

/* Select — custom arrow */
.esf-wa__select-wrap {
    position: relative;
    width: 100%;
}

.esf-wa__select-wrap::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
}

.esf-wa__select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    cursor: pointer;
}

/* Field label (above choice groups) */
.esf-wa__field-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Checkbox & Radio groups */
.esf-wa__choice-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px 0 4px;
}

.esf-wa__choice-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #111;
    cursor: pointer;
    line-height: 1.4;
    user-select: none;
}

/* Hide native input — keep accessible */
.esf-wa__choice-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Custom indicator base */
.esf-wa__choice-mark {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    background: #fff;
    border-radius: 4px;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
}

/* Checkbox — square, checkmark via ::after */
.esf-wa__choice-group[data-type="checkbox"] .esf-wa__choice-input:checked ~ .esf-wa__choice-mark {
    background: #25d366;
    border-color: #25d366;
}

.esf-wa__choice-group[data-type="checkbox"] .esf-wa__choice-input:checked ~ .esf-wa__choice-mark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* Radio — circle, inner dot via ::after */
.esf-wa__choice-group[data-type="radio"] .esf-wa__choice-mark {
    border-radius: 50%;
}

.esf-wa__choice-group[data-type="radio"] .esf-wa__choice-input:checked ~ .esf-wa__choice-mark {
    background: #25d366;
    border-color: #25d366;
}

.esf-wa__choice-group[data-type="radio"] .esf-wa__choice-input:checked ~ .esf-wa__choice-mark::after {
    content: '';
    position: absolute;
    width: 7px;
    height: 7px;
    background: #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Focus ring for keyboard nav */
.esf-wa__choice-input:focus-visible ~ .esf-wa__choice-mark {
    outline: 2px solid #25d366;
    outline-offset: 2px;
}

/* Error state */
.esf-wa__choice-group--error .esf-wa__choice-mark {
    border-color: #ef4444;
}

.esf-wa__choice-text {
    flex: 1;
}

.esf-wa__error {
    color: #dc2626;
    font-size: 12.5px;
    padding: 0;
    line-height: 1.4;
}

/* ── Submit Button ───────────────────────────────────── */

.esf-wa__submit {
    width: 100%;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 11px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, opacity 0.2s;
    margin-top: 2px;
}

.esf-wa__submit:hover:not(:disabled) { background: #20c55a; }
.esf-wa__submit:disabled { opacity: 0.65; cursor: not-allowed; }

.esf-wa__submit-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.esf-wa__submit:not(:disabled):hover .esf-wa__submit-icon {
    animation: esf-wa-arrow-bounce 0.45s ease;
}

.esf-wa__submit--sending .esf-wa__submit-icon {
    animation: esf-wa-arrow-loop 0.65s ease infinite !important;
}

@keyframes esf-wa-arrow-bounce {
    0%   { transform: translateX(0); }
    45%  { transform: translateX(7px); }
    72%  { transform: translateX(-3px); }
    100% { transform: translateX(0); }
}

@keyframes esf-wa-arrow-loop {
    0%   { transform: translateX(-8px); opacity: 0; }
    30%  { transform: translateX(0);    opacity: 1; }
    70%  { transform: translateX(0);    opacity: 1; }
    100% { transform: translateX(8px);  opacity: 0; }
}

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 400px) {
    .esf-wa        { bottom: 16px; right: 16px; }
    .esf-wa__popup { width: calc(100vw - 32px); }
}
