/* ============================================
   AI CHATBOT - ESTILOS
   ============================================ */

/* Contenedor principal */
.ai-chatbot-widget {
    position: fixed;
    z-index: 10000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ============================================
   BOTÓN FLOTANTE
   ============================================ */
.ai-chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #00ffc8, #00d4ff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 
        0 10px 40px rgba(0, 255, 200, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10001;
    border: 3px solid rgba(0, 0, 0, 0.3);
}

.ai-chat-button:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 
        0 15px 60px rgba(0, 255, 200, 0.8),
        inset 0 0 30px rgba(255, 255, 255, 0.3);
}

.ai-chat-button.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.ai-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    animation: bounce-subtle 2s ease-in-out infinite;
}

@keyframes bounce-subtle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Pulso animado */
.ai-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0, 255, 200, 0.4);
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Badge AI */
.ai-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff00ff;
    color: white;
    font-size: 0.65rem;
    font-weight: 900;
    padding: 4px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(255, 0, 255, 0.6);
    animation: badge-glow 2s ease-in-out infinite;
}

@keyframes badge-glow {
    0%, 100% { box-shadow: 0 2px 10px rgba(255, 0, 255, 0.6); }
    50% { box-shadow: 0 2px 20px rgba(255, 0, 255, 1); }
}

/* ============================================
   PANEL DEL CHAT
   ============================================ */
.ai-chat-panel {
    position: fixed;
    bottom: 120px;
    right: 30px;
    width: 420px;
    height: 650px;
    background: linear-gradient(135deg, rgba(10, 10, 30, 0.98), rgba(0, 20, 40, 0.98));
    border-radius: 25px;
    border: 3px solid rgba(0, 255, 200, 0.5);
    box-shadow: 
        0 30px 100px rgba(0, 0, 0, 0.8),
        0 0 60px rgba(0, 255, 200, 0.3),
        inset 0 0 80px rgba(0, 255, 200, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0) translateY(100px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(20px);
}

.ai-chat-panel.active {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.ai-chat-panel.minimized {
    height: 60px;
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */
.ai-chat-header {
    background: linear-gradient(135deg, rgba(0, 255, 200, 0.2), rgba(0, 212, 255, 0.2));
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(0, 255, 200, 0.3);
    cursor: grab;
    user-select: none;
}

.ai-chat-header:active {
    cursor: grabbing;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 1.1rem;
    color: #00ffc8;
    text-shadow: 0 0 10px rgba(0, 255, 200, 0.5);
    letter-spacing: 1px;
}

.ai-status-dot {
    width: 10px;
    height: 10px;
    background: #00ff00;
    border-radius: 50%;
    animation: status-pulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px #00ff00;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-version {
    font-size: 0.7rem;
    background: rgba(255, 0, 255, 0.3);
    padding: 3px 8px;
    border-radius: 10px;
    color: #ff00ff;
    font-weight: 700;
}

.ai-chat-controls {
    display: flex;
    gap: 8px;
}

.ai-chat-controls button {
    background: rgba(0, 255, 200, 0.2);
    border: 2px solid rgba(0, 255, 200, 0.4);
    color: #00ffc8;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-controls button:hover {
    background: rgba(0, 255, 200, 0.4);
    border-color: #00ffc8;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 200, 0.6);
}

.ai-mode-switch {
    font-size: 1rem !important;
}

/* ============================================
   INDICADOR DE MODO
   ============================================ */
.ai-mode-indicator {
    background: rgba(0, 212, 255, 0.15);
    padding: 10px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 255, 200, 0.2);
}

.mode-text {
    color: #00d4ff;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   CONTENIDO DEL CHAT
   ============================================ */
.ai-chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-view,
.ai-analytics-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================
   MENSAJES
   ============================================ */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Scrollbar personalizado */
.ai-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.ai-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #00ffc8, #00d4ff);
    border-radius: 10px;
}

.ai-message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.4s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-bot {
    align-self: flex-start;
}

.ai-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00ffc8, #00d4ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 255, 200, 0.4);
}

.ai-message-user .ai-avatar {
    background: linear-gradient(135deg, #ff00ff, #ff0080);
    box-shadow: 0 4px 15px rgba(255, 0, 255, 0.4);
}

.ai-message-content {
    background: rgba(0, 255, 200, 0.1);
    padding: 15px 18px;
    border-radius: 18px;
    max-width: 75%;
    border: 1px solid rgba(0, 255, 200, 0.3);
    position: relative;
}

.ai-message-user .ai-message-content {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.3);
}

.ai-message-content p {
    margin: 0 0 8px 0;
    color: #e0e0e0;
    line-height: 1.6;
    font-size: 0.95rem;
}

.ai-message-content p:last-child {
    margin-bottom: 0;
}

.ai-message-content ul {
    margin: 10px 0;
    padding-left: 20px;
    color: #b0b0b0;
}

.ai-message-content li {
    margin: 5px 0;
    font-size: 0.9rem;
}

.ai-message-content a {
    color: #00ffc8;
    text-decoration: underline;
}

.ai-timestamp {
    font-size: 0.7rem;
    color: #666;
    display: block;
    margin-top: 5px;
}

/* Indicador de escritura */
.typing-dots {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #00ffc8;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots 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;
    }
}

