/* SalesCloud Chat — Unified Widget — RIGHT SIDE */

/* Reset: neutralizar estilos globales de WP/Gutenberg/Woodmart en botones del chatbot */
#schat-wrap button,
#schat-wrap button:hover,
#schat-wrap button:focus {
    background-color: transparent;
    padding: 0;
    margin: 0;
    border: none;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    box-shadow: none;
    min-width: 0;
    min-height: 0;
}

:root {
    --sc-primary: #2AB9AD;
    --sc-primary-dark: #1e9b90;
    --sc-dark: #000065;
    --sc-white: #ffffff;
    --sc-gray-light: #f0f2f5;
    --sc-gray: #e4e6ea;
    --sc-gray-text: #65676b;
    --sc-online: #42b72a;
    --sc-offline: #bcc0c4;
    --sc-recording: #e74c3c;
    --sc-shadow: 0 8px 30px rgba(0,0,0,0.18);
    --sc-radius: 18px;
    --sc-z: 999999;
}

/* ── BOTÓN FLOTANTE (IZQUIERDA) ── */
#schat-wrap {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: var(--sc-z);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.schat-button {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--sc-shadow);
    transition: transform 0.2s ease;
    user-select: none;
}

.schat-button:hover { transform: scale(1.08); }

.schat-btn-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--sc-white);
    background: var(--sc-gray-light);
}

.schat-btn-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.schat-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--sc-offline);
    border: 2.5px solid var(--sc-white);
    z-index: 2;
}

.schat-status-dot.online {
    background: var(--sc-online);
    animation: sc-pulse-dot 2s infinite;
}

@keyframes sc-pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(66,183,42,0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(66,183,42,0); }
}

.schat-btn-pulse {
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 50%;
    border: 3px solid var(--sc-primary);
    opacity: 0;
    pointer-events: none;
}

.schat-button.online .schat-btn-pulse {
    animation: sc-pulse-ring 2.5s infinite;
}

@keyframes sc-pulse-ring {
    0%   { transform: scale(0.9); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 0; }
}

.schat-btn-label {
    position: absolute;
    bottom: 72px;
    left: 0;
    background: var(--sc-dark);
    color: var(--sc-white);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
}

.schat-button:hover .schat-btn-label {
    opacity: 1;
    transform: translateY(0);
}

.schat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* ── VENTANA CHAT (abre hacia la izquierda) ── */
.schat-window {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 360px;
    max-height: 580px;
    background: var(--sc-white);
    border-radius: var(--sc-radius);
    box-shadow: var(--sc-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: sc-slide-up 0.3s ease;
}

@keyframes sc-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── PANTALLA LLAMANDO ── */
.schat-screen-calling,
#schat-screen-calling {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px;
    background: linear-gradient(135deg, var(--sc-dark) 0%, #0a0a8a 100%);
    min-height: 320px;
}

.schat-calling-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
}

.schat-calling-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.3);
    position: relative;
    z-index: 3;
}

.schat-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--sc-primary);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.schat-ring1 { width: 120px; height: 120px; animation: sc-ring 2.5s 0.0s infinite; }
.schat-ring2 { width: 150px; height: 150px; animation: sc-ring 2.5s 0.6s infinite; }
.schat-ring3 { width: 180px; height: 180px; animation: sc-ring 2.5s 1.2s infinite; }

@keyframes sc-ring {
    0%   { opacity: 0.8; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 0;   transform: translate(-50%, -50%) scale(1.4); }
}

.schat-calling-name  { color: var(--sc-white); font-size: 22px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.schat-calling-title { color: rgba(255,255,255,0.7); font-size: 13px; margin-bottom: 16px; text-align: center; }
.schat-calling-status { color: var(--sc-primary); font-size: 14px; font-weight: 500; text-align: center; animation: sc-status-blink 1.5s infinite; }

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

/* ── PANTALLA CHAT ── */
#schat-screen-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.schat-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--sc-dark) 0%, #0a0a8a 100%);
    color: var(--sc-white);
    gap: 10px;
    flex-shrink: 0;
}

.schat-header-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.schat-header-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.schat-header-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--sc-offline);
    border: 2px solid white;
}

