/* ===== ADVANCED AI CHATBOT - IBYTE THEME ===== */
:root {
    --ibyte-cyan: #40E0D0;
    --ibyte-dark: #1F2937;
    --ibyte-white: #FFFFFF;
    --ibyte-light-gray: #F9FAFB;
    --ibyte-medium-gray: #6B7280;
    --ibyte-secondary: #00FF97;
    --ibyte-dark-bg: #0f172a;
    --ibyte-shadow: rgba(0, 0, 0, 0.15);
}

/* ===== CONTAINER PRINCIPAL ===== */
#ai-chatbot-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9998; /* Menor que scroll-up (10000) para no solaparse */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Asegurarse de que el scroll-up esté por encima del chatbot */
.xb-backtotop {
    z-index: 10001 !important;
    bottom: 25px !important;
    left: 25px !important; /* Moverlo al lado izquierdo para no solaparse */
}

/* Ajuste responsive para scroll-up */
@media (max-width: 768px) {
    .xb-backtotop {
        left: 20px !important;
        bottom: 20px !important;
    }
}

/* ===== BOTÓN FLOTANTE PRINCIPAL - ELEGANTE Y MINIMALISTA ===== */
.ai-chatbot-toggle {
    position: relative;
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #1F2937 0%, #374151 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(31, 41, 55, 0.3), 0 0 0 0 rgba(64, 224, 208, 0.4);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 2px solid rgba(64, 224, 208, 0.2);
}

.ai-chatbot-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, var(--ibyte-cyan), #00FF97);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ai-chatbot-toggle:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(64, 224, 208, 0.4), 0 0 0 8px rgba(64, 224, 208, 0.1);
    border-color: var(--ibyte-cyan);
}

.ai-chatbot-toggle:hover::before {
    opacity: 1;
}

.ai-chatbot-toggle-icon {
    font-size: 28px;
    background: linear-gradient(135deg, var(--ibyte-cyan), #00FF97);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s ease;
}

.ai-chatbot-toggle:hover .ai-chatbot-toggle-icon {
    transform: scale(1.15);
}

/* Badge de mensajes no leídos */
.ai-chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: #FF3B30;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    border: 3px solid #ffffff;
    box-shadow: 0 3px 15px rgba(255, 59, 48, 0.9), 0 0 0 3px rgba(255, 59, 48, 0.4);
    animation: pulse-badge 2s ease-in-out infinite;
    z-index: 100;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 12px rgba(255, 59, 48, 0.8), 0 0 0 2px rgba(255, 59, 48, 0.3);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 4px 16px rgba(255, 59, 48, 1), 0 0 0 4px rgba(255, 59, 48, 0.5);
    }
}

/* Badge de notificación (legacy) */
.ai-chatbot-notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: #FF3B30;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    border: 2px solid white;
    animation: bounce-notification 0.6s ease-in-out infinite;
}

/* Animación de rebote suave para primera visita */
@keyframes softBounce {
    0%, 100% { 
        transform: translateY(0);
    }
    25% {
        transform: translateY(-8px);
    }
    50% {
        transform: translateY(-4px);
    }
    75% {
        transform: translateY(-6px);
    }
}

.ai-chatbot-toggle.first-visit-bounce {
    animation: softBounce 2s ease-in-out infinite;
}

@keyframes bounce-notification {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Animación de minimizar con efecto elegante */
@keyframes chatMinimizeOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 0.6;
        transform: translateY(10px) scale(0.98);
    }
    100% {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
}

/* ===== VENTANA DEL CHAT - DISEÑO PREMIUM ===== */
.ai-chatbot-widget {
    position: fixed;
    bottom: 94px;
    right: 25px;
    width: 420px;
    max-width: calc(100vw - 50px);
    height: 650px;
    max-height: calc(100vh - 120px);
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(31, 41, 55, 0.15), 0 0 0 1px rgba(64, 224, 208, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    z-index: 9998;
    backdrop-filter: blur(10px);
}

.ai-chatbot-widget.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Prevenir scroll de la página cuando el chat está activo */
body.chatbot-focus {
    overflow: hidden;
}

/* ===== HEADER DEL CHAT - ELEGANTE ===== */
.ai-chatbot-header {
    background: linear-gradient(135deg, #1F2937 0%, #374151 100%);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(64, 224, 208, 0.15);
    flex-shrink: 0;
    position: relative;
}

.ai-chatbot-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--ibyte-cyan), transparent);
    opacity: 0.5;
}

.ai-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-chatbot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(64, 224, 208, 0.2);
    padding: 0;
    overflow: hidden;
}

