/* ==========================================================================
   WIDGET DE SOPORTE INTELIGENTE - HOJA DE ESTILOS (GLASSMORPHISM & PREMIUM DESIGN)
   ========================================================================== */

:root {
    --ai-support-theme-color: #00f0ff; /* Neon cyan similar al del portal */
    --ai-support-bg-glass: rgba(18, 18, 22, 0.88);
    --ai-support-border-glass: rgba(255, 255, 255, 0.08);
    --ai-support-glow: 0 0 15px rgba(0, 240, 255, 0.3);
}

/* Contenedor Principal */
.ai-support-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999; /* Asegurar que flote por encima de todo */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Botón Flotante */
.ai-support-toggle-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d1b2a 0%, #1b263b 100%);
    border: 2px solid var(--ai-support-theme-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), var(--ai-support-glow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

.ai-support-toggle-btn:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(0, 240, 255, 0.6);
}

.ai-support-toggle-btn:active {
    transform: scale(0.95);
}

.ai-support-toggle-btn .chat-icon,
.ai-support-toggle-btn .close-icon {
    transition: transform 0.3s ease;
}

.ai-support-toggle-btn.open .chat-icon {
    display: none;
}

.ai-support-toggle-btn.open .close-icon {
    display: block;
    transform: rotate(90deg);
}

/* Anillo de Pulso */
.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--ai-support-theme-color);
    top: 0;
    left: 0;
    animation: wave-pulse 2.5s infinite;
    pointer-events: none;
    opacity: 0;
}

@keyframes wave-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Ventana de Chat */
.ai-support-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 370px;
    height: 520px;
    border-radius: 16px;
    background: var(--ai-support-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--ai-support-border-glass);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: bottom right;
    animation: window-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes window-appear {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Cabecera */
.ai-support-header {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--ai-support-border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.ai-support-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 240, 255, 0.2);
    font-size: 18px;
}

.status-indicator-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background-color: #00e676;
    box-shadow: 0 0 8px #00e676;
}

.status-dot.away {
    background-color: #ffd600;
    box-shadow: 0 0 8px #ffd600;
}

/* Cuerpo del Chat (Mensajes) */
.ai-support-messages-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Estilos de Burbujas de Mensaje */
.message-wrapper {
    max-width: 80%;
    display: flex;
    flex-direction: column;
}

.message-wrapper.user {
    align-self: flex-end;
}

.message-wrapper.assistant {
    align-self: flex-start;
}

.message-wrapper.system {
    max-width: 100%;
    align-self: center;
    text-align: center;
    margin: 5px 0;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    color: #f1f3f5;
}

.message-wrapper.user .message-bubble {
    background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
    border-bottom-right-radius: 2px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.2);
}

.message-wrapper.assistant .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-wrapper.system .message-bubble {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.02);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 4px;
    padding: 0 4px;
}

.message-wrapper.user .message-time {
    align-self: flex-end;
}

.message-wrapper.assistant .message-time {
    align-self: flex-start;
}

/* Indicador de Escritura */
.ai-support-typing-indicator {
    align-self: flex-start;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    border-bottom-left-radius: 2px;
    margin-left: 20px;
    margin-bottom: 15px;
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: dot-bounce 1.4s infinite ease-in-out both;
}

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

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Pie de Página (Footer de entrada) */
.ai-support-footer {
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--ai-support-border-glass);
}

.ai-support-chat-form {
    display: flex;
    gap: 10px;
}

.ai-support-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 15px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.ai-support-chat-input:focus {
    border-color: var(--ai-support-theme-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.ai-support-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--ai-support-theme-color);
    border: none;
    color: #0d1b2a;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-support-send-btn:hover {
    background: #40f7ff;
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 240, 255, 0.3);
}

.ai-support-send-btn:active {
    transform: translateY(1px);
}

/* Scrollbar Personalizada */
.ai-support-messages-body::-webkit-scrollbar {
    width: 5px;
}

.ai-support-messages-body::-webkit-scrollbar-track {
    background: transparent;
}

.ai-support-messages-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.ai-support-messages-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Clases de Utilidad */
.d-none {
    display: none !important;
}

/* Estilos de Elementos Markdown en Burbujas */
.message-bubble a {
    color: var(--ai-support-theme-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.message-bubble a:hover {
    color: #40f7ff;
    text-decoration: underline;
}

.message-bubble ul {
    margin-top: 5px;
    margin-bottom: 5px;
    padding-left: 20px;
}

.message-bubble li {
    margin-bottom: 4px;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.3);
    color: #ffd600;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

/* Adaptación Móvil */
@media (max-width: 480px) {
    .ai-support-chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -5px;
    }
}

/* ==========================================================================
   ESTILOS DE ARCHIVOS ADJUNTOS E IMÁGENES DE SOPORTE
   ========================================================================== */

/* Botón de Adjuntar Imagen */
.ai-support-file-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 0;
}

.ai-support-file-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ai-support-theme-color);
    border-color: rgba(0, 240, 255, 0.3);
}

/* Barra de vista previa de adjunto */
.ai-support-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 240, 255, 0.08);
    border: 1px dashed rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    padding: 6px 12px;
    margin-bottom: 10px;
    color: #fff;
    animation: preview-slide-in 0.2s ease-out;
}

@keyframes preview-slide-in {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-filename {
    max-width: 220px;
    font-weight: 500;
}

/* Imágenes dentro de las burbujas de chat */
.chat-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
    display: block;
    margin: 4px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.chat-image:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 15px rgba(0, 240, 255, 0.15);
}

