/* =============================================================================
   Sales Chat Widget - Educativa Studio
   ============================================================================= */

/* --- Bubble (FAB) --- */
.sc-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #267579, #1a5557);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(38, 117, 121, 0.45);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.sc-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(38, 117, 121, 0.55);
}
.sc-bubble svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    transition: opacity 0.2s ease;
}
.sc-bubble .sc-icon-close { display: none; }
.sc-bubble.sc-open .sc-icon-chat { display: none; }
.sc-bubble.sc-open .sc-icon-close { display: block; }

/* --- Unread badge --- */
.sc-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #F1870F;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
.sc-bubble.sc-unread .sc-badge { display: block; }

/* --- Panel --- */
.sc-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.sc-panel.sc-visible {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* --- Header --- */
.sc-header {
    background: linear-gradient(135deg, #267579, #1a5557);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sc-header-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.sc-header-info { flex: 1; min-width: 0; }
.sc-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}
.sc-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.3;
}

/* --- Messages area --- */
.sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.sc-messages::-webkit-scrollbar { width: 5px; }
.sc-messages::-webkit-scrollbar-track { background: transparent; }
.sc-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* --- Message bubbles --- */
.sc-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: sc-msg-in 0.2s ease;
}
.sc-msg-user {
    align-self: flex-end;
    background: #267579;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sc-msg-bot {
    align-self: flex-start;
    background: #f1f3f5;
    color: #1a202c;
    border-bottom-left-radius: 4px;
}

/* Links inside bot messages */
.sc-msg-bot a {
    color: #267579;
    text-decoration: underline;
}

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

/* --- Typing indicator --- */
.sc-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 16px;
    background: #f1f3f5;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.sc-typing.sc-visible { display: flex; gap: 4px; align-items: center; }
.sc-typing-dot {
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: sc-dot-bounce 1.2s infinite ease-in-out;
}
.sc-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.sc-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes sc-dot-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- Input area --- */
.sc-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #fff;
}
.sc-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.2s;
}
.sc-input:focus { border-color: #267579; }
.sc-input::placeholder { color: #9ca3af; }

.sc-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #267579;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, opacity 0.2s;
}
.sc-send:hover { background: #1a5557; }
.sc-send:disabled { opacity: 0.5; cursor: not-allowed; }
.sc-send svg { width: 18px; height: 18px; fill: currentColor; }

/* --- Footer with WhatsApp --- */
.sc-powered {
    text-align: center;
    padding: 8px 12px;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}
.sc-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #25D366;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 16px;
    transition: background 0.2s, color 0.2s;
}
.sc-whatsapp:hover {
    background: rgba(37, 211, 102, 0.1);
    color: #1da851;
}
.sc-whatsapp i {
    font-size: 16px;
}

/* --- Responsive mobile --- */
@media (max-width: 768px) {
    .sc-bubble {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
    .sc-bubble svg { width: 22px; height: 22px; }
    .sc-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100dvh;
    }
    .sc-panel.sc-visible {
        position: fixed;
        top: 0;
    }
}