.ai-chatbot-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ai-chatbot-avatar-icon {
    font-size: 22px;
    color: #1F2937;
}

.ai-chatbot-header-text h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.3px;
}

.ai-chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
}

.ai-chatbot-status-dot {
    width: 7px;
    height: 7px;
    background: var(--ibyte-cyan);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--ibyte-cyan);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.2); }
}

.ai-chatbot-header-actions {
    display: flex;
    gap: 8px;
}

.ai-chatbot-settings,
.ai-chatbot-minimize,
.ai-chatbot-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(64, 224, 208, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--ibyte-cyan);
}

.ai-chatbot-settings:hover,
.ai-chatbot-minimize:hover,
.ai-chatbot-close:hover {
    background: rgba(64, 224, 208, 0.2);
    transform: translateY(-2px);
}

/* ===== ÁREA DE MENSAJES - FONDO SUTIL ===== */
.ai-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #FAFBFC;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

/* IMPORTANTE: Mantener scroll dentro del contenedor del chat */
.ai-chatbot-messages:focus {
    outline: none;
}

/* Estilizar scrollbar */
.ai-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(64, 224, 208, 0.3);
    border-radius: 10px;
}

.ai-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(64, 224, 208, 0.5);
}

/* ===== MENSAJES ===== */
.ai-chatbot-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: message-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes message-slide-in {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chatbot-message.user {
    flex-direction: row-reverse;
}

.ai-chatbot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    overflow: hidden;
}

.ai-chatbot-message.bot .ai-chatbot-message-avatar {
    background: white;
    color: var(--ibyte-cyan);
    padding: 4px;
}

.ai-chatbot-message.bot .ai-chatbot-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ai-chatbot-message.user .ai-chatbot-message-avatar {
    background: linear-gradient(135deg, var(--ibyte-cyan), #00FF97);
    color: #1F2937;
    font-weight: 600;
    font-size: 14px;
}

.ai-chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.5;
}

.ai-chatbot-message.bot .ai-chatbot-message-content {
    background: #FFFFFF;
    color: #1F2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-chatbot-message.user .ai-chatbot-message-content {
    background: linear-gradient(135deg, #1F2937, #374151);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.2);
}

.ai-chatbot-message-text {
    font-size: 15px;
    margin: 0;
}

.ai-chatbot-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 6px;
    display: block;
}

/* ===== INDICADOR DE ESCRITURA ===== */
.ai-chatbot-typing {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 0 24px 10px;
    animation: message-slide-in 0.4s ease;
}

.ai-chatbot-typing.active {
    display: flex;
}

.ai-chatbot-typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    overflow: hidden;
}

.ai-chatbot-typing-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ai-chatbot-typing-content {
    background: #FFFFFF;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.ai-chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-chatbot-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1F2937;
    animation: typing-bounce 1.4s infinite;
}

.ai-chatbot-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chatbot-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ===== ACCIONES RÁPIDAS - MINIMALISTAS ===== */
.ai-chatbot-quick-actions {
    padding: 12px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #FAFBFC;
    flex-shrink: 0;
}

.ai-quick-action-btn {
    padding: 8px 14px;
    border: 1px solid rgba(64, 224, 208, 0.3);
    background: white;
    color: #1F2937;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.ai-quick-action-btn:hover {
    background: linear-gradient(135deg, #1F2937, #374151);
    color: #FFFFFF;
    border-color: #1F2937;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.2);
}

/* ===== ÁREA DE INPUT - LIMPIO Y MODERNO ===== */
.ai-chatbot-input-container {
    padding: 16px 20px;
    background: #FFFFFF;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.ai-chatbot-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #F5F7F9;
    border-radius: 20px;
    padding: 4px 4px 4px 16px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.ai-chatbot-input-wrapper:focus-within {
    border-color: rgba(64, 224, 208, 0.3);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(64, 224, 208, 0.1);
}

.ai-chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    color: #1F2937;
    font-family: inherit;
}

.ai-chatbot-input::placeholder {
    color: #9CA3AF;
}

.ai-chatbot-send {
    width: 38px;
    height: 38px;
    border: none;
    background: linear-gradient(135deg, #1F2937, #374151);
    color: var(--ibyte-cyan);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ai-chatbot-send:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--ibyte-cyan), #00FF97);
    color: #1F2937;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(64, 224, 208, 0.3);
}

.ai-chatbot-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ai-chatbot-send i {
    font-size: 16px;
}

/* ===== BOTÓN DE TEXTO "Conversemos ahora" - OCULTO ===== */
.ai-chatbot-text-prompt {
    display: none !important;
}

/* ===== SUGERENCIAS INTELIGENTES ===== */
.ai-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(64, 224, 208, 0.1);
    border-radius: 12px;
    margin: 4px 0;
    font-size: 13px;
    color: var(--ibyte-dark);
}

