/* AI GNLBot - Estilos Modernos v2.0 */
:root {
    --chatbot-primary: #001E3D;
    --chatbot-secondary: #8BC34A;
    --chatbot-primary-light: rgba(0, 30, 61, 0.1);
    --chatbot-secondary-light: rgba(139, 195, 74, 0.1);
    --chatbot-shadow: 0 20px 60px rgba(0, 30, 61, 0.3);
    --chatbot-shadow-hover: 0 25px 80px rgba(0, 30, 61, 0.4);
    --chatbot-gradient-primary: linear-gradient(135deg, var(--chatbot-primary) 0%, #003366 100%);
    --chatbot-gradient-secondary: linear-gradient(135deg, var(--chatbot-secondary) 0%, #7CB342 100%);
    --chatbot-gradient-mixed: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
}

/* Widget Principal del Chatbot */
.ai-chatbot-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: #ffffff;
    border-radius: var(--chatbot-border-radius, 20px);
    box-shadow: var(--chatbot-shadow);
    z-index: 999999;
    display: none;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chatbot-widget.show {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* Botón Flotante Toggle */
.ai-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    background: var(--chatbot-gradient-mixed);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chatbot-shadow);
    z-index: 1000000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.ai-chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--chatbot-shadow-hover);
}

.ai-chatbot-toggle:active {
    transform: scale(0.95);
}

.ai-chatbot-toggle img,
.ai-chatbot-toggle svg {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
    transition: transform 0.3s ease;
}

.ai-chatbot-toggle:hover img,
.ai-chatbot-toggle:hover svg {
    transform: scale(1.1);
}

/* Header del Chat */
.ai-chatbot-header {
    background: var(--chatbot-gradient-primary);
    color: white;
    padding: 25px 20px;
    border-radius: var(--chatbot-border-radius, 20px) var(--chatbot-border-radius, 20px) 0 0;
    position: relative;
    text-align: center;
}

.ai-chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="50" cy="50" r="1" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.ai-chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.ai-chatbot-header .status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--chatbot-secondary);
    border-radius: 50%;
    margin-left: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Botón de Cerrar */
.ai-chatbot-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ai-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Área de Mensajes */
.ai-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    position: relative;
}

.ai-chatbot-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, rgba(248, 249, 250, 1), rgba(248, 249, 250, 0));
    pointer-events: none;
    z-index: 1;
}

/* Scrollbar personalizado */
.ai-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chatbot-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-primary);
    border-radius: 3px;
    opacity: 0.5;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    opacity: 0.8;
}

/* Mensajes */
.ai-message, .user-message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    animation: messageSlide 0.4s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.message-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.ai-message .message-bubble {
    background: white;
    color: var(--chatbot-primary);
    border-bottom-left-radius: 8px;
    border: 2px solid var(--chatbot-primary-light);
    font-weight: 500;
}

.ai-message .message-bubble::before {
    content: '🤖';
    position: absolute;
    left: -35px;
    bottom: 0;
    width: 28px;
    height: 28px;
    background: var(--chatbot-gradient-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.user-message .message-bubble {
    background: var(--chatbot-gradient-primary);
    color: white;
    border-bottom-right-radius: 8px;
    font-weight: 500;
}

.user-message .message-bubble::before {
    content: '👤';
    position: absolute;
    right: -35px;
    bottom: 0;
    width: 28px;
    height: 28px;
    background: var(--chatbot-gradient-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Área de Input */
.ai-chatbot-input-area {
    padding: 25px 20px;
    border-top: 1px solid rgba(0, 30, 61, 0.1);
    background: white;
    border-radius: 0 0 var(--chatbot-border-radius, 20px) var(--chatbot-border-radius, 20px);
}

.ai-chatbot-input {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.ai-chatbot-input input {
    flex: 1;
    border: 2px solid var(--chatbot-primary-light);
    border-radius: 25px;
    padding: 14px 20px;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(10px);
}

.ai-chatbot-input input:focus {
    border-color: var(--chatbot-primary);
    background: white;
    box-shadow: 0 0 0 3px var(--chatbot-primary-light);
}

.ai-chatbot-input input::placeholder {
    color: rgba(0, 30, 61, 0.5);
    font-weight: 400;
}

.ai-chatbot-send {
    background: var(--chatbot-gradient-mixed);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 30, 61, 0.3);
}

.ai-chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 30, 61, 0.4);
}

.ai-chatbot-send:active {
    transform: scale(0.95);
}

.ai-chatbot-send svg {
    width: 22px;
    height: 22px;
    fill: white;
    transition: transform 0.3s ease;
}

.ai-chatbot-send:hover svg {
    transform: translateX(2px);
}

/* Indicador de Escritura */
.typing-indicator {
    display: none;
    padding: 15px 0;
    animation: messageSlide 0.4s ease-out;
}

.typing-indicator.show {
    display: block;
}

.typing-dots {
    display: inline-flex;
    gap: 6px;
    padding: 12px 16px;
    background: white;
    border-radius: 20px;
    border: 2px solid var(--chatbot-primary-light);
    margin-left: 15px;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--chatbot-primary);
    animation: typing 1.6s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typing {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    } 
    40% { 
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Animaciones de Entrada */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.05) rotate(5deg);
    }
    70% {
        transform: scale(0.9) rotate(-2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.ai-chatbot-widget.animation-smooth {
    animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chatbot-widget.animation-bounce {
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Responsive Design */
@media (max-width: 480px) {
    .ai-chatbot-widget {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        bottom: 10px;
        right: 10px;
        left: 10px;
        top: 10px;
        border-radius: 15px;
    }
    
    .ai-chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }
    
    .ai-chatbot-toggle img,
    .ai-chatbot-toggle svg {
        width: 28px;
        height: 28px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .ai-chatbot-header {
        padding: 20px 15px;
    }
    
    .ai-chatbot-messages {
        padding: 15px;
    }
    
    .ai-chatbot-input-area {
        padding: 20px 15px;
    }
}

@media (max-width: 320px) {
    .ai-chatbot-widget {
        width: calc(100vw - 10px);
        height: calc(100vh - 10px);
        bottom: 5px;
        right: 5px;
        left: 5px;
        top: 5px;
    }
}

/* Estados especiales */
.ai-chatbot-widget.loading .ai-chatbot-send {
    background: #cccccc;
    cursor: not-allowed;
    pointer-events: none;
}

.ai-chatbot-widget.error .ai-chatbot-header {
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 100%);
}

/* Personalización dinámica de colores */
.ai-chatbot-widget[data-primary-color] {
    --chatbot-primary: attr(data-primary-color);
}

.ai-chatbot-widget[data-secondary-color] {
    --chatbot-secondary: attr(data-secondary-color);
}

/* Efectos de hover modernos */
.ai-chatbot-widget {
    will-change: transform, opacity;
}

.message-bubble {
    will-change: transform, box-shadow;
}

.ai-chatbot-toggle {
    will-change: transform, box-shadow;
}
