/* chat.css */
#nova-chat-widget {
    position: fixed;
    bottom: 6.5rem; /* Elevado para no superponerse con el botón de la tienda */
    right: 2rem;
    z-index: 1080; /* Por encima de navbar y modales bootstrap */
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#nova-chat-popover {
    display: none;
    width: 340px;
    height: 480px;
    max-height: calc(100vh - 6.5rem - 90px);
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    overflow: hidden;
    flex-direction: column;
    margin-bottom: 75px; /* Espacio para el boton si existe */
    position: absolute;

    bottom: 0;
    right: 0;
    transform-origin: bottom right;
    animation: novaChatScaleIn 0.3s ease;
}

#nova-chat-popover.open {
    display: flex;
}

@keyframes novaChatScaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.nova-chat-header {
    background: linear-gradient(to right, #1a2980, #26d0ce);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.nova-chat-header .back-btn, 
.nova-chat-header .close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
}

.nova-chat-header .back-btn { display: none; }

.nova-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Burbujas */
.nchat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 15px;
    font-size: 0.95rem;
    line-height: 1.3;
    position: relative;
    word-wrap: break-word;
}
.nchat-msg .time {
    font-size: 0.70rem;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
    display: block;
}

/* Si hablo yo (Usuario hacia admin, o Admin hacia usuario) 
   En chat.js usaremos la lógica:
   "mi_mensaje" = right
   "otro_mensaje" = left
*/
.nchat-msg.mine {
    background: linear-gradient(to right, #1a2980, #26d0ce);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.nchat-msg.other {
    background: #e9ecef;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid #dee2e6;
}

.nova-chat-footer {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}
.nova-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 15px;
    resize: none;
    outline: none;
    height: 40px;
    line-height: 1.5;
}
.nova-chat-btn-send {
    background: #1a2980;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.nova-chat-btn-send:hover {
    background: #26d0ce;
}

/* Panel Admin (Lista de hilos) */
#nchat-admin-list {
    display: none; 
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    background: #fff;
}
.nchat-thread-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nchat-thread-item:hover { background: #f5f5f5; }
.nchat-thread-info strong { display: block; color: #1a2980; }
.nchat-thread-info small { color: #888; font-size: 0.8rem; }
.nchat-badge {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
}

/* Form anónimo */
#nchat-anon-form {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
}
#nchat-anon-form input {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 10px;
}

.nova-chat-icon-fixed {
    width: 60px;
    height: 60px;
    background: linear-gradient(to right, #1a2980, #26d0ce);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(26, 41, 128, 0.4);
    cursor: pointer;
    position: relative;
    transition: transform 0.3s;
}
.nova-chat-icon-fixed:hover { transform: scale(1.1); }
.nova-chat-badge-icon {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    display: none;
}

@media (max-width: 576px) {
    #nova-chat-widget {
        right: 1rem;
    }
    #nova-chat-popover {
        width: calc(100vw - 2rem);
        height: calc(100vh - 8.5rem - 90px); /* 100vh menos bottom (6.5rem) menos icono y márgenes */
        max-height: 480px;
        margin-bottom: 70px;
    }
    .nova-chat-icon-fixed {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }
}

