/* ============================================================ */
/* 💬 ESTILOS DEL CHAT (BURBUJAS Y AMIGOS)                      */
/* ============================================================ */

#chat-offcanvas {
    width: 350px;
}

.chat-friend-item {
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.chat-friend-item:hover {
    background-color: #e9ecef;
}

[data-bs-theme="dark"] .chat-friend-item:hover {
    background-color: rgba(255,255,255,0.08);
}

.chat-friend-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
}

.modal-dialog.modal-lg {
    max-width: 800px;
}

/* Modal del chat: como panel fijo igual que el feed (340px × llenar pantalla) */
#chatModal .modal-dialog {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important;
    width: 340px !important;
    max-width: 340px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    transform: none !important;
}

#chatModal .modal-content {
    height: 100% !important;
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: 0 0 40px rgba(0,0,0,0.4);
}

#chatModal .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 8px !important;
}

/* Visor de imágenes en el chat */
#chatMediaViewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    z-index: 2147483647;
    cursor: pointer;
    justify-content: center;
    align-items: center;
}

#chatMediaViewer img,
#chatMediaViewer video {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}

#chatMediaViewer .viewer-close {
    position: fixed;
    top: 15px;
    right: 20px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 2147483648;
    opacity: 0.7;
    transition: opacity 0.2s;
    background: none;
    border: none;
}

#chatMediaViewer .viewer-close:hover {
    opacity: 1;
}

.message-bubble {
    max-width: 70%;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Colores de burbujas */
.justify-content-end .message-bubble:not(.media-only) {
    background-color: #5ac440;
    color: white;
    padding: 10px;
}

.justify-content-start .message-bubble:not(.media-only) {
    background-color: #e9ecef;
    color: #212529;
    padding: 10px;
    border-left: none !important;
}

[data-bs-theme="dark"] .justify-content-start .message-bubble:not(.media-only) {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

.message-bubble.media-only {
    background: transparent !important;
    padding: 0 !important;
}

.message-bubble img,
.message-bubble video {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    margin: 5px 0;
}

#message-input {
    border-radius: 20px;
}

/* ============================================================ */
/* 🐭 SOLÍN REACCIONES EN CHAT                                  */
/* ============================================================ */

.solin-chat-btn {
    visibility: hidden;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s, opacity 0.15s;
    user-select: none;
    opacity: 0;
    margin-left: 4px;
    align-self: flex-end;
}
.d-flex.mb-2:hover .solin-chat-btn {
    visibility: visible;
    opacity: 0.6;
}
.solin-chat-btn:hover {
    background: rgba(255,215,0,0.2);
    opacity: 1 !important;
}

.solin-chat-option {
    transition: border-color 0.15s, transform 0.15s;
}
.solin-chat-option:hover {
    border-color: #FFD700 !important;
    transform: scale(1.15);
}

.solin-chat-reaction {
    position: absolute;
    bottom: -10px;
    right: -10px;
    z-index: 100;
    pointer-events: none;
    animation: miniFloat 4.5s ease-out forwards;
}
.solin-chat-reaction img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(255,215,0,0.6);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    background: rgba(0,0,0,0.6);
    object-fit: cover;
}

@keyframes miniFloat {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    50%  { opacity: 1; transform: translateY(-24px) scale(1.1); }
    100% { opacity: 0; transform: translateY(-48px) scale(0.85); }
}

.message-container {
    position: relative;
}

/* ============================================================ */
/* 📱 AJUSTES PANTALLA COMPLETA MÓVIL                           */
/* ============================================================ */

@media (max-width: 767px) {
    /* Forzamos al diálogo a ocupar TODO sin trucos de Bootstrap */
    #chatModal .modal-dialog {
        margin: 0 !important;
        padding: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: none !important;
        /* Esto elimina el desplazamiento automático de Bootstrap */
        transform: none !important; 
        top: 0 !important;
        left: 0 !important;
        display: flex !important;
        align-items: stretch !important;
    }

    #chatModal .modal-content {
        height: 100% !important;
        width: 100% !important;
        border: none !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        /* Evita que cualquier cosa interna lo estire */
        overflow: hidden !important; 
    }

    #chatModal .modal-header {
        flex-shrink: 0 !important;
        padding: 10px 15px !important;
        background: white;
        z-index: 10;
    }

    #chatModal .modal-body {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        padding: 10px !important;
    }

    #chatModal .modal-footer {
        flex-shrink: 0 !important;
        padding: 5px 10px !important;
        background: white;
        border-top: 1px solid #eee;
    }

    [data-bs-theme="dark"] #chatModal .modal-header {
        background: #1e1e1e;
    }

    [data-bs-theme="dark"] #chatModal .modal-footer {
        background: #1e1e1e;
        border-top-color: #333;
    }

    /* Aseguramos que el contenedor de mensajes no se pelee con el scroll */
    #chat-messages {
        flex-grow: 1;
        overflow-y: auto;
    }
}
/* ============================================================ */
/* 📱 MÓVIL: OCULTAR HEADER CUANDO EL CHAT ESTÁ ABIERTO        */
/* ============================================================ */

@media (max-width: 767px) {
    body.chat-modal-open #main-header {
        display: none !important;
    }
}

/* ============================================================ */
/* 📞 INTERFAZ DE LLAMADA (EL JEFE FINAL)                       */
/* ============================================================ */

/* 🎯 Si la llamada empieza, matamos el chat y CUALQUIER modal abierto */
body.video-activo #chatModal,
body.video-activo .modal, 
body.video-activo .modal-backdrop,
body.video-activo .offcanvas {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    z-index: -1 !important; /* Lo mandamos al sótano */
}
#video-call-container {
    display: none; /* Controlado por JS */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #000 !important;
    /* PODER MÁXIMO: Encima de todo lo demás en la web */
    z-index: 2147483647 !important; 
    overflow: hidden !important;
}

#remoteVideo {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    position: absolute;
    top: 0;
    left: 0;
}

#localVideo {
    width: 120px !important;
    height: 160px !important;
    object-fit: cover !important;
    position: absolute !important;
    top: 20px;
    right: 20px;
    border-radius: 12px;
    border: 2px solid white;
    /* Un paso más arriba que el video remoto */
    z-index: 2147483648 !important; 
}

.call-controls {
    position: absolute !important;
    bottom: 40px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    /* Encima de los videos para poder colgar */
    z-index: 2147483649 !important;
}