.ai-suggestion i {
    color: var(--ibyte-cyan);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #ai-chatbot-container {
        bottom: 20px;
        right: 20px;
    }
    
    .ai-chatbot-widget {
        bottom: 88px;
        right: 20px;
        width: calc(100vw - 40px);
        height: calc(100vh - 116px);
        max-height: 600px;
        border-radius: 16px;
    }
    
    .ai-chatbot-toggle {
        width: 58px;
        height: 58px;
    }
    
    .ai-chatbot-toggle-icon {
        font-size: 26px;
    }
    
    .ai-chatbot-message-content {
        max-width: 80%;
    }
}

@media (max-width: 480px) {
    .ai-chatbot-widget {
        border-radius: 16px;
        bottom: 84px;
    }
    
    .ai-chatbot-header {
        padding: 18px;
    }
    
    .ai-chatbot-messages {
        padding: 16px;
    }
    
    .ai-chatbot-input-container {
        padding: 14px 16px;
    }
}

/* ===== SUGERENCIAS INTELIGENTES ===== */
.ai-suggestion {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(64, 224, 208, 0.08);
    border-radius: 12px;
    margin: 4px 0;
    font-size: 13px;
    color: #1F2937;
    border: 1px solid rgba(64, 224, 208, 0.2);
}

.ai-suggestion i {
    color: var(--ibyte-cyan);
}

/* ===== MODAL DE CONFIGURACIÓN GPT-4O ===== */
.ai-chatbot-settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.ai-chatbot-settings-modal.active {
    display: flex;
}

.ai-chatbot-settings-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-chatbot-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(64, 224, 208, 0.2);
    background: linear-gradient(135deg, #1F2937 0%, #374151 100%);
    border-radius: 16px 16px 0 0;
}

.ai-chatbot-settings-header h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chatbot-settings-header h3 i {
    color: var(--ibyte-cyan);
}

.ai-chatbot-settings-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
}

.ai-chatbot-settings-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.ai-chatbot-settings-body {
    padding: 24px;
}

.ai-chatbot-setting-item {
    margin-bottom: 24px;
}

.ai-chatbot-setting-item label {
    display: block;
    font-weight: 500;
    color: #1F2937;
    margin-bottom: 8px;
    font-size: 14px;
}

.ai-chatbot-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    background: rgba(64, 224, 208, 0.05);
    border: 1px solid rgba(64, 224, 208, 0.2);
    transition: all 0.3s ease;
}

.ai-chatbot-toggle-label:hover {
    background: rgba(64, 224, 208, 0.1);
}

.ai-chatbot-toggle-label input[type="checkbox"] {
    display: none;
}

.ai-chatbot-toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: #D1D5DB;
    border-radius: 13px;
    transition: all 0.3s ease;
}

.ai-chatbot-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ai-chatbot-toggle-label input[type="checkbox"]:checked + .ai-chatbot-toggle-slider {
    background: var(--ibyte-cyan);
}

.ai-chatbot-toggle-label input[type="checkbox"]:checked + .ai-chatbot-toggle-slider::after {
    transform: translateX(22px);
}

.ai-chatbot-toggle-text {
    font-weight: 500;
    color: #1F2937;
    font-size: 15px;
}

.ai-chatbot-input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(64, 224, 208, 0.3);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
    background: rgba(15, 23, 42, 0.05);
}

.ai-chatbot-input-field:focus {
    outline: none;
    border-color: var(--ibyte-cyan);
    box-shadow: 0 0 0 3px rgba(64, 224, 208, 0.1);
}

.ai-chatbot-setting-description {
    margin-top: 8px;
    font-size: 13px;
    color: #6B7280;
    line-height: 1.5;
}

.ai-chatbot-setting-description a {
    color: var(--ibyte-cyan);
    text-decoration: none;
}

.ai-chatbot-setting-description a:hover {
    text-decoration: underline;
}

.ai-chatbot-setting-warning {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #FFC107;
    border-radius: 4px;
    font-size: 12px;
    color: #856404;
    line-height: 1.6;
}

.ai-chatbot-save-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--ibyte-cyan) 0%, #00FF97 100%);
    color: #1F2937;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-chatbot-save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(64, 224, 208, 0.3);
}

.ai-chatbot-save-btn:active {
    transform: translateY(0);
}

/* Status text update for GPT status */
#ai-chatbot-status-text {
    font-size: 13px;
    font-weight: 500;
}

