/* SP Assistant - Chatbot Widget */
#sp-chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

#sp-chatbot-widget.sp-position-right {
    bottom: 20px;
    right: 20px;
}

#sp-chatbot-widget.sp-position-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.sp-chatbot-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 50px;
    border: none;
    background: var(--sp-primary, #2563eb);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
}

.sp-chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.sp-toggle-icon {
    font-size: 18px;
}

/* Chat Container */
.sp-chatbot-container {
    display: none;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    animation: sp-chat-in 0.3s ease;
    position: relative;
}

@keyframes sp-chat-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#sp-chatbot-widget.sp-open .sp-chatbot-container {
    display: flex;
}

#sp-chatbot-widget.sp-open .sp-chatbot-toggle {
    display: none;
}

/* Header */
.sp-chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--sp-primary, #2563eb);
    color: #fff;
}

.sp-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.sp-chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sp-chatbot-avatar span {
    font-size: 20px;
}

.sp-chatbot-info {
    flex: 1;
}

.sp-chatbot-name {
    font-weight: 700;
    font-size: 15px;
}

.sp-chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sp-chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.sp-chatbot-close:hover {
    opacity: 1;
}

/* Messages Area */
.sp-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.sp-message {
    max-width: 85%;
    animation: sp-msg-in 0.3s ease;
}

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

.sp-message-content {
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.sp-message-bot .sp-message-content {
    background: #fff;
    color: #1e293b;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sp-message-user .sp-message-content {
    background: var(--sp-primary, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.sp-message-user {
    align-self: flex-end;
}

.sp-message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.sp-message-user .sp-message-time {
    text-align: right;
}

/* Typing Indicator */
.sp-chatbot-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8fafc;
}

.sp-typing-dots {
    display: flex;
    gap: 4px;
}

.sp-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--sp-primary, #2563eb);
    border-radius: 50%;
    animation: sp-bounce 1.4s infinite ease-in-out both;
}

.sp-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.sp-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

.sp-typing-text {
    font-size: 12px;
    color: #64748b;
}

/* Input Area */
.sp-chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.sp-chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.sp-chatbot-input:focus {
    border-color: var(--sp-primary, #2563eb);
}

.sp-chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--sp-primary, #2563eb);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sp-chatbot-send:hover {
    background: var(--sp-secondary, #1e40af);
}

/* Lead Capture Form */
.sp-lead-form {
    background: #fff;
    border: 2px solid var(--sp-primary, #2563eb);
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
}

.sp-lead-form h4 {
    margin: 0 0 12px 0;
    color: var(--sp-primary, #2563eb);
    font-size: 14px;
}

.sp-lead-form input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    box-sizing: border-box;
}

.sp-lead-form input:focus {
    border-color: var(--sp-primary, #2563eb);
    outline: none;
}

.sp-lead-form button {
    width: 100%;
    padding: 10px;
    background: var(--sp-primary, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

.sp-lead-form button:hover {
    background: var(--sp-secondary, #1e40af);
}

/* Responsive */
@media (max-width: 480px) {
    .sp-chatbot-container {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        position: fixed;
        top: 0;
        margin: 0;
    }

    /* Respetar posición configurada */
    #sp-chatbot-widget.sp-position-right .sp-chatbot-container {
        right: 0;
        left: auto;
    }

    #sp-chatbot-widget.sp-position-left .sp-chatbot-container {
        left: 0;
        right: auto;
    }

    #sp-chatbot-widget.sp-position-right {
        bottom: 0;
        right: 0;
        left: auto;
    }

    #sp-chatbot-widget.sp-position-left {
        bottom: 0;
        left: 0;
        right: auto;
    }

    .sp-chatbot-messages {
        padding-bottom: 80px;
    }

    .sp-chatbot-input-area {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-top: 1px solid #e2e8f0;
        padding: 12px 16px;
        z-index: 10;
    }

    .sp-chatbot-input {
        font-size: 16px;
    }
}