/* ============================================
   INPUT DE MENSAJE
   ============================================ */
.ai-input-container {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 2px solid rgba(0, 255, 200, 0.2);
}

#aiMessageInput {
    flex: 1;
    background: rgba(0, 255, 200, 0.1);
    border: 2px solid rgba(0, 255, 200, 0.3);
    border-radius: 25px;
    padding: 12px 20px;
    color: #e0e0e0;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

#aiMessageInput:focus {
    outline: none;
    border-color: #00ffc8;
    background: rgba(0, 255, 200, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 200, 0.3);
}

#aiMessageInput::placeholder {
    color: #666;
}

.ai-send-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00ffc8, #00d4ff);
    border: none;
    color: #000;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 255, 200, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-send-button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 25px rgba(0, 255, 200, 0.6);
}

.ai-send-button:active {
    transform: scale(0.95);
}

/* ============================================
   SUGERENCIAS RÁPIDAS
   ============================================ */
.ai-quick-suggestions {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.3);
    overflow-x: auto;
    border-top: 1px solid rgba(0, 255, 200, 0.15);
}

.ai-quick-suggestions::-webkit-scrollbar {
    height: 4px;
}

.ai-quick-suggestions::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 200, 0.5);
    border-radius: 10px;
}

.ai-suggestion {
    background: rgba(0, 255, 200, 0.15);
    border: 1px solid rgba(0, 255, 200, 0.3);
    color: #00ffc8;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.ai-suggestion:hover {
    background: rgba(0, 255, 200, 0.3);
    border-color: #00ffc8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 200, 0.4);
}

/* ============================================
   VISTA DE ANALYTICS
   ============================================ */
.analytics-dashboard {
    padding: 20px;
    overflow-y: auto;
    height: 100%;
}

.analytics-dashboard h3 {
    color: #00ffc8;
    margin-bottom: 20px;
    font-size: 1.4rem;
    text-shadow: 0 0 10px rgba(0, 255, 200, 0.5);
}

.analytics-dashboard h4 {
    color: #00d4ff;
    margin: 20px 0 15px 0;
    font-size: 1.1rem;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.analytics-card {
    background: linear-gradient(135deg, rgba(0, 255, 200, 0.1), rgba(0, 212, 255, 0.1));
    border: 2px solid rgba(0, 255, 200, 0.3);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.analytics-card:hover {
    transform: translateY(-5px);
    border-color: #00ffc8;
    box-shadow: 0 10px 30px rgba(0, 255, 200, 0.3);
}

.analytics-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.analytics-value {
    font-size: 2rem;
    font-weight: 900;
    color: #00ffc8;
    margin: 10px 0;
    text-shadow: 0 0 15px rgba(0, 255, 200, 0.6);
}

.analytics-label {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.analytics-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 200, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.optimization-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.optimization-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 255, 200, 0.05);
    border-radius: 10px;
    border-left: 4px solid;
}

.optimization-item.success {
    border-color: #00ff00;
}

.optimization-item.warning {
    border-color: #ffaa00;
}

.optimization-item.error {
    border-color: #ff0000;
}

.opt-icon {
    font-size: 1.2rem;
    font-weight: 900;
}

.optimization-item.success .opt-icon {
    color: #00ff00;
}

.optimization-item.warning .opt-icon {
    color: #ffaa00;
}

.opt-text {
    color: #b0b0b0;
    font-size: 0.9rem;
}

.auto-optimization-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: rgba(0, 255, 200, 0.1);
    border-radius: 10px;
    margin-bottom: 15px;
}

.status-indicator {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #666;
}

.status-indicator.active {
    background: #00ff00;
    box-shadow: 0 0 15px #00ff00;
    animation: status-pulse 2s ease-in-out infinite;
}

.analytics-info {
    color: #888;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 10px 0;
}

.ai-refresh-analytics {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #00ffc8, #00d4ff);
    border: none;
    border-radius: 12px;
    color: #000;
    font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.4s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 6px 20px rgba(0, 255, 200, 0.4);
}

.ai-refresh-analytics:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 255, 200, 0.6);
}

/* ============================================
   NOTIFICACIÓN
   ============================================ */
.ai-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #00ffc8, #00d4ff);
    color: #000;
    padding: 15px 25px;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: 0 10px 40px rgba(0, 255, 200, 0.6);
    animation: notificationSlide 0.5s ease;
    z-index: 10002;
}

@keyframes notificationSlide {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .ai-chat-panel {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 20px;
        right: 20px;
        left: 20px;
    }

    .ai-chat-button {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }

    .ai-icon {
        font-size: 2rem;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .ai-chat-panel {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }

    .ai-quick-suggestions {
        flex-wrap: wrap;
    }
}


