/**
 * WP Smart Chatbot - Estilos
 * Diseño moderno, accesible y responsive
 */

/* Variables CSS - se sobreescriben dinámicamente desde PHP */
:root {
    --wpsc-primary: #0073aa;
    --wpsc-secondary: #005177;
    --wpsc-text: #1a1a1a;
    --wpsc-text-light: #6b7280;
    --wpsc-bg: #ffffff;
    --wpsc-bg-alt: #f9fafb;
    --wpsc-border: #e5e7eb;
    --wpsc-success: #10b981;
    --wpsc-error: #ef4444;
    --wpsc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --wpsc-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
    --wpsc-shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);
    --wpsc-radius: 16px;
    --wpsc-radius-sm: 10px;
    --wpsc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* Wrapper principal */
#wpsc-chatbot-wrapper {
    position: fixed;
    z-index: 999999;
    font-family: var(--wpsc-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--wpsc-text);
}

#wpsc-chatbot-wrapper *,
#wpsc-chatbot-wrapper *::before,
#wpsc-chatbot-wrapper *::after {
    box-sizing: border-box;
}

/* Posiciones */
.wpsc-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wpsc-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Botón flotante para abrir/cerrar - VERSIÓN LLAMATIVA */
.wpsc-toggle-button {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background:
        linear-gradient(135deg, var(--wpsc-primary) 0%, var(--wpsc-secondary) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow:
        var(--wpsc-shadow-md),
        0 0 24px -4px var(--wpsc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    animation: wpsc-float 3s ease-in-out infinite;
    overflow: visible;
}

/* Brillo deslizante sobre el botón */
.wpsc-toggle-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent 20%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 80%
    );
    transform: skewX(-25deg);
    border-radius: 50%;
    animation: wpsc-shine 4s ease-in-out infinite;
    pointer-events: none;
}

.wpsc-toggle-button:hover {
    transform: scale(1.12) rotate(-3deg);
    box-shadow:
        var(--wpsc-shadow-lg),
        0 0 40px -2px var(--wpsc-primary);
}

.wpsc-toggle-button:active {
    transform: scale(0.95);
}

.wpsc-toggle-button svg {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
    position: absolute;
    z-index: 2;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.wpsc-toggle-button .wpsc-icon-close {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
}

.wpsc-toggle-button.wpsc-active .wpsc-icon-chat {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
}

.wpsc-toggle-button.wpsc-active .wpsc-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.wpsc-toggle-button.wpsc-active {
    animation: none;
}

.wpsc-toggle-button.wpsc-active::before,
.wpsc-toggle-button.wpsc-active .wpsc-pulse-ring,
.wpsc-toggle-button.wpsc-active .wpsc-sparkle {
    display: none;
}

/* Anillos de pulso animados (concéntricos) */
.wpsc-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--wpsc-primary);
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    animation: wpsc-pulse-ring 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

.wpsc-pulse-ring-2 {
    animation-delay: 1.25s;
}

@keyframes wpsc-pulse-ring {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.6;
    }
    100% {
        width: 220%;
        height: 220%;
        opacity: 0;
    }
}

/* Flotación suave del botón */
@keyframes wpsc-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* Brillo deslizante */
@keyframes wpsc-shine {
    0%, 50%, 100% {
        left: -75%;
    }
    25%, 75% {
        left: 125%;
    }
}

/* Chispitas decorativas alrededor del botón */
.wpsc-sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 0 8px #fff, 0 0 12px var(--wpsc-primary);
}

.wpsc-sparkle-1 {
    top: 8%;
    right: -2px;
    animation: wpsc-sparkle 3s ease-in-out infinite;
    animation-delay: 0.3s;
}

.wpsc-sparkle-2 {
    bottom: 12%;
    left: -4px;
    width: 5px;
    height: 5px;
    animation: wpsc-sparkle 3s ease-in-out infinite;
    animation-delay: 1.4s;
}

