/* 
   Milestone AI Assistant - Premium Compact Design (V3)
   Glassmorphism + Executive Aesthetics + Small Typography
*/

:root {
    --ai-primary: #00d2d3;
    --ai-secondary: #0a192f;
    --ai-accent: #02aab0;
    --ai-glass: rgba(255, 255, 255, 0.05);
    /* Cristal Blanco para dejar pasar la luz */
    --ai-border: rgba(255, 255, 255, 0.2);
    --ai-glow: rgba(255, 255, 255, 0.1);
}

/* Contenedor Principal */
.ai-assistant-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* El Botón Flotante (Trigger) más compacto */
#ai-buddy-trigger {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(0, 210, 211, 0.4);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 25px rgba(0, 210, 211, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: visible;
    padding: 0;
    /* Sin padding para que la imagen ocupe todo */
    z-index: 10;
    animation: ai-float 3s ease-in-out infinite;
}

@keyframes ai-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Borde segmentado tipo anillo (estilo Milestone) */
#ai-buddy-trigger::before {
    content: '';
    position: absolute;
    inset: -3px;
    /* Grosor del anillo */
    border-radius: 50%;
    background: conic-gradient(#137fec 0deg 120deg,
            #14b8a6 120deg 240deg,
            #22c55e 240deg 360deg);
    /* Máscara para que solo se vea el borde exterior */
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #fff 100%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #fff 100%);
    z-index: 2;
    pointer-events: none;
}

/* Animaciones eliminadas */

#ai-trigger-img {
    width: 90%;
    height: 90%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
    /* Asegura que la imagen sea circular */
    z-index: 1;
    /* Por encima de la luz */
    position: relative;
}

#ai-buddy-trigger:hover {
    transform: scale(1.1);
}

/* Pulse ring eliminado */

/* Efecto Nebulosa */
.ai-nebula {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, var(--ai-primary) 0%, transparent 60%),
        radial-gradient(circle, var(--ai-accent) 0%, transparent 60%);
    background-blend-mode: screen;
    filter: blur(25px);
    border-radius: 50%;
    z-index: -2;
    transform: translate(-50%, -50%);
    opacity: 0.5;
    pointer-events: none;
}

/* Nebula animaciones eliminadas */

/* Globito de Bienvenida (Tooltip) */
.ai-hover-tooltip {
    position: absolute;
    bottom: 75px;
    right: 50%;
    transform: translateX(50%) translateY(10px);
    background: var(--ai-glass);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ai-border);
    padding: 6px 14px;
    border-radius: 12px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.ai-hover-tooltip::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--ai-border);
}

/* Interacción Hover Reforzada - Solo cuando se pasa el cursor sobre el botón específicamente */
.ai-assistant-container:not(.chat-open) #ai-buddy-trigger:hover {
    scale: 1.2;
    /* SE AGRANDA EL AVATAR */
    box-shadow: 0 15px 35px rgba(0, 210, 211, 0.5);
}

.ai-assistant-container:not(.chat-open) #ai-buddy-trigger:hover+.ai-hover-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(50%) translateY(0);
}

.ai-assistant-container:not(.chat-open) #ai-buddy-trigger:hover~.ai-nebula {
    opacity: 0.7;
    /* Sutil aumento de brillo */
}

/* Ventana de Chat COMPACTA */
#ai-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 320px;
    height: 400px;
    /* Reducido de 450px */
    max-height: calc(100vh - 120px);
    /* Asegura que no pegue al borde superior */
    background: var(--ai-glass) !important;
    -webkit-backdrop-filter: blur(12px) saturate(180%) !important;
    backdrop-filter: blur(12px) saturate(180%) !important;
    border: 1px solid var(--ai-border) !important;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px var(--ai-glow);
    /* Brillo interno de cristal */
    transform: translateY(15px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Cabecera REDUCIDA */
.ai-chat-header {
    padding: 14px 18px;
    background: transparent;
    border-bottom: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ai-close-window {
    margin-left: auto;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s, transform 0.2s;
    opacity: 0.7;
}

.ai-close-window:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
    transform: scale(1.1);
}

.ai-close-window span {
    font-size: 18px !important;
}

.ai-avatar {
    width: 42px;
    height: 42px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--ai-primary);
    overflow: hidden;
    flex-shrink: 0;
}

.ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-status h3 {
    color: white;
    margin: 0;
    font-size: 13px;
    /* Letra más chica */
    font-weight: 600;
}

.ai-status span {
    color: #00d2d3;
    font-size: 10px;
    /* Letra más chica */
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-status span::before {
    content: "";
    width: 5px;
    height: 5px;
    background: #00d2d3;
    border-radius: 50%;
    display: inline-block;
}

/* Área de Mensajes OPTIMIZADA */
#ai-messages-area {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#ai-messages-area::-webkit-scrollbar {
    width: 3px;
}

#ai-messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

/* Mensajes con Letra Chica */
.msg {
    max-width: 88%;
    padding: 10px 14px;
    font-size: 12.5px;
    /* TIPOGRAFÍA MÁS PEQUEÑA */
    line-height: 1.4;
    word-wrap: break-word;
}

.msg.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    color: #f1f5f9;
    border-radius: 0 14px 14px 14px;
    border-left: 2px solid var(--ai-primary);
}

.msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-accent));
    color: white;
    border-radius: 14px 0 14px 14px;
}

/* Barra de Entrada Compacta */
.ai-chat-input-wrapper {
    padding: 12px 18px 18px;
    background: transparent;
    /* Totalmente cristalino abajo */
    flex-shrink: 0;
}

.ai-input-container {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 4px 4px 4px 12px;
}

#ai-chat-input {
    flex: 1;
    background: transparent !important;
    border: none !important;
    color: white !important;
    font-size: 12.5px;
    outline: none !important;
    box-shadow: none !important;
    padding: 8px 0;
}

#ai-chat-input:focus {
    outline: none !important;
    box-shadow: none !important;
}

#ai-send-btn {
    width: 32px;
    height: 32px;
    background: var(--ai-primary);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-send-btn span {
    font-size: 16px !important;
}

/* Móvil Fullscreen */
@media (max-width: 480px) {
    #ai-chat-window {
        width: calc(100vw - 30px);
        height: 60vh;
        /* Reducido de 70vh */
        bottom: 80px;
    }
}

/* Indicador de Escritura */
.typing-indicator {
    padding: 10px 18px;
    display: none;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 5px;
    height: 5px;
    background: var(--ai-accent);
    border-radius: 50%;
    opacity: 0.4;
    animation: ai-typing 1.4s infinite;
}

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

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

@keyframes ai-typing {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    50% {
        transform: translateY(-3px);
        opacity: 1;
    }
}