/* Chatbot Widget Styles */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Open Sans', sans-serif;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #0670d4, #045FB4 50%, #034a8d 100%);
    border: none;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 8px 24px rgba(4, 95, 180, 0.3),
        inset 0 -4px 10px rgba(0, 0, 0, 0.3),
        inset 0 2px 6px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    transform-style: preserve-3d;
}

.chatbot-toggle:hover {
    transform: scale(1.1) translateZ(10px);
    box-shadow: 
        0 6px 16px rgba(0, 0, 0, 0.25),
        0 12px 32px rgba(4, 95, 180, 0.35),
        inset 0 -4px 10px rgba(0, 0, 0, 0.35),
        inset 0 2px 8px rgba(255, 255, 255, 0.25);
}

.chatbot-toggle i {
    color: white;
    font-size: 28px;
}

.chatbot-toggle .chat-icon {
    display: block;
    width: 32px;
    height: 32px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.chatbot-toggle.active .chat-icon {
    animation: bot-idle 3s ease-out infinite;
}

.chatbot-toggle .close-icon {
    display: none;
}

.chatbot-toggle.active .chat-icon {
    display: none;
}

.chatbot-toggle.active .close-icon {
    display: block;
}

.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: #ff4757;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

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

.chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-container.show {
    display: flex;
}

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

.chatbot-header {
    background: linear-gradient(135deg, #045FB4 0%, #034a8d 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-header-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    animation: bot-idle 3s ease-out infinite;
}

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

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

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    scroll-padding-bottom: 20px;
}

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

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

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

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

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

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: none !important;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bot-avatar-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    animation: bot-idle 4s linear infinite;
}

/* Animaciones del bot */
@keyframes bot-idle {
    0% {
        transform: rotate(0deg);
    }
    40% {
        transform: rotate(360deg);
    }
    70% {
        transform: rotate(450deg);
    }
    85% {
        transform: rotate(480deg);
    }
    100% {
        transform: rotate(540deg);
    }
}

@keyframes bot-blink {
    0%, 100% {
        transform: scaleY(1);
        filter: brightness(1);
    }
    40% {
        transform: scaleY(0.8);
        filter: brightness(0.95);
    }
    50% {
        transform: scaleY(0.6);
        filter: brightness(0.9);
    }
    60% {
        transform: scaleY(0.8);
        filter: brightness(0.95);
    }
}

@keyframes bot-scale-pulse {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.05);
    }
    50% {
        transform: scale(1.1);
    }
    75% {
        transform: scale(1.05);
    }
}

@keyframes bot-spawn {
    0% {
        transform: scale(0.6);
        opacity: 0;
        filter: blur(6px);
    }
    100% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0);
    }
}

@keyframes bot-despawn {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0);
    }
    100% {
        transform: scale(0.6);
        opacity: 0;
        filter: blur(6px);
    }
}

@keyframes bot-search {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-4px) rotate(-2.5deg);
    }
    50% {
        transform: translateX(4px) rotate(2.5deg);
    }
    75% {
        transform: translateX(-4px) rotate(-2.5deg);
    }
}

@keyframes bot-waiting {
    0%, 100% {
        transform: translateY(0);
    }
    20% {
        transform: translateY(-8px);
    }
    40% {
        transform: translateY(-6px);
    }
    60% {
        transform: translateY(-4px);
    }
    80% {
        transform: translateY(-2px);
    }
}

@keyframes bot-error {
    0%, 100% {
        transform: translateX(0);
        filter: brightness(1);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-6px);
        filter: brightness(1) drop-shadow(0 0 4px rgba(255, 0, 0, 0.3));
    }
    20%, 40%, 60%, 80% {
        transform: translateX(6px);
        filter: brightness(1) drop-shadow(0 0 4px rgba(255, 0, 0, 0.3));
    }
}

@keyframes bot-success {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    30% {
        transform: scale(1.15);
        filter: brightness(1.2) drop-shadow(0 0 8px rgba(46, 204, 113, 0.5));
    }
    60% {
        transform: scale(1.05);
        filter: brightness(1.1) drop-shadow(0 0 6px rgba(46, 204, 113, 0.3));
    }
}

/* Clases de animación */
.bot-avatar-icon.blink {
    animation: bot-blink 0.5s ease-in-out;
}

.bot-avatar-icon.scale-pulse {
    animation: bot-scale-pulse 0.625s ease-in-out infinite;
}

.bot-avatar-icon.spawn {
    animation: bot-spawn 0.667s ease-out;
}

.bot-avatar-icon.despawn {
    animation: bot-despawn 0.667s ease-in;
}

.bot-avatar-icon.search {
    animation: bot-search 0.6s ease-in-out infinite;
}

.bot-avatar-icon.waiting {
    animation: bot-waiting 1s ease-in-out infinite;
}

.bot-avatar-icon.error {
    animation: bot-error 0.375s ease-in-out;
}

.bot-avatar-icon.success {
    animation: bot-success 0.5s ease-out;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #045FB4 0%, #034a8d 100%);
    color: white;
}

.message.user .message-avatar {
    background: #e9ecef;
    color: #495057;
}

.message-content {
    max-width: 70%;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.bot .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #045FB4 0%, #034a8d 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
    padding: 0 5px;
}

.message-options-container {
    margin-top: 8px;
}

.options-toggle-btn {
    background: #f0f2f5;
    color: #045FB4;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: space-between;
}

.options-toggle-btn:hover {
    background: #e8eaed;
    border-color: #045FB4;
}

.options-toggle-btn .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.message-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), margin-top 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    margin-top: 0;
    opacity: 0;
}

.message-options.expanded {
    margin-top: 8px;
    opacity: 1;
}

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

.option-btn {
    background: linear-gradient(135deg, #045FB4 0%, #034a8d 100%);
    color: white;
    border: none;
    border-radius: 18px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.option-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(4, 95, 180, 0.3);
}

.option-btn:disabled,
.options-toggle-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.option-btn:disabled:hover,
.options-toggle-btn:disabled:hover {
    transform: none;
    background: #f0f2f5;
}

.message.bot .option-btn {
    background: white;
    color: #045FB4;
    border: 2px solid #045FB4;
}

.message.bot .option-btn:hover {
    background: linear-gradient(135deg, #045FB4 0%, #034a8d 100%);
    color: white;
    border-color: transparent;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.typing-indicator.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.typing-indicator-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

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

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

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

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

.chatbot-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 25px;
    padding: 10px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chatbot-input:focus {
    border-color: #045FB4;
}

.chatbot-send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #045FB4 0%, #034a8d 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chatbot-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(4, 95, 180, 0.3);
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .chatbot-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 90px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .chatbot-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-container {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 15px;
    }
    
    .chatbot-toggle {
        width: 55px;
        height: 55px;
    }
}
