/* ============================================================
   🌐 MentorSync — Chat Panel Visual System (Front-End)
   - Header visual
   - Mensajes / Burbujas
   - Input interactivo
   - Light/Dark Mode
   - Animaciones
   - Menú flotante (corregido)
   - Mobile fullscreen
============================================================ */

/* ============================================================
   FIX GLOBAL — NECESARIOS PARA EL MENÚ
============================================================ */
.mentorsync-ai-panel {
    position: relative;
    overflow: visible !important;
    z-index: 999999 !important;
}

.mentorsync-ai-header {
    position: relative;
    overflow: visible !important;
    padding: 0.85rem 1rem;
    backdrop-filter: blur(14px);
    border-bottom: 1px solid transparent;
    transition: background .25s ease, border-color .25s ease;
}


/* ============================================================
   MENÚ ⋮ — CORREGIDO Y FUNCIONAL
============================================================ */
.mentorsync-ai-menu {
    position: absolute;
    top: 52px;             /* debajo del header */
    right: 12px;           /* alineado con el botón ⋮ */
    min-width: 170px;

    background: var(--ms-panel, rgba(255,255,255,0.85));
    border-radius: 12px;
    padding: 8px 0;

    box-shadow: 0 8px 24px rgba(0,0,0,0.22);
    backdrop-filter: blur(18px);

    display: flex;
    flex-direction: column;

    opacity: 1;
    transform: scale(1);
    transition: opacity .18s ease, transform .18s ease;
    z-index: 999999999;
}

.mentorsync-ai-menu.hidden {
    opacity: 0;
    transform: scale(.85);
    pointer-events: none;
}

