/* ═══════════════════════════════════════════════════════════════════════════════
   4. ÁREA PRINCIPAL DE CHAT
   Panel derecho con el chat activo, mensajes y entrada de texto
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   4.1 Contenedor Principal del Área de Chat
   ───────────────────────────────────────────────────────────────────────────── */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0b141a;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4.2 Pantalla de Bienvenida
   Se muestra cuando no hay chat seleccionado
   ───────────────────────────────────────────────────────────────────────────── */

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222e35;
}

.welcome-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.whatsapp-logo {
    font-size: 120px;
    color: #00a884;
    margin-bottom: 24px;
}

.welcome-content h2 {
    color: #e9edef;
    font-size: 32px;
    font-weight: 300;
    margin-bottom: 16px;
}

.welcome-content p {
    color: #aebac1;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4.3 Chat Activo
   Contenedor del chat cuando hay una conversación seleccionada
   ───────────────────────────────────────────────────────────────────────────── */

.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative; /* Para el panel de búsqueda absoluto */
    min-height: 0; /* Importante para que flex funcione correctamente */
    overflow: hidden;
}

.chat-header {
    background: #202c33;
    padding: 10px 16px;
    display: flex;
    flex-shrink: 0; /* Nunca se encoge */
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #313d45;
}

.contact-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    background: #00a884;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.contact-details h3 {
    color: #e9edef;
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 2px;
}

.contact-details span {
    color: #aebac1;
    font-size: 13px;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4.4 Área de Mensajes
   Contenedor scrolleable con la lista de mensajes
   ───────────────────────────────────────────────────────────────────────────── */

.messages-container {
    flex: 1;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><defs><pattern id="pattern" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="%23ffffff" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="%230b141a"/><rect width="100" height="100" fill="url(%23pattern)"/></svg>');
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    scroll-behavior: smooth;
    min-height: 0; /* Importante para que flex funcione correctamente */
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4.5 Mensajes (Enviados y Recibidos)
   Estilos de las burbujas de mensaje
   ───────────────────────────────────────────────────────────────────────────── */

.message {
    max-width: 65%;
    padding: 8px 12px;
    padding-top: 12px; /* Espacio extra para el botón de estrella */
    padding-right: 35px; /* Espacio para el botón de estrella a la derecha */
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
}

.message.sent {
    background: #005c4b;
    color: #e9edef;
    align-self: flex-end;
    margin-left: auto;
}

.message.received {
    background: #202c33;
    color: #e9edef;
    align-self: flex-start;
}

.message-content {
    margin-bottom: 4px;
    white-space: pre-wrap; /* Preserva espacios y saltos de línea */
    line-height: 1.4; /* Mejor espaciado entre líneas */
    word-wrap: break-word; /* Rompe palabras largas */
}

.message-media {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
}

.message-media img {
    width: 100%;
    height: auto;
    display: block;
}

.message-media video {
    width: 100%;
    height: auto;
    display: block;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: #00a884;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.file-info {
    flex: 1;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.file-size {
    font-size: 12px;
    opacity: 0.7;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
    margin-top: 4px;
}

.message.sent .message-time {
    color: rgba(233, 237, 239, 0.6);
}

.message.received .message-time {
    color: rgba(174, 186, 193, 0.8);
}

/* ─────────────────────────────────────────────────────────────────────────────
   4.6 Contenido Multimedia
   Imágenes, videos, archivos y audio en mensajes
   ───────────────────────────────────────────────────────────────────────────── */

.media-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: #aebac1;
    font-size: 14px;
}

.media-loading i {
    animation: spin 1s linear infinite;
}

.media-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: #ff4444;
    font-size: 14px;
}

.media-caption {
    margin-top: 8px;
    font-size: 14px;
    color: #e9edef;
}

.audio-player {
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 8px;
}

.message-media img {
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-media img:hover {
    opacity: 0.9;
}

.message-media video {
    cursor: pointer;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────────────────────
   4.7 Input de Mensaje
   Barra inferior para escribir y enviar mensajes
   ───────────────────────────────────────────────────────────────────────────── */

.message-input-container {
    background: #202c33;
    padding: 12px;
    border-top: 1px solid #313d45;
    flex-shrink: 0; /* Nunca se encoge, siempre visible */
}

.message-input {
    background: #2a3942;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
}

.emoji-btn {
    background: none;
    border: none;
    color: #aebac1;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.input-wrapper {
    flex: 1;
}

.input-wrapper input {
    background: none;
    border: none;
    color: #e9edef;
    font-size: 15px;
    width: 100%;
    outline: none;
    padding: 8px 0;
}

.input-wrapper input::placeholder {
    color: #aebac1;
}

.attach-btn, .send-btn {
    background: none;
    border: none;
    color: #aebac1;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.send-btn:hover {
    color: #00a884;
}

