/* Susy - Widget chat mayorista. Reemplaza el flotante de WhatsApp. */
#susy-widget * { box-sizing: border-box; }
#susy-widget { position: fixed; bottom: 24px; right: 24px; z-index: 99999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* === Boton flotante con avatar de Susy === */
#susy-bubble {
    width: 82px; height: 82px; border-radius: 50%;
    background: linear-gradient(135deg, #6c3eb1, #4a2080);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 4px 20px rgba(108,62,177,0.5), 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s; border: 3px solid #fff;
    position: relative; padding: 0; overflow: visible;
    animation: susyAttention 8s ease-in-out infinite;
}
#susy-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(108,62,177,0.6), 0 3px 8px rgba(0,0,0,0.2);
    animation-play-state: paused;
}
#susy-bubble:active { transform: scale(0.96); }

/* Avatar circular dentro del boton (foto de Susy) */
#susy-bubble .susy-bubble-avatar {
    width: 100%; height: 100%; border-radius: 50%;
    background-image: url('../img/susy-avatar.webp');
    background-size: cover; background-position: center top;
    background-color: #ede2ff;
}
/* Nuke: dentro del bubble SOLO mostramos foto + dot online + tooltip + counter.
   Cualquier otro hijo (svg fallback de cache viejo, iconos de extensiones, etc.) se oculta. */
#susy-bubble > *:not(.susy-bubble-avatar):not(.susy-online-dot):not(.susy-tooltip):not(.susy-counter) {
    display: none !important;
}
#susy-bubble svg { display: none !important; }

/* Punto verde "online" pulsante */
#susy-bubble .susy-online-dot {
    position: absolute; bottom: 2px; right: 2px;
    width: 19px; height: 19px; border-radius: 50%;
    background: #4caf50; border: 2.5px solid #fff;
    box-shadow: 0 0 0 0 rgba(76,175,80,0.7);
    animation: susyOnlinePulse 2s ease-out infinite;
}
@keyframes susyOnlinePulse {
    0%   { box-shadow: 0 0 0 0 rgba(76,175,80,0.7); }
    70%  { box-shadow: 0 0 0 10px rgba(76,175,80,0); }
    100% { box-shadow: 0 0 0 0 rgba(76,175,80,0); }
}

/* Animacion sutil de "atencion": pulso cada 8 segundos */
@keyframes susyAttention {
    0%, 90%, 100% { transform: scale(1); }
    93%           { transform: scale(1.08); box-shadow: 0 4px 24px rgba(108,62,177,0.7); }
    96%           { transform: scale(0.97); }
}

/* Badge rojo (mensajes no leidos) - reposicionado para no chocar con dot verde */
#susy-bubble .susy-badge {
    position: absolute; top: -4px; right: -4px;
    background: #ff4757; color: #fff; border-radius: 50%;
    width: 24px; height: 24px; font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; z-index: 2;
}

/* === Tooltip al hover === */
#susy-bubble .susy-tooltip {
    position: absolute; right: 80px; top: 50%;
    transform: translateY(-50%);
    background: #2c1850; color: #fff;
    padding: 8px 14px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    white-space: nowrap;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
#susy-bubble .susy-tooltip::after {
    content: ''; position: absolute;
    right: -6px; top: 50%; transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #2c1850;
}
#susy-bubble:hover .susy-tooltip {
    opacity: 1; transform: translateY(-50%) translateX(0);
}

/* === Burbuja de bienvenida (aparece 8s despues de cargar) === */
#susy-welcome {
    position: absolute; bottom: 80px; right: 0;
    background: #fff; border-radius: 16px 16px 4px 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(108,62,177,0.15);
    padding: 14px 16px; padding-right: 32px;
    width: 280px; max-width: calc(100vw - 48px);
    font-size: 14px; line-height: 1.4; color: #222;
    cursor: pointer;
    opacity: 0; transform: translateY(10px) scale(0.95); pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    border-left: 4px solid #6c3eb1;
}
#susy-welcome.susy-welcome-visible {
    opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
    animation: susyWelcomeBounce 0.6s ease-out;
}
@keyframes susyWelcomeBounce {
    0%   { opacity: 0; transform: translateY(20px) scale(0.9); }
    60%  { opacity: 1; transform: translateY(-4px) scale(1.02); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
#susy-welcome strong { color: #4a2080; display: block; margin-bottom: 2px; }
#susy-welcome .susy-welcome-close {
    position: absolute; top: 6px; right: 8px;
    background: none; border: none; color: #999; cursor: pointer;
    font-size: 18px; line-height: 1; padding: 4px;
    border-radius: 50%; transition: background 0.15s;
}
#susy-welcome .susy-welcome-close:hover { background: #f0f0f0; color: #333; }

#susy-window {
    position: fixed; bottom: 100px; right: 24px;
    width: 380px; max-width: calc(100vw - 48px);
    height: 560px; max-height: calc(100vh - 130px);
    background: #fff; border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
}
#susy-window.susy-hidden { opacity: 0; pointer-events: none; transform: translateY(12px) scale(0.97); }