/* Items del menú (aunque aún no uses ninguno) */
.mentorsync-ai-menu-item {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    color: var(--ms-text, #222);
    transition: background .15s ease;
}

.mentorsync-ai-menu-item:hover {
    background: var(--ms-hover, rgba(0,0,0,0.06));
}


/* ============================================================
   HEADER — BASE
============================================================ */
.mentorsync-ai-avatar {
    background-size: cover;
    background-position: center;
}

.mentorsync-ai-title {
    font-size: 1rem;
}

.mentorsync-ai-subtitle {
    opacity: 0.85;
}

.mentorsync-ai-close {
    transition: background .2s ease, color .2s ease;
}

/* ============================================================
   MENSAJES — BASE
============================================================ */
.mentorsync-ai-messages {
    backdrop-filter: blur(6px);
}

.mentorsync-ai-message-bubble {
    backdrop-filter: blur(5px);
    border: 1px solid transparent;
    transition: background .25s ease, border-color .25s ease, color .25s ease;
}

/* ============================================================
   INPUT
============================================================ */
.mentorsync-ai-input {
    backdrop-filter: blur(14px);
    border-top: 1px solid transparent;
    transition: background .25s ease, border-color .25s ease;
}

.mentorsync-ai-input-text {
    background: transparent;
    transition: background .25s ease, border-color .25s ease, color .25s ease;
}

.mentorsync-ai-input-send {
    transition: background .25s ease, color .25s ease;
}

/* ============================================================
   🌞 LIGHT MODE
============================================================ */
html[data-theme="light"] .mentorsync-ai-header {
    background: rgba(255, 255, 255, 0.80);
    border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .mentorsync-ai-title { color: #111; }
html[data-theme="light"] .mentorsync-ai-subtitle { color: #444; }

html[data-theme="light"] .mentorsync-ai-close { color: #333; }
html[data-theme="light"] .mentorsync-ai-close:hover {
    background: rgba(0, 0, 0, 0.07);
}

html[data-theme="light"] .mentorsync-ai-messages {
    background: linear-gradient(145deg, #fafafa, #f2f2f2);
}

html[data-theme="light"] .mentorsync-ai-message-avatar {
    background: #ececec;
    color: #111;
}

html[data-theme="light"] .mentorsync-ai-message-bubble {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
    color: #222;
}

/* User bubble */
html[data-theme="light"] .mentorsync-ai-message-user .mentorsync-ai-message-bubble {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
    color: #0f172a;
}

html[data-theme="light"] .mentorsync-ai-input {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .mentorsync-ai-input-text {
    border-color: rgba(0, 0, 0, 0.15);
    color: #111;
}

html[data-theme="light"] .mentorsync-ai-input-send {
    background: #2563eb;
    color: white;
}
html[data-theme="light"] .mentorsync-ai-input-send:hover {
    background: #1d4ed8;
}

/* ============================================================
   🌙 DARK MODE
============================================================ */
html[data-theme="dark"] .mentorsync-ai-header {
    background:
        radial-gradient(circle at 0% 0%, rgba(236,72,153,0.20), transparent 55%),
        radial-gradient(circle at 100% 0%, rgba(59,130,246,0.22), transparent 55%),
        linear-gradient(to right, rgba(15,23,42,0.98), rgba(15,23,42,0.92));
    border-color: rgba(148, 163, 184, 0.20);
}

html[data-theme="dark"] .mentorsync-ai-title { color: #f1f5f9; }
html[data-theme="dark"] .mentorsync-ai-subtitle { color: #cbd5e1; }

html[data-theme="dark"] .mentorsync-ai-close { color: #e2e8f0; }
html[data-theme="dark"] .mentorsync-ai-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .mentorsync-ai-messages {
    background:
        radial-gradient(circle at 0% 100%, rgba(79,70,229,0.35), transparent 55%),
        radial-gradient(circle at 100% 0%, rgba(236,72,153,0.35), transparent 55%),
        linear-gradient(145deg, #020617, #020617);
}

html[data-theme="dark"] .mentorsync-ai-message-avatar {
    background: #1e293b;
    color: #fff;
}

html[data-theme="dark"] .mentorsync-ai-message-bubble {
    background: rgba(15, 23, 42, 0.65);
    border-color: rgba(148,163,184,0.25);
    color: #e2e8f0;
}

/* User bubble */
html[data-theme="dark"] .mentorsync-ai-message-user .mentorsync-ai-message-bubble {
    background: rgba(59,130,246,0.22);
    border-color: rgba(59,130,246,0.55);
    color: #fff;
}

html[data-theme="dark"] .mentorsync-ai-input {
    background: rgba(2, 6, 23, 0.92);
    border-color: rgba(148,163,184,0.15);
}

html[data-theme="dark"] .mentorsync-ai-input-text {
    border-color: rgba(148,163,184,0.25);
    color: #e2e8f0;
}

html[data-theme="dark"] .mentorsync-ai-input-send {
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    color: white;
}
html[data-theme="dark"] .mentorsync-ai-input-send:hover {
    filter: brightness(1.15);
}

/* ============================================================
   Animación mensajes
============================================================ */
.mentorsync-ai-message {
    animation: msyncFadeIn .25s ease;
}

@keyframes msyncFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Mobile fullscreen
============================================================ */
@media (max-width: 600px) {
    .mentorsync-ai-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        overflow: visible !important;
    }

    .mentorsync-ai-header {
        border-radius: 0;
    }
}

/* ============================================================
   AVATARES EN MOVIL — FIX DE VISIBILIDAD Y ESPACIADO
============================================================ */
@media (max-width: 768px) {

    /* Asegurar que el contenedor del mensaje permita ver el avatar */
    .mentorsync-ai-message {
        display: flex !important;
        align-items: flex-start !important;
        gap: 8px !important;
        overflow: visible !important;
        max-width: 100% !important;
    }

    /* Avatar visible, sin recorte */
    .mentorsync-ai-message-avatar {
        flex-shrink: 0 !important;
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 18px !important;
        overflow: visible !important;
    }

    /* Burbuja ajustada en móvil */
    .mentorsync-ai-message-bubble {
        max-width: calc(100% - 40px) !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        white-space: pre-wrap !important;
    }

    /* Evitar que algún contenedor padre esconda los avatares */
    .mentorsync-ai-messages {
        overflow-y: auto !important;
        overflow-x: visible !important;
    }
}

.mentorsync-ai-message-avatar {
    width: 36px !important;
    height: 36px !important;

    min-width: 36px !important;
    min-height: 36px !important;

    border-radius: 50% !important;
    background: rgba(255,255,255,0.08);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 0 !important; /* elimina emojis */
    overflow: visible !important;
}

.mentorsync-ai-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