.wpsc-sparkle-3 {
    top: -2px;
    left: 30%;
    width: 4px;
    height: 4px;
    animation: wpsc-sparkle 3s ease-in-out infinite;
    animation-delay: 2.2s;
}

@keyframes wpsc-sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Efecto de sacudida ocasional para llamar atención */
.wpsc-toggle-button.wpsc-attention {
    animation: wpsc-attention-shake 1s ease-in-out;
}

@keyframes wpsc-attention-shake {
    0%, 100% { transform: rotate(0) scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: rotate(-8deg) scale(1.05); }
    20%, 40%, 60%, 80% { transform: rotate(8deg) scale(1.05); }
}

/* ===========================================
   BURBUJA DE INVITACIÓN CON MENSAJES ROTATIVOS
   =========================================== */
.wpsc-invite-bubble {
    position: absolute;
    bottom: 10px;
    background: linear-gradient(135deg, #ffffff 0%, #f9fbff 100%);
    border-radius: 18px;
    padding: 14px 38px 14px 18px;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(0, 0, 0, 0.03);
    max-width: 280px;
    min-width: 220px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.9);
    transition:
        opacity 0.4s ease,
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

.wpsc-position-bottom-right .wpsc-invite-bubble {
    right: 84px;
    transform-origin: bottom right;
}

.wpsc-position-bottom-left .wpsc-invite-bubble {
    left: 84px;
    transform-origin: bottom left;
}

.wpsc-invite-bubble.wpsc-visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
    animation: wpsc-invite-wobble 4s ease-in-out infinite;
    animation-delay: 1s;
}

.wpsc-invite-bubble.wpsc-hidden-forever {
    display: none !important;
}

@keyframes wpsc-invite-wobble {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-2px) rotate(-0.5deg); }
    75% { transform: translateY(-2px) rotate(0.5deg); }
}

.wpsc-invite-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

.wpsc-invite-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--wpsc-primary);
    line-height: 1.2;
}

.wpsc-invite-message {
    font-size: 14px;
    color: var(--wpsc-text);
    line-height: 1.35;
    font-weight: 500;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.wpsc-invite-message.wpsc-fading {
    opacity: 0;
    transform: translateY(-4px);
}

.wpsc-invite-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    color: var(--wpsc-text-light);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.wpsc-invite-close:hover {
    background: rgba(0, 0, 0, 0.12);
    color: var(--wpsc-text);
    transform: rotate(90deg);
}

/* "Colita" de la burbuja apuntando al botón */
.wpsc-invite-tail {
    position: absolute;
    bottom: 14px;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #ffffff 0%, #f9fbff 100%);
    transform: rotate(45deg);
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.04);
}

.wpsc-position-bottom-right .wpsc-invite-tail {
    right: -6px;
}

.wpsc-position-bottom-left .wpsc-invite-tail {
    left: -6px;
}

.wpsc-invite-bubble:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.16),
        0 0 0 1px var(--wpsc-primary);
    animation: none;
}

/* Badge de notificación */
.wpsc-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--wpsc-error);
    color: white;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: wpsc-bounce 1s ease infinite;
}

.wpsc-notification-badge.wpsc-hidden {
    display: none;
}

@keyframes wpsc-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Ventana del chat */
.wpsc-chat-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--wpsc-bg);
    border-radius: var(--wpsc-radius);
    box-shadow: var(--wpsc-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
    transform-origin: bottom right;
}

.wpsc-position-bottom-left .wpsc-chat-window {
    transform-origin: bottom left;
    left: 0;
}

.wpsc-position-bottom-right .wpsc-chat-window {
    right: 0;
}

.wpsc-chat-window.wpsc-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Header del chat */
.wpsc-chat-header {
    background: linear-gradient(135deg, var(--wpsc-primary) 0%, var(--wpsc-secondary) 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wpsc-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wpsc-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.wpsc-bot-name {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
}

.wpsc-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.wpsc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
    animation: wpsc-blink 2s ease infinite;
}

@keyframes wpsc-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.wpsc-minimize-button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.wpsc-minimize-button:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Área de mensajes */
.wpsc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--wpsc-bg-alt);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.wpsc-messages::-webkit-scrollbar {
    width: 6px;
}

