/* === RESETEO Y BASE === */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #f4f4f4;
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
}

body {
    display: block;
    position: relative;
    height: 100%;
}

/* === CONTENEDOR PRINCIPAL DEL CHAT === */
.chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 800px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* === ??REA DE MENSAJES === */
.chat-box {
    flex-grow: 1;
    padding: 20px;
    background-color: #f9f9f9;
    overflow-y: auto;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
    color: #333;
    display: flex;
    flex-direction: column-reverse;
}

/* === MENSAJE INDIVIDUAL === */
.chat-box div.message {
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 4px;
    background-color: #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    word-wrap: break-word;
}

.chat-box div.message strong {
    font-weight: 600;
    color: #007bff;
    margin-right: 10px;
}

.chat-box div.message .message-text {
    font-size: 14px;
    color: #333;
    max-width: 80%;
    white-space: pre-wrap;
}

.chat-box div.message .time-ago {
    font-size: 12px;
    color: #888;
    margin-left: auto;
    align-self: flex-start;
}

/* === INPUT Y BOTONES === */
.input-container {
    display: flex;
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #ddd;
    align-items: center;
    gap: 10px;
    position: relative;
}

.input-container input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    box-sizing: border-box;
}

.input-container button#sendButton {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    margin-left: 10px;
    flex-shrink: 0;
    min-width: 80px;
}

.input-container button#sendButton:hover {
    background-color: #0056b3;
}

/* === BOT??N DE EMOJIS === */
#emojiButton {
    background-color: #1257cd;
    border: none;
    margin-left: 10px;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

#emojiButton .emoji {
    font-size: 24px;
    line-height: 1;
}

#emojiButton:hover {
    background-color: #0a45a0;
}

/* === CONTENEDOR DE EMOJIS === */
.emoji-container {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 20px;
    background-color: white;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    user-select: none;
    white-space: nowrap;
}

.emoji-container .emoji {
    font-size: 24px;
    margin: 0 4px;
    padding: 2px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: inline-block;
}

.emoji-container .emoji:hover {
    background-color: #f0f0f0;
}

/* === POPUP DEL CHAT FLOTANTE === */
.chat-popup {
    /* Cambiado para animación suave */
    opacity: 0;
    visibility: hidden;
    transform: translateY(30px);
    position: fixed;
    bottom: 100px; /* un poco más arriba */
    right: 20px;
    width: 350px;
    height: 500px;
    max-height: 90vh;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    overflow: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
    pointer-events: none;
}

.chat-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.chat-popup-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* === BOT??N CERRAR DEL POPUP === */
.chat-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background-color: #eee;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #333;
    font-size: 20px;
    font-weight: bold;
    line-height: 32px;
    text-align: center;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: background-color 0.3s ease, color 0.3s ease;
    z-index: 10;
}

.chat-close:hover {
    background-color: #007bff;
    color: white;
}

/* === IFRAME DEL CHAT === */
.chat-popup-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0 0 12px 12px;
    margin-top: 30px;
}

/* === RESPONSIVE (pantallas peque??as) === */
@media screen and (max-width: 600px) {
    .input-container {
        flex-direction: column;
        align-items: stretch;
    }

    .input-container input {
        width: 100%;
        margin-bottom: 10px;
    }

    .input-container button {
        width: 100%;
        margin-left: 0;
        min-width: auto;
    }

    #emojiButton {
        display: none;
    }

    .chat-box div.message {
        flex-direction: column;
        align-items: flex-start;
    }

    .chat-box div.message .time-ago {
        align-self: flex-end;
        margin-top: 5px;
    }

    .chat-popup {
        bottom: 60px;
        right: 10px;
        width: 90vw;
        height: 60vh;
        max-height: 70vh;
        border-radius: 12px;
    }

    .chat-popup-content iframe {
        margin-top: 40px;
    }
}

/* === RESPONSIVE PARA TABLETAS (601px a 900px) === */
@media screen and (min-width: 601px) and (max-width: 900px) {
    .chat-popup {
        bottom: 80px;
        right: 15px;
        width: 400px;
        height: 450px;
        max-height: 80vh;
        border-radius: 12px;
    }
}

/* === NOTIFICACIONES (emergentes flotantes) === */
.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #4a90e2, #357ABD);
    color: #fff;
    padding: 16px 28px;
    border-radius: 12px;
    font-family: 'Poppins', Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 8px 20px rgba(53, 122, 189, 0.6);
    z-index: 10000;
    opacity: 0.95;
    user-select: none;
    pointer-events: auto;
    transition: opacity 0.4s ease, transform 0.3s ease;
    max-width: 90vw;
    text-align: center;
}