.schat-header-dot.online { background: var(--sc-online); }

.schat-header-info { flex: 1; }
.schat-header-name { font-size: 15px; font-weight: 700; }
.schat-header-sub  { font-size: 11px; opacity: 0.8; }

.schat-close-btn {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    color: rgba(255,255,255,0.7) !important;
    cursor: pointer !important;
    font-size: 16px !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    transition: background 0.2s;
    line-height: 1 !important;
    min-width: 0 !important;
}
#schat-wrap .schat-close-btn:hover { background: rgba(255,255,255,0.15) !important; color: white !important; }

.schat-reset-btn {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    color: rgba(255,255,255,0.7) !important;
    cursor: pointer !important;
    font-size: 17px !important;
    padding: 4px 6px !important;
    border-radius: 50% !important;
    line-height: 1 !important;
    min-width: 0 !important;
    transition: color 0.15s, background 0.15s !important;
}
#schat-wrap .schat-reset-btn:hover { background: rgba(255,255,255,0.15) !important; color: white !important; }

/* ── MENSAJES ── */
.schat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 300px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

.schat-messages::-webkit-scrollbar { width: 4px; }
.schat-messages::-webkit-scrollbar-thumb { background: var(--sc-gray); border-radius: 4px; }

.schat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 86%;
    animation: sc-msg-in 0.2s ease;
}

@keyframes sc-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.schat-msg-left { align-self: flex-start; }
.schat-msg-right { align-self: flex-end; flex-direction: row-reverse; }
.schat-msg-center { align-self: center; width: 100%; }

.schat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.schat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.schat-msg-body { display: flex; flex-direction: column; gap: 3px; }

.schat-bubble {
    padding: 9px 13px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.schat-msg-left  .schat-bubble { background: var(--sc-white); color: #050505; border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.schat-msg-right .schat-bubble { background: var(--sc-primary); color: var(--sc-white); border-bottom-right-radius: 4px; }
.schat-msg-center .schat-bubble { background: transparent; color: var(--sc-gray-text); font-size: 12px; font-style: italic; padding: 4px; box-shadow: none; text-align: center; }

.schat-msg-time { font-size: 10px; color: var(--sc-gray-text); padding: 0 4px; }

/* Botón speaker TTS */
.schat-speak-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--sc-gray-text);
    display: inline-flex;
    align-items: center;
    transition: color 0.2s;
    border-radius: 4px;
}
.schat-speak-btn:hover { color: var(--sc-primary); }
.schat-speak-btn.speaking { color: var(--sc-primary); animation: sc-speak-pulse 1s infinite; }
.schat-speak-btn svg { width: 14px; height: 14px; }

@keyframes sc-speak-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ── TYPING ── */
.schat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f9fafb;
    flex-shrink: 0;
}
.schat-typing-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.schat-typing-dots {
    background: var(--sc-white);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.schat-typing-dots span { width: 7px; height: 7px; background: var(--sc-gray-text); border-radius: 50%; animation: sc-typing 1.2s infinite; }
.schat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.schat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sc-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ── INPUT AREA ── */
.schat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--sc-gray);
    background: var(--sc-white);
    flex-shrink: 0;
}

/* Mic button */
.schat-mic-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: none !important;
    background: var(--sc-gray-light) !important;
    background-color: var(--sc-gray-light) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: background 0.2s;
    color: var(--sc-gray-text) !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
}
#schat-wrap .schat-mic-btn:hover { background: var(--sc-gray) !important; background-color: var(--sc-gray) !important; }
#schat-wrap .schat-mic-btn.recording {
    background: var(--sc-recording) !important;
    background-color: var(--sc-recording) !important;
    color: white !important;
    animation: sc-mic-pulse 1s infinite;
}
.schat-mic-btn.unsupported { opacity: 0.4 !important; cursor: not-allowed !important; }
.schat-mic-btn svg { width: 18px; height: 18px; }

@keyframes sc-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
    50%       { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
}

.schat-input {
    flex: 1;
    border: 1px solid var(--sc-gray);
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    color: #050505;
}
.schat-input:focus { border-color: var(--sc-primary); }

