/* Chatbot Flotante - Estilos */

.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Badge de ayuda */
.chatbot-help-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 10px 16px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.5s ease-out, pulseGlow 2s ease-in-out infinite 1s;
    opacity: 0;
    animation-fill-mode: forwards;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    pointer-events: auto;
}

.chatbot-help-badge:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 20px rgba(0, 45, 98, 0.3);
}

.chatbot-help-badge.hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

.chatbot-help-text {
    font-size: 14px;
    font-weight: 600;
    color: #002D62;
    white-space: nowrap;
}

.chatbot-help-badge i {
    color: #CE1126;
    font-size: 16px;
    animation: bounceArrow 1.5s ease-in-out infinite;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0, 45, 98, 0.2);
    }
    50% {
        box-shadow: 0 4px 20px rgba(0, 45, 98, 0.4), 0 0 15px rgba(0, 45, 98, 0.2);
    }
}

@keyframes bounceArrow {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-5px);
    }
}

/* Botón flotante para abrir el chatbot */
.chatbot-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #002D62 0%, #CE1126 100%);
    border: 3px solid white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(0, 45, 98, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    animation: bounceIn 0.6s ease-out, pulseRing 2s ease-out infinite 0.6s;
}

.chatbot-toggle:hover {
    transform: scale(1.15);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 0 8px rgba(0, 45, 98, 0.1);
}

.chatbot-toggle:active {
    transform: scale(1.05);
}

/* Efecto de onda/ripple */
.chatbot-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    animation: ripple 2s ease-out infinite;
    pointer-events: none;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(50px);
    }
    50% {
        transform: scale(1.05) translateY(-10px);
    }
    70% {
        transform: scale(0.9) translateY(5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes pulseRing {
    0% {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(0, 45, 98, 0.4);
    }
    50% {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 10px rgba(0, 45, 98, 0);
    }
    100% {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(0, 45, 98, 0);
    }
}

@keyframes ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

.chatbot-toggle .chatbot-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 50%;
    padding: 5px;
    position: relative;
    z-index: 2;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

.chatbot-toggle i {
    font-size: 32px;
    color: white;
    position: relative;
    z-index: 2;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4444;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
    animation: pulse 2s infinite;
}

.chatbot-notification.show {
    display: block;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Ventana del chatbot */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-window.open {
    display: flex;
}

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

/* Header del chatbot */
.chatbot-header {
    background: linear-gradient(135deg, #002D62 0%, #CE1126 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px;
}

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

.chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-subtitle {
    opacity: 0.9;
    font-size: 12px;
}

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

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

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

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

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

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.chatbot-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message-user {
    flex-direction: row-reverse;
}

.chatbot-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.chatbot-message-bot .chatbot-avatar {
    background: linear-gradient(135deg, #002D62 0%, #CE1126 100%);
}

.chatbot-message-user .chatbot-avatar {
    background: #6c757d;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 5px;
}

.chatbot-avatar i {
    color: white;
    font-size: 18px;
}

.chatbot-message-content {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chatbot-message-bot .chatbot-message-content {
    background: white;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.chatbot-message-user .chatbot-message-content {
    background: linear-gradient(135deg, #002D62 0%, #CE1126 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-content p {
    margin: 0 0 10px 0;
    line-height: 1.6;
    font-size: 14px;
    color: inherit;
}

.chatbot-message-content p:last-child {
    margin-bottom: 0;
}

/* Estilos para listas */
.chatbot-message-content ol,
.chatbot-message-content ul {
    margin: 12px 0;
    padding-left: 0;
    line-height: 1.7;
    list-style-position: outside;
}

.chatbot-message-content ol {
    list-style-type: decimal;
    padding-left: 28px;
    margin-left: 4px;
}

.chatbot-message-content ul {
    list-style-type: disc;
    padding-left: 24px;
    margin-left: 4px;
}

.chatbot-message-content li {
    margin: 10px 0;
    padding-left: 4px;
    line-height: 1.7;
    font-size: 14px;
    color: inherit;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chatbot-message-content li:first-child {
    margin-top: 4px;
}

.chatbot-message-content li:last-child {
    margin-bottom: 4px;
}

.chatbot-message-content li strong {
    font-weight: 600;
    color: inherit;
}

/* Mejorar espaciado entre listas y párrafos */
.chatbot-message-content ol + p,
.chatbot-message-content ul + p,
.chatbot-message-content p + ol,
.chatbot-message-content p + ul {
    margin-top: 12px;
}

/* Texto en negrita */
.chatbot-message-content strong {
    font-weight: 600;
    color: inherit;
}

/* Espaciado entre párrafos y elementos */
.chatbot-message-content > *:first-child {
    margin-top: 0;
}

.chatbot-message-content > *:last-child {
    margin-bottom: 0;
}

/* Mejorar visualización de texto largo */
.chatbot-message-content {
    text-align: left;
    hyphens: auto;
}

/* Input container */
.chatbot-input-container {
    padding: 15px 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chatbot-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.chatbot-input:focus {
    border-color: #002D62;
    box-shadow: 0 0 0 3px rgba(0, 45, 98, 0.1);
}

.chatbot-send {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #002D62 0%, #CE1126 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 45, 98, 0.3);
}

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

.chatbot-send i {
    font-size: 18px;
}

/* Indicador de escritura */
.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 10px 0;
    justify-content: center;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    background: #002D62;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Responsive */
@media (max-width: 768px) {
    .chatbot-help-badge {
        display: none; /* Ocultar badge en móvil para ahorrar espacio */
    }
    
    .chatbot-container {
        gap: 0;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
        border-radius: 15px;
    }
    
    .chatbot-toggle {
        width: 60px;
        height: 60px;
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-toggle .chatbot-logo {
        width: 45px;
        height: 45px;
    }
    
    .chatbot-help-badge {
        display: none;
    }
}

/* Animación de entrada para nuevos mensajes */
.chatbot-message.new-message {
    animation: slideInMessage 0.3s ease;
}

@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
