/* Assistant Chatbot Styles */

/* Variables CSS */
:root {
    --assistant-primary-color: #007bff;
    --assistant-secondary-color: #6c757d;
    --assistant-bg-light: #f8f9fa;
    --assistant-bg-white: #ffffff;
    --assistant-border-color: #e1e5e9;
    --assistant-text-dark: #333333;
    --assistant-text-muted: #666666;
    --assistant-text-light: #999999;
    --assistant-close-red: #DC2626;
    --assistant-close-red-dark: #B91C1C;
    --assistant-success-green: #4ade80;
    --dynamic-primary-color: var(--assistant-primary-color);
}

/* Chatbot Widget */
#assistant-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    width: 60px;
    height: 60px;
}

#assistant-chatbot-toggle {
    width: 60px;
    height: 60px;
    background: var(--dynamic-primary-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    border: 2px solid rgba(255,255,255,0.3);
}

#assistant-chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

#chatbot-icon {
    font-size: 24px;
    transition: all 0.3s ease;
}

#assistant-chatbot-toggle div {
    font-size: 9px;
    text-align: center;
    margin-top: 2px;
    font-weight: 500;
}

#notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: var(--assistant-close-red);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: white;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(220,38,38,0.4);
    animation: notificationPulse 2s infinite;
}

/* Chatbot Window */
#assistant-chatbot-window, #assistant-chatbot-window * { box-sizing: border-box; }
#assistant-chatbot-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    height: 620px;
    background: var(--assistant-bg-white);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.1);
    transform: translateY(30px) scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

/* Header */
.chat-header {
    background: var(--dynamic-primary-color);
    color: white;
    padding: 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.chat-header-left { display: flex; align-items: center; gap: 12px; }

.chat-avatar {
    width: 40px; height: 40px; background: rgba(255,255,255,0.2); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; border: 2px solid rgba(255,255,255,0.3);
}
.chat-avatar i { font-size: 16px; color: white; }

.chat-title h4 { margin: 0; font-size: 16px; font-weight: 600; }
.chat-title small { opacity: 0.9; font-size: 12px; display: flex; align-items: center; gap: 4px; }
.chat-title small span { width: 6px; height: 6px; border-radius: 50%; background: var(--assistant-success-green); }

.chat-close-btn {
    background: rgba(255,255,255,0.2); border: none; color: white; font-size: 16px; cursor: pointer;
    width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.3); }

/* Messages Area */
#assistant-chatbot-messages {
    flex: 1 1 auto;
    padding: 20px;
    overflow-y: auto;
    background: var(--assistant-bg-light);
}

/* Close Conversation Button Area */
.close-area {
    padding: 15px;
    text-align: center;
    border-top: 1px solid #eee;
    background: var(--assistant-bg-light);
}

#close-conversation-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--assistant-close-red) 0%, var(--assistant-close-red-dark) 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(220,38,38,0.4);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#close-conversation-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(220,38,38,0.5);
}

#close-conversation-btn i {
    font-size: 14px;
}

/* Input Area */
#assistant-chatbot-window > div:nth-child(4) {
    padding: 20px;
    border-top: 1px solid #ddd;
    background: var(--assistant-bg-white);
    border-radius: 0 0 20px 20px;
    /* Mantener dentro del flujo, evitar que se salga del contenedor */
}

.assistant-chatbot-input-area { width: 100%; }
.assistant-chatbot-input-container {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    flex-wrap: nowrap;
    margin-top: 12px;
}

#assistant-chatbot-input {
    flex: 1 1 auto;
    min-width: 0; /* permite que el input reduzca sin romper layout */
    padding: 14px 16px;
    border: 2px solid var(--assistant-border-color);
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#assistant-chatbot-input:focus {
    border-color: var(--dynamic-primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#send-button {
    padding: 14px 20px;
    background: var(--dynamic-primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto; /* no se encoge ni se parte en otra línea */
    white-space: nowrap;
}

#send-button:hover {
    background: #0056a3;
}

#send-button i {
    font-size: 12px;
}

.assistant-chatbot-input-hint {
    font-size: 12px;
    color: var(--assistant-text-muted);
    text-align: center;
    margin-top: 12px;
    opacity: 0.7;
}

/* Continuation Buttons */
#continuation-buttons {
    padding: 20px;
    text-align: center;
}

#continuation-buttons > div:first-child {
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--assistant-text-muted);
}

#continuation-buttons > div:first-child i {
    margin-right: 8px;
}

#continuation-buttons > div:nth-child(2) {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

#continuation-buttons button {
    padding: 12px 20px;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

#continuation-buttons button:first-child {
    background: linear-gradient(135deg, var(--dynamic-primary-color) 0%, var(--dynamic-primary-color)dd 100%);
}

#continuation-buttons button:last-child {
    background: var(--assistant-secondary-color);
}

#continuation-buttons > div:last-child {
    margin-top: 15px;
    font-size: 12px;
    color: var(--assistant-text-light);
}

/* Messages */
.assistant-message, .user-message {
    margin-bottom: 16px;
    max-width: 80%;
    position: relative;
    animation: messageSlideIn 0.3s ease-out;
}

.assistant-message {
    margin-right: auto;
    margin-left: 0;
    display: flex;
    justify-content: flex-start;
}

.user-message {
    margin-left: auto;
    margin-right: 0;
    display: flex;
    justify-content: flex-end;
}

.message-content {
    padding: 16px 18px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-width: 280px;
    position: relative;
}

.assistant-message .message-content {
    background: var(--assistant-bg-white);
    color: var(--assistant-text-dark);
    border-radius: 18px 18px 18px 4px;
    border-left: 3px solid var(--dynamic-primary-color);
}

.user-message .message-content {
    background: var(--assistant-primary-color);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.assistant-message .message-tail {
    position: absolute;
    bottom: -6px;
    left: 18px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--assistant-bg-light);
}

.user-message .message-tail {
    position: absolute;
    bottom: -6px;
    right: 18px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--assistant-primary-color);
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 6px;
    font-weight: 500;
}

.assistant-message .message-time {
    text-align: left;
}

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

.message-time span {
    font-size: 10px;
    margin-right: 4px;
}

/* Typing Indicator */
.typing-indicator {
    margin-bottom: 16px;
    max-width: 80%;
    margin-right: auto;
    margin-left: 0;
}

.typing-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--assistant-bg-white);
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

.typing-dots div {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dynamic-primary-color) 0%, var(--dynamic-primary-color)80 100%);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots div:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots div:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-content span {
    font-size: 14px;
    color: var(--assistant-text-muted);
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.typing-tail {
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--assistant-bg-light);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

/* Animations */
@keyframes notificationPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Dynamic Elements */
#typing-indicator-wrapper {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 24px;
    display: flex;
    justify-content: flex-start;
}

/* Responsive */
@media (max-width: 480px) {
    #assistant-chatbot-window {
        width: 90vw;
        max-width: 380px;
        height: 80vh;
        max-height: 620px;
    }

    #continuation-buttons > div:nth-child(2) {
        flex-direction: column;
    }

    #continuation-buttons button {
        width: 100%;
        justify-content: center;
    }
}