.schat-send-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: var(--sc-primary) !important;
    background-color: var(--sc-primary) !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: white !important;
}
#schat-wrap .schat-send-btn:hover { background: var(--sc-primary-dark) !important; background-color: var(--sc-primary-dark) !important; transform: scale(1.05); }
#schat-wrap .schat-send-btn:disabled { background: var(--sc-gray) !important; background-color: var(--sc-gray) !important; cursor: not-allowed !important; transform: none; }
.schat-send-btn svg { width: 16px; height: 16px; stroke: white; }

/* ── EMAIL CAPTURE ── */
.schat-email-capture {
    padding: 14px 16px;
    border-top: 1px solid var(--sc-gray);
    background: #f9fafb;
    font-size: 13px;
    flex-shrink: 0;
}
.schat-email-capture p { margin: 0 0 10px; color: #444; }
.schat-email-form { display: flex; gap: 8px; }
.schat-email-form input { flex: 1; border: 1px solid var(--sc-gray); border-radius: 20px; padding: 7px 12px; font-size: 13px; outline: none; }
.schat-email-form input:focus { border-color: var(--sc-primary); }
.schat-btn-primary { background: var(--sc-primary) !important; background-color: var(--sc-primary) !important; color: white !important; border: none !important; border-radius: 35px !important; padding: 7px 16px !important; font-size: 13px !important; font-weight: 600 !important; cursor: pointer !important; min-width: 0 !important; }
#schat-wrap .schat-btn-primary:hover { background: var(--sc-primary-dark) !important; background-color: var(--sc-primary-dark) !important; }
.schat-btn-link { background: none !important; background-color: transparent !important; border: none !important; color: var(--sc-gray-text) !important; font-size: 12px !important; cursor: pointer !important; display: block !important; margin-top: 8px !important; text-decoration: underline !important; padding: 0 !important; }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
    #schat-wrap { bottom: 16px; left: 16px; }
    .schat-window { width: calc(100vw - 32px); left: -8px; }
}

/* ── OCULTAR CHATBOT ANTIGUO cuando el nuevo Chat está activo ── */
#scbot-container { display: none !important; }

/* ── BURBUJA INTRODUCTORIA ── */
.sclc-bubble {
    position: fixed;
    bottom: 90px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border-radius: 35px;
    padding: 10px 16px 10px 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    cursor: pointer;
    z-index: 9998;
    animation: sclc-bubble-in 0.35s ease;
    border: 1px solid rgba(9,33,67,0.1);
    max-width: 220px;
}
@keyframes sclc-bubble-in {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.sclc-bubble-avatar { flex-shrink: 0; }
.sclc-bubble-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sc-primary, #092143);
    display: block;
}
.sclc-bubble-text {
    font-size: 13px;
    line-height: 1.3;
    color: #222;
    pointer-events: none;
}
.sclc-bubble-text strong { color: var(--sc-primary, #092143); display: block; }
.sclc-bubble-text span   { color: #555; }
.sclc-bubble-close {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #666;
    color: white;
    border: none;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 1;
}
.sclc-bubble-close:hover { background: #333; }
@media (max-width: 480px) {
    .sclc-bubble { bottom: 85px; left: 16px; max-width: 200px; }
}

/* ── PANTALLA NOMBRE ── */
.schat-name-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 24px 20px;
    gap: 14px;
}
.schat-name-label { font-size: 16px; font-weight: 600; color: #333; margin: 0; text-align: center; }
.schat-name-input {
    width: 100%;
    border: 2px solid var(--sc-gray);
    border-radius: 35px;
    padding: 10px 18px;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    text-align: center;
}
.schat-name-input:focus { border-color: var(--sc-primary); }
#schat-screen-name { display: flex; flex-direction: column; }

/* ── QUICK REPLIES ── */
.schat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--sc-gray);
}
.schat-qr-btn {
    background: transparent !important;
    border: 1.5px solid var(--sc-primary) !important;
    color: var(--sc-primary) !important;
    border-radius: 35px !important;
    padding: 6px 14px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.schat-qr-btn:hover {
    background: var(--sc-primary) !important;
    color: white !important;
}