.wpsc-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wpsc-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* Mensajes */
.wpsc-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--wpsc-radius-sm);
    word-wrap: break-word;
    animation: wpsc-message-in 0.3s ease forwards;
    line-height: 1.4;
}

@keyframes wpsc-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpsc-message-bot {
    background: white;
    color: var(--wpsc-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--wpsc-shadow-sm);
}

.wpsc-message-user {
    background: linear-gradient(135deg, var(--wpsc-primary) 0%, var(--wpsc-secondary) 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Indicador de escritura */
.wpsc-typing {
    background: white;
    align-self: flex-start;
    padding: 14px 16px;
    border-radius: var(--wpsc-radius-sm);
    border-bottom-left-radius: 4px;
    box-shadow: var(--wpsc-shadow-sm);
    display: flex;
    gap: 4px;
    animation: wpsc-message-in 0.3s ease forwards;
}

.wpsc-typing span {
    width: 8px;
    height: 8px;
    background: var(--wpsc-text-light);
    border-radius: 50%;
    animation: wpsc-typing-bounce 1.4s infinite ease-in-out;
}

.wpsc-typing span:nth-child(2) { animation-delay: 0.2s; }
.wpsc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wpsc-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Botones de opciones */
.wpsc-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    align-self: flex-start;
    width: 100%;
    max-width: 100%;
}

.wpsc-option-button {
    background: white;
    border: 1.5px solid var(--wpsc-border);
    color: var(--wpsc-text);
    padding: 12px 16px;
    border-radius: var(--wpsc-radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    text-align: left;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wpsc-option-button:hover {
    border-color: var(--wpsc-primary);
    background: var(--wpsc-primary);
    color: white;
    transform: translateX(4px);
}

.wpsc-option-button.wpsc-back {
    background: transparent;
    border: none;
    color: var(--wpsc-text-light);
    font-size: 13px;
    padding: 8px 12px;
    align-self: flex-start;
    width: auto;
}

.wpsc-option-button.wpsc-back:hover {
    color: var(--wpsc-primary);
    background: transparent;
    transform: translateX(-2px);
}

/* WhatsApp button especial */
.wpsc-whatsapp-button {
    background: #25D366;
    color: white;
    border: none;
    padding: 14px 18px;
    border-radius: var(--wpsc-radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
    justify-content: center;
}

.wpsc-whatsapp-button:hover {
    background: #128C7E;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

/* Resultados de búsqueda */
.wpsc-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.wpsc-search-result {
    background: white;
    border: 1px solid var(--wpsc-border);
    border-radius: var(--wpsc-radius-sm);
    padding: 12px;
    text-decoration: none;
    color: var(--wpsc-text);
    transition: all 0.2s;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.wpsc-search-result:hover {
    border-color: var(--wpsc-primary);
    transform: translateX(4px);
    box-shadow: var(--wpsc-shadow-sm);
}

.wpsc-search-result-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.wpsc-search-result-content {
    flex: 1;
    min-width: 0;
}

.wpsc-search-result-title {
    font-weight: 600;
    font-size: 14px;
    margin: 0 0 4px;
    color: var(--wpsc-primary);
    line-height: 1.3;
}

.wpsc-search-result-excerpt {
    font-size: 12px;
    color: var(--wpsc-text-light);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Formulario de contacto */
.wpsc-contact-form {
    background: white;
    padding: 16px;
    border-radius: var(--wpsc-radius-sm);
    box-shadow: var(--wpsc-shadow-sm);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wpsc-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wpsc-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--wpsc-text);
}

.wpsc-form-group input,
.wpsc-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--wpsc-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--wpsc-text);
    background: white;
    transition: border-color 0.2s;
    resize: vertical;
}

.wpsc-form-group input:focus,
.wpsc-form-group textarea:focus {
    outline: none;
    border-color: var(--wpsc-primary);
}

.wpsc-form-group input.wpsc-error-input,
.wpsc-form-group textarea.wpsc-error-input {
    border-color: var(--wpsc-error);
}

.wpsc-form-error {
    font-size: 11px;
    color: var(--wpsc-error);
    margin-top: 2px;
}

/* Honeypot */
.wpsc-honeypot {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.wpsc-form-submit {
    background: linear-gradient(135deg, var(--wpsc-primary) 0%, var(--wpsc-secondary) 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 4px;
}

.wpsc-form-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.wpsc-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Footer del chat */
.wpsc-chat-footer {
    background: white;
    border-top: 1px solid var(--wpsc-border);
    flex-shrink: 0;
}

.wpsc-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    align-items: center;
}

.wpsc-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--wpsc-border);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.wpsc-input-area input:focus {
    border-color: var(--wpsc-primary);
}

#wpsc-send-button {
    background: linear-gradient(135deg, var(--wpsc-primary) 0%, var(--wpsc-secondary) 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

#wpsc-send-button:hover {
    transform: scale(1.08);
}

#wpsc-send-button:active {
    transform: scale(0.95);
}

.wpsc-powered {
    text-align: center;
    font-size: 11px;
    color: var(--wpsc-text-light);
    padding: 8px;
    border-top: 1px solid var(--wpsc-border);
}

/* Botón disparador externo (shortcode) */
.wpsc-trigger-button {
    background: linear-gradient(135deg, var(--wpsc-primary) 0%, var(--wpsc-secondary) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--wpsc-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.wpsc-trigger-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.3);
}

/* Estado de éxito en el formulario */
.wpsc-success-message {
    background: #ecfdf5;
    border: 1px solid var(--wpsc-success);
    color: #065f46;
    padding: 14px 16px;
    border-radius: var(--wpsc-radius-sm);
    text-align: center;
    font-weight: 500;
}

.wpsc-error-message {
    background: #fef2f2;
    border: 1px solid var(--wpsc-error);
    color: #991b1b;
    padding: 14px 16px;
    border-radius: var(--wpsc-radius-sm);
    text-align: center;
}

/* Responsive: móvil */
@media (max-width: 480px) {
    /* En móvil el wrapper ocupa toda la pantalla cuando el chat está abierto,
       así la ventana puede fijarse a 0/0 sin desfase por offsets del wrapper.
       El botón flotante se posiciona por sí mismo. */
    .wpsc-position-bottom-right,
    .wpsc-position-bottom-left {
        bottom: 0;
        right: 0;
        left: 0;
        top: auto;
    }

    /* El botón flotante mantiene su posición habitual */
    .wpsc-toggle-button {
        position: fixed;
        bottom: 16px;
        width: 56px;
        height: 56px;
    }
    .wpsc-position-bottom-right .wpsc-toggle-button {
        right: 16px;
    }
    .wpsc-position-bottom-left .wpsc-toggle-button {
        left: 16px;
    }

    /* Ventana del chat: usa position:fixed + dvh para adaptarse al teclado virtual.
       100dvh = "dynamic viewport height", se reduce cuando el teclado aparece
       (a diferencia de 100vh, que se mantiene fijo y provoca el desfase). */
    .wpsc-chat-window {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100vw;
        width: 100dvw;
        max-width: 100vw;
        max-width: 100dvw;
        height: 100vh;            /* fallback navegadores antiguos */
        height: 100dvh;           /* clave: se ajusta con el teclado */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;         /* pantalla completa */
        transform-origin: center center;
    }

    .wpsc-position-bottom-right .wpsc-chat-window,
    .wpsc-position-bottom-left .wpsc-chat-window {
        left: 0;
        right: 0;
        transform-origin: center center;
    }

    /* Cuando el chat está abierto, ocultar el botón flotante (evita superposición
       y un segundo origen visual durante el scroll del teclado). */
    .wpsc-chat-window.wpsc-open ~ .wpsc-toggle-button,
    #wpsc-chatbot-wrapper:has(.wpsc-chat-window.wpsc-open) .wpsc-toggle-button {
        opacity: 0;
        pointer-events: none;
    }

    /* Burbuja de invitación en móvil: más pequeña y ajustada */
    .wpsc-invite-bubble {
        max-width: calc(100vw - 110px);
        min-width: 180px;
        padding: 10px 32px 10px 14px;
        bottom: 18px;
    }

    .wpsc-position-bottom-right .wpsc-invite-bubble {
        right: 80px;
    }

    .wpsc-position-bottom-left .wpsc-invite-bubble {
        left: 80px;
    }

    .wpsc-invite-title { font-size: 12px; }
    .wpsc-invite-message { font-size: 13px; }

    /* Ocultar la burbuja cuando el chat está abierto en móvil */
    #wpsc-chatbot-wrapper:has(.wpsc-chat-window.wpsc-open) .wpsc-invite-bubble {
        opacity: 0;
        pointer-events: none;
    }

    /* Asegurar que el área de mensajes sea la que hace scroll
       cuando el alto disponible se reduce por el teclado. */
    .wpsc-messages {
        flex: 1 1 auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }

    /* El header y el footer no deben encogerse al abrir el teclado. */
    .wpsc-chat-header,
    .wpsc-chat-footer {
        flex-shrink: 0;
    }

    /* Inputs: font-size >= 16px evita que iOS Safari haga zoom al enfocar,
       que es otra causa común de desfase visual hacia la derecha. */
    .wpsc-input-area input,
    .wpsc-form-group input,
    .wpsc-form-group textarea {
        font-size: 16px;
    }
}

/* Clase auxiliar aplicada por JS cuando el teclado virtual está visible.
   Usa la altura real reportada por visualViewport para máxima precisión. */
.wpsc-chat-window.wpsc-keyboard-open {
    height: var(--wpsc-vv-height, 100dvh) !important;
    max-height: var(--wpsc-vv-height, 100dvh) !important;
}

/* Accesibilidad: respetar preferencias de movimiento */
@media (prefers-reduced-motion: reduce) {
    .wpsc-toggle-button,
    .wpsc-notification-badge,
    .wpsc-status-dot,
    .wpsc-pulse-ring,
    .wpsc-sparkle,
    .wpsc-invite-bubble,
    .wpsc-toggle-button::before {
        animation: none !important;
    }
    .wpsc-chat-window,
    .wpsc-message,
    .wpsc-typing,
    .wpsc-option-button:hover,
    .wpsc-search-result:hover,
    .wpsc-invite-message {
        transition-duration: 0.01s !important;
        animation-duration: 0.01s !important;
    }
}
/* Resaltado de coincidencias en resultados de búsqueda */
.wpsc-search-result-excerpt mark {
    background: #fff3a0;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}
 
/* Etiqueta del tipo de contenido (Página, Producto, etc.) */
.wpsc-search-result-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wpsc-text-light);
    background: var(--wpsc-bg-alt);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 4px;
}
 
/* =================================================================
 * CTA shortcodes ([wpsc_chat_button], [wpsc_chat_link])
 * Estilos por defecto. Se pueden sobrescribir con la clase del atributo
 * `class="..."` o desde el tema.
 * ================================================================= */
.wpsc-cta-button {
    display: inline-block;
    padding: 12px 24px;
    background: var(--wpsc-primary, #0073aa);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
    border: none;
    cursor: pointer;
}
.wpsc-cta-button:hover,
.wpsc-cta-button:focus {
    background: var(--wpsc-secondary, #005177);
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.wpsc-cta-link {
    color: var(--wpsc-primary, #0073aa);
    text-decoration: underline;
    cursor: pointer;
}
.wpsc-cta-link:hover,
.wpsc-cta-link:focus {
    color: var(--wpsc-secondary, #005177);
}