#susy-header {
    background: linear-gradient(135deg, #6c3eb1, #4a2080);
    color: white; padding: 14px 16px;
    display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
#susy-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background-image: url('../img/susy-avatar.webp');
    background-size: cover; background-position: center top;
    background-color: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
#susy-header-info { flex: 1; min-width: 0; }
#susy-header-name { font-weight: 700; font-size: 15px; }
#susy-header-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 5px; }
.susy-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #4caf50; }
.susy-dot.susy-busy { background: #ff9800; animation: susyPulse 1s infinite; }
@keyframes susyPulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
#susy-close { background: none; border: none; color: white; cursor: pointer; font-size: 22px; padding: 4px; opacity: 0.85; line-height: 1; }
#susy-close:hover { opacity: 1; }
#susy-clear { background: none; border: none; color: white; cursor: pointer; font-size: 18px; padding: 4px 6px; opacity: 0.75; line-height: 1; border-radius: 50%; transition: opacity 0.15s, background 0.15s; }
#susy-clear:hover { opacity: 1; background: rgba(255,255,255,0.15); }

#susy-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 10px; background: #fafafa;
}
#susy-messages::-webkit-scrollbar { width: 4px; }
#susy-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.susy-msg {
    max-width: 84%; padding: 9px 13px; border-radius: 14px;
    font-size: 14px; line-height: 1.45; word-break: break-word;
    animation: susyFade 0.2s ease; white-space: pre-wrap;
}
@keyframes susyFade { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }
.susy-msg.susy-user { align-self: flex-end; background: #6c3eb1; color: white; border-bottom-right-radius: 4px; }
.susy-msg.susy-bot { align-self: flex-start; background: white; color: #222; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.susy-msg.susy-bot a {
    display: inline-block;
    color: #fff !important;
    background: linear-gradient(135deg, #6c3eb1, #4a2080);
    text-decoration: none;
    word-break: break-word;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 14px;
    margin: 2px 2px;
    box-shadow: 0 1px 3px rgba(108,62,177,0.3);
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
    line-height: 1.35;
}
.susy-msg.susy-bot a::before { content: "🔗\00a0"; font-size: 11px; opacity: 0.9; }
.susy-msg.susy-bot a:hover { background: linear-gradient(135deg, #7e4dc4, #5a2da0); box-shadow: 0 2px 6px rgba(108,62,177,0.45); transform: translateY(-1px); text-decoration: none; }
.susy-msg.susy-bot a:visited { color: #fff !important; }
.susy-msg.susy-bot .susy-prod-img { display: block; max-width: 140px; max-height: 140px; width: auto; height: auto; border-radius: 8px; margin: 6px 0 4px 0; background: #f5f5f5; }
.susy-msg.susy-bot strong { font-weight: 700; }
.susy-msg.susy-system { align-self: center; background: none; color: #888; font-size: 12px; padding: 2px 8px; }

.susy-typing { display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: white; border-radius: 14px; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); align-self: flex-start; max-width: 90%; }
.susy-typing-dots { display: inline-flex; gap: 4px; align-items: center; flex-shrink: 0; }
.susy-typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: #ccc; display: inline-block; animation: susyTyping 1.2s infinite; }
.susy-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.susy-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
.susy-typing-msg { font-size: 12px; color: #888; transition: opacity 0.3s; }
@keyframes susyTyping { 0%,60%,100%{transform:none;background:#ccc} 30%{transform:translateY(-5px);background:#6c3eb1} }

#susy-input-area { padding: 12px; background: white; border-top: 1px solid #f0f0f0; display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0; }
#susy-input { flex: 1; border: 1.5px solid #e0e0e0; border-radius: 22px; padding: 10px 16px; font-size: 14px; outline: none; resize: none; max-height: 100px; font-family: inherit; transition: border-color 0.2s; line-height: 1.4; }
#susy-input:focus { border-color: #6c3eb1; }
#susy-input::placeholder { color: #bbb; }
#susy-send { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #6c3eb1, #4a2080); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform 0.15s, opacity 0.15s; }
#susy-send:hover { transform: scale(1.07); }
#susy-send:disabled { opacity: 0.5; cursor: default; transform: none; }
#susy-send svg { width: 20px; height: 20px; fill: white; margin-left: 2px; }
