/* ========================================================
   SISSA CHATBOT WIDGET - CSS ($0.00 Costo)
   Asistente Técnico Comercial de Ventas SISSA PERÚ
   ======================================================== */

:root {
    --sissa-orange: #ff6b00;
    --sissa-orange-hover: #ea580c;
    --sissa-dark: #0f172a;
    --sissa-dark-light: #1e293b;
    --sissa-green: #10b981;
    --sissa-gray-bg: #f8fafc;
    --sissa-border: #e2e8f0;
    --sissa-text-dark: #0f172a;
    --sissa-text-muted: #64748b;
}

/* 1. BOTÓN LANZADOR FLOTANTE */
.sissa-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.sissa-chat-launcher.chat-open {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
    visibility: hidden;
}

.sissa-launcher-bubble {
    background: #ffffff;
    color: var(--sissa-dark);
    padding: 10px 16px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
    border: 1px solid var(--sissa-border);
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 250px;
    line-height: 1.35;
    animation: sissaFloat 3s ease-in-out infinite;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.sissa-launcher-bubble .bubble-close {
    cursor: pointer;
    color: #94a3b8;
    font-size: 14px;
    margin-left: 4px;
    transition: color 0.2s;
}
.sissa-launcher-bubble .bubble-close:hover {
    color: #ef4444;
}

.sissa-launcher-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid var(--sissa-orange);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(255, 107, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    user-select: none;
    overflow: visible;
}

.sissa-launcher-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 34px rgba(255, 107, 0, 0.55);
    border-color: #ff8533;
}

.sissa-launcher-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.sissa-launcher-btn .sissa-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--sissa-green);
    border: 2.5px solid #0f172a;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
    animation: sissaPulse 2s infinite;
}

.sissa-launcher-badge {
    position: absolute;
    top: -3px;
    left: -3px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* 2. VENTANA DE CHAT */
.sissa-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
    border: 1px solid var(--sissa-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.sissa-chat-window.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* 3. ENCABEZADO DEL CHAT */
.sissa-chat-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--sissa-orange);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.sissa-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sissa-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid var(--sissa-orange);
    box-shadow: 0 4px 10px rgba(255, 107, 0, 0.4);
    flex-shrink: 0;
}

.sissa-header-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.sissa-header-avatar .header-online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--sissa-green);
    border: 2px solid #0f172a;
}

.sissa-header-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sissa-verified-icon {
    color: #38bdf8;
    width: 15px;
    height: 15px;
}

.sissa-header-info p {
    margin: 3px 0 0 0;
    font-size: 0.74rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sissa-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sissa-action-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.sissa-action-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.sissa-action-btn.btn-wa-header {
    background: #25D366;
    border-color: #25D366;
}
.sissa-action-btn.btn-wa-header:hover {
    background: #20ba59;
}

/* 4. CUERPO DE MENSAJES */
.sissa-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: var(--sissa-gray-bg);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.sissa-chat-body::-webkit-scrollbar {
    width: 5px;
}
.sissa-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Burbujas */
.sissa-msg-row {
    display: flex;
    gap: 10px;
    max-width: 90%;
}
.sissa-msg-row.bot {
    align-self: flex-start;
}
.sissa-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.sissa-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1.5px solid var(--sissa-orange);
    overflow: hidden;
}

.sissa-avatar-photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.sissa-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.sissa-msg-row.bot .sissa-msg-bubble {
    background: #ffffff;
    color: var(--sissa-text-dark);
    border: 1px solid var(--sissa-border);
    border-top-left-radius: 4px;
}

.sissa-msg-row.user .sissa-msg-bubble {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
}

.sissa-msg-time {
    font-size: 0.68rem;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
}

/* 5. TARJETAS DE PRODUCTO DENTRO DEL CHAT */
.sissa-products-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.sissa-product-card {
    background: #ffffff;
    border: 1px solid var(--sissa-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    transition: transform 0.2s, border-color 0.2s;
}
.sissa-product-card:hover {
    border-color: var(--sissa-orange);
    transform: translateY(-2px);
}

.sissa-card-top {
    display: flex;
    gap: 12px;
    align-items: center;
}

.sissa-card-img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #f1f5f9;
    background: #ffffff;
    flex-shrink: 0;
}

.sissa-card-details {
    flex: 1;
    min-width: 0;
}

.sissa-card-brand {
    display: inline-block;
    background: #f1f5f9;
    color: var(--sissa-orange);
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 3px;
}

.sissa-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--sissa-text-dark);
    margin: 0 0 4px 0;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sissa-card-prices {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.sissa-card-price-main {
    font-size: 1.05rem;
    font-weight: 900;
    color: #0f172a;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.sissa-card-promo-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 600;
    margin-top: 4px;
    display: inline-block;
    line-height: 1.35;
}
.sissa-card-promo-badge strong {
    color: #b45309;
    font-weight: 800;
}

.sissa-card-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.sissa-btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
}

.sissa-btn-ficha {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}
.sissa-btn-ficha:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.sissa-btn-buy {
    background: #ff6b00;
    color: #ffffff !important;
    border: 1px solid #ea580c;
}
.sissa-btn-buy:hover {
    background: #ea580c;
}

/* 6. CHIPS DE ACCESO RÁPIDO */
.sissa-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.sissa-chip {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.sissa-chip:hover {
    background: var(--sissa-orange);
    color: #ffffff;
    border-color: var(--sissa-orange);
    transform: translateY(-1px);
}

/* 7. INDICADOR DE ESCRIBIENDO */
.sissa-typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--sissa-border);
    border-radius: 14px;
    width: fit-content;
    border-top-left-radius: 4px;
    margin-bottom: 6px;
}
.sissa-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: sissaTyping 1.4s infinite ease-in-out both;
}
.sissa-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.sissa-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* 8. FOOTER / INPUT */
.sissa-chat-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid var(--sissa-border);
}

.sissa-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border: 1.5px solid #cbd5e1;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sissa-input-form:focus-within {
    border-color: var(--sissa-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
    background: #ffffff;
}

.sissa-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.88rem;
    color: var(--sissa-text-dark);
    outline: none;
    font-family: inherit;
}
.sissa-chat-input::placeholder {
    color: #94a3b8;
}

.sissa-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sissa-orange);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.sissa-send-btn:hover {
    background: var(--sissa-orange-hover);
    transform: scale(1.05);
}
.sissa-send-btn svg {
    width: 17px;
    height: 17px;
    margin-left: 2px;
}

.sissa-footer-tagline {
    font-size: 0.65rem;
    color: #94a3b8;
    text-align: center;
    margin-top: 6px;
    font-weight: 600;
}

/* ANIMACIONES */
@keyframes sissaFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes sissaPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes sissaTyping {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* RESPONSIVE MÓVIL */
@media (max-width: 480px) {
    .sissa-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .sissa-chat-launcher {
        bottom: 18px;
        right: 18px;
    }
    .sissa-launcher-bubble {
        display: none;
    }
}
