/**
 * WhatsApp Leads & Google Sheets - Estilos Frontend
 * Diseño fiel al modal oficial de WhatsApp
 */

:root {
    --wsl-green-header: #075E54;
    --wsl-green-header-dark: #054c44;
    --wsl-green-cta: #25D366;
    --wsl-green-cta-hover: #1ebe5d;
    --wsl-green-badge: #128C7E;
    --wsl-chat-bubble-bg: #F0F4F8;
    --wsl-text-dark: #1e293b;
    --wsl-text-muted: #64748b;
    --wsl-text-label: #475569;
    --wsl-input-border: #E2E8F0;
    --wsl-input-bg: #FFFFFF;
    --wsl-input-focus-border: #25D366;
    --wsl-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================================
   Contenedor Principal Flotante
   ========================================================================== */
.wsl-widget-wrap {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--wsl-font-family);
    box-sizing: border-box;
}

.wsl-widget-wrap *,
.wsl-inline-card * {
    box-sizing: border-box;
}

.wsl-widget-wrap.wsl-pos-right {
    right: 24px;
}

.wsl-widget-wrap.wsl-pos-left {
    left: 24px;
}

/* ==========================================================================
   Botón Circular Flotante
   ========================================================================== */
.wsl-floating-btn {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background-color: var(--wsl-green-cta);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(37, 211, 102, 0.42), 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    margin-left: auto;
}

.wsl-pos-left .wsl-floating-btn {
    margin-left: 0;
    margin-right: auto;
}

.wsl-floating-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.55), 0 3px 8px rgba(0, 0, 0, 0.2);
}

.wsl-floating-btn:active {
    transform: scale(0.96);
}

.wsl-floating-svg {
    width: 36px;
    height: 36px;
    fill: #ffffff;
}

/* Pulso animado sutil */
.wsl-floating-pulse {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid var(--wsl-green-cta);
    opacity: 0.8;
    animation: wslPulse 2.4s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
}

@keyframes wslPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.22);
        opacity: 0;
    }
    100% {
        transform: scale(1.22);
        opacity: 0;
    }
}

/* ==========================================================================
   Caja del Modal / Tarjeta
   ========================================================================== */
.wsl-modal,
.wsl-inline-card {
    width: 375px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 16px 48px -4px rgba(0, 0, 0, 0.22), 0 6px 16px -2px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
    transform-origin: bottom right;
    animation: wslPopupIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.wsl-pos-left .wsl-modal {
    transform-origin: bottom left;
}

.wsl-inline-card {
    margin: 20px auto;
    animation: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

@keyframes wslPopupIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   Cabecera Verde WhatsApp
   ========================================================================== */
.wsl-header {
    background: var(--wsl-green-header);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.wsl-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wsl-whatsapp-icon {
    width: 26px;
    height: 26px;
    fill: #ffffff;
}

.wsl-header-info {
    flex: 1;
    min-width: 0;
}

.wsl-header-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: #ffffff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wsl-header-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    gap: 6px;
}

.wsl-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--wsl-green-cta);
    display: inline-block;
    box-shadow: 0 0 6px var(--wsl-green-cta);
}

.wsl-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.wsl-close-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: rotate(90deg);
}

/* ==========================================================================
   Cuerpo del Modal y Burbuja de Chat
   ========================================================================== */
.wsl-body {
    padding: 18px 20px 16px 20px;
    background: #ffffff;
}

.wsl-chat-bubble {
    background: var(--wsl-chat-bubble-bg);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 18px;
    position: relative;
    border-left: 3px solid #cbd5e1;
}

.wsl-chat-bubble p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
    color: #334155;
    font-weight: 500;
}

/* ==========================================================================
   Formulario y Campos
   ========================================================================== */
.wsl-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wsl-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wsl-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--wsl-text-label);
}

.wsl-required {
    color: #ef4444;
    font-weight: 700;
}

.wsl-input,
.wsl-select {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--wsl-text-dark);
    background-color: var(--wsl-input-bg);
    border: 1.5px solid var(--wsl-input-border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.wsl-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.wsl-input:focus,
.wsl-select:focus,
.wsl-country-select:focus {
    border-color: var(--wsl-green-cta);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.18);
}

/* Campo Celular con Selector de País */
.wsl-phone-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wsl-country-select-wrap {
    position: relative;
    width: 105px;
    flex-shrink: 0;
}

.wsl-country-select {
    width: 100%;
    height: 42px;
    padding: 8px 24px 8px 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--wsl-text-dark);
    background: #f8fafc;
    border: 1.5px solid var(--wsl-input-border);
    border-radius: 8px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    text-transform: uppercase;
}

.wsl-input-phone {
    flex: 1;
}

/* Selectores generales con flecha personalizada */
.wsl-select-wrapper {
    position: relative;
    width: 100%;
}

.wsl-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    cursor: pointer;
    background-color: #ffffff;
}

.wsl-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: #64748b;
    pointer-events: none;
}

/* ==========================================================================
   Botón de Envío
   ========================================================================== */
.wsl-submit-btn {
    width: 100%;
    height: 48px;
    margin-top: 4px;
    background-color: var(--wsl-green-cta);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.wsl-submit-btn:hover {
    background-color: var(--wsl-green-cta-hover);
    transform: translateY(-1.5px);
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.45);
}

.wsl-submit-btn:active {
    transform: translateY(0);
}

.wsl-submit-btn:disabled {
    opacity: 0.75;
    cursor: not-allowed;
    transform: none;
}

/* Spinner de Carga */
.wsl-spinner-svg {
    width: 22px;
    height: 22px;
    animation: wslRotate 1.5s linear infinite;
}

.wsl-spinner-path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: wslDash 1.5s ease-in-out infinite;
}

@keyframes wslRotate {
    100% { transform: rotate(360deg); }
}

@keyframes wslDash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* ==========================================================================
   Pie de Estado & Mensajes
   ========================================================================== */
.wsl-footer-status {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: var(--wsl-text-muted);
    font-weight: 500;
}

.wsl-footer-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--wsl-green-cta);
    display: inline-block;
}

.wsl-feedback-msg {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.4;
    animation: wslFadeIn 0.2s ease;
}

.wsl-feedback-msg.wsl-msg-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.wsl-feedback-msg.wsl-msg-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

@keyframes wslFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsividad Móvil
   ========================================================================== */
@media (max-width: 480px) {
    .wsl-widget-wrap {
        bottom: 16px;
    }
    .wsl-widget-wrap.wsl-pos-right {
        right: 16px;
    }
    .wsl-widget-wrap.wsl-pos-left {
        left: 16px;
    }
    .wsl-modal {
        width: calc(100vw - 32px);
        margin-bottom: 12px;
    }
    .wsl-body {
        padding: 14px 16px;
    }
}
