/* ============================================
   Chatbot Widget - Estilos
   ============================================ */

.chatbot-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5a27 0%, #1e3a8a 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.chatbot-toggle-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #dc3545;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-toggle-btn.chatbot-open .bi-chat-dots-fill {
    display: none;
}

.chatbot-toggle-btn.chatbot-open .bi-x-lg {
    display: block;
}

.chatbot-toggle-btn:not(.chatbot-open) .bi-x-lg {
    display: none;
}

@keyframes chatbotPulse {
    0% { box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(45, 90, 39, 0.4); }
    70% { box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 0 15px rgba(45, 90, 39, 0); }
    100% { box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(45, 90, 39, 0); }
}

.chatbot-toggle-btn:not(.chatbot-open) {
    animation: chatbotPulse 2.5s infinite;
}

.chatbot-dismiss-btn {
    position: fixed;
    bottom: 74px;
    right: 18px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.2s ease;
    padding: 0;
}

#chatbot-widget:hover .chatbot-dismiss-btn,
.chatbot-dismiss-btn:focus {
    opacity: 1;
}

.chatbot-dismiss-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Panel de Chat */
.chatbot-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 130px);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.chatbot-panel.chatbot-visible {
    display: flex;
}

.chatbot-panel-header {
    background: linear-gradient(135deg, #2d5a27 0%, #1e3a8a 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-panel-header i {
    font-size: 22px;
}

.chatbot-panel-header-text h6 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.chatbot-panel-header-text small {
    font-size: 12px;
    opacity: 0.85;
}

.chatbot-panel-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    padding: 4px;
    line-height: 1;
}

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

/* Área de Mensajes */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Burbujas de Chat */
.chatbot-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-line;
}

.chatbot-bubble-bot {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatbot-bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2d5a27, #1e3a8a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-bubble-link {
    display: block;
    margin-top: 8px;
    padding: 6px 14px;
    background: linear-gradient(135deg, #2d5a27, #1e3a8a);
    color: #fff !important;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.chatbot-bubble-link:hover {
    opacity: 0.9;
    color: #fff !important;
}

/* Botones Rápidos */
.chatbot-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chatbot-quick-btn {
    padding: 6px 14px;
    border: 1px solid #2d5a27;
    background: #fff;
    color: #2d5a27;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-quick-btn:hover {
    background: #2d5a27;
    color: #fff;
}

/* Indicador de Escribiendo */
.chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatbot-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: chatbotTypingBounce 1.4s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: 0s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbotTypingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

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

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

.chatbot-input:focus {
    border-color: #2d5a27;
}

.chatbot-input::placeholder {
    color: #adb5bd;
}

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d5a27, #1e3a8a);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.chatbot-send-btn:hover {
    opacity: 0.9;
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Botón Volver al Menú */
.chatbot-back-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.chatbot-back-btn {
    padding: 6px 16px;
    border: none;
    background: #e9ecef;
    color: #495057;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-back-btn:hover {
    background: #dee2e6;
    color: #212529;
}

/* Popup de Ayuda */
.chatbot-help-popup {
    position: fixed;
    bottom: 92px;
    right: 92px;
    background: #fff;
    color: #333;
    padding: 10px 36px 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    cursor: pointer;
    z-index: 9997;
    animation: chatbotHelpSlideIn 0.4s ease forwards;
    max-width: 220px;
    line-height: 1.4;
}

.chatbot-help-popup-text {
    display: block;
}

.chatbot-help-popup-close {
    position: absolute;
    top: 2px;
    right: 4px;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    color: #555;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}

.chatbot-help-popup-close:hover {
    background: rgba(0, 0, 0, 0.15);
    color: #333;
}

.chatbot-help-popup-hiding {
    animation: chatbotHelpSlideOut 0.3s ease forwards;
}

@keyframes chatbotHelpSlideIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes chatbotHelpSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chatbot-toggle-btn {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 22px;
    }

    .chatbot-panel {
        bottom: 80px;
    }

    .chatbot-help-popup {
        bottom: 80px;
        right: 80px;
        max-width: 200px;
        font-size: 13px;
    }

    .chatbot-dismiss-btn {
        bottom: 62px;
        right: 10px;
        opacity: 1;
    }
}
