/* ======================== */
/*      ESTILOS GLOBALES    */
/* ======================== */

html, body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
    height: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

/* Reset de márgenes y padding */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ======================== */
/*         HEADER           */
/* ======================== */
.app-header {
    background-color: #075E54;
    padding: 10px;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    height: 80px;
}

/* Contenedor del logo */
.logo-container {
    position: absolute;
    left: 32%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

/* Logo */
.app-header .logo {
    height: 50px;
    display: block;
}




/* ======================== */
/*   CHAT HEADER Y CONTADOR */
/* ======================== */
/* Aseguramos que el header actúe como contenedor posicionado */
#chat-header {
  position: relative;
  background-color: #ecf3f2;
  padding: 5px 10px;
  color: rgb(13, 71, 59);
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ccc;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}

/* Ajuste para que la información del contacto no quede tapada */
.contact-header-info {
  margin-left: 60px; /* Deja espacio al lado izquierdo para el botón */
  display: flex;
  align-items: center;
}

.contact-header-name {
    font-size: 14px;
    margin-left: 10px;
    color: #024d3e;
}

.contact-header-image-container {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.contact-header-image-container i {
    font-size: 16px;
    color: #075E54;
}
.contact-header-image {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.message-email {
    font-size: 0.73em;
    color: #888;
    margin-top: 5px;
}

/* Contador */
.contador-numeros {
    font-size: 1.2em;
    font-weight: bold;
}
.contador-texto {
    font-size: 0.8em;
    color: #666;
}
.contador-container {
    text-align: center;
    margin-bottom: 30px;
    position: fixed;
    display: none;
}
.ultima-interaccion {
    font-size: 0.8em;
    color: #777;
    margin-top: 5px;
}
.contador-chat {
    font-size: 1em;
    color: #075E54;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    margin-bottom: 70px;
    background-color: #f0f8ff;
    border-radius: 5px;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
    width: 100px;
    margin-left: auto;
    margin-right: auto;
    position: fixed;
    bottom: 10px;
    display: none;
}
.contador-chat.active {
    color: #28a745;
    background-color: #e8f5e9;
}
.contador-chat.hidden {
    display: none;
}


/* ======================== */
/*      BARRA LATERAL       */
/* ======================== */
.chat-container {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 60px);
}

.contact-sidebar {
    width: 30%;
    padding: 10px;
    background-color: #f7f7f7;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-width: 140px;
}

#search-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
}

.contact-list {
    flex: 1;
    overflow-y: auto;
}

/* ======================== */
/*       CONTACTOS          */
/* ======================== */
.contact {
    position: relative;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}

.contact:hover {
    background-color: #b5dccd;
}

.contact-name {
    font-size: 14px;
    font-weight: bold;
    color: #075E54;
    display: block;
    margin-bottom: 3px;
}

.contact-message-preview {
    font-size: 12px;
    font-style: italic;
    color: #727272;
    display: block;
}


/* Indicador de mensajes no leídos */
.unread-indicator {
    background-color: red;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Notificación (dentro de .contact) */
.contact .notification {
    position: absolute;
    top: 1px;
    right: 2px;
    background-color: #d43d3d;
    color: white;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    display: none;
}
.contact.unread .notification {
    display: flex;
}
.contact.unread {
    font-weight: bold;
    background-color: #ffefef;
}

/* Estilos específicos para plataformas */
.whatsapp .contact {
    background-color: #dbf5eb;
    color: #075E54;
}
.whatsapp .contact:hover {
    background-color: #b5dccd;
}
.messenger .contact {
    background-color: #e3f2fd;
    color: #1e4864;
}
.messenger .contact:hover {
    background-color: #b0daf9;
}
.instagram .contact {
    background-color: #f3e5f5;
    color: #62366a;
}
.instagram .contact:hover {
    background-color: #ce93d8;
}

/* Otros estilos generales */
h3 {
    display: flex;
    align-items: center;
    font-size: 1rem;
    margin-bottom: 10px;
    color: #075E54;
}
h3 i {
    margin-right: 8px;
}


/* ======================== */
/*         CHAT CONTENT     */
/* ======================== */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    background-color: #f8efe2;
}

.chat-box {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background-color: #f8efe2;
    scroll-margin-bottom: 60px;
}

.message {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 8px;
    max-width: 70%;
    word-wrap: break-word;
    clear: both;
}

.message.received {
    background-color: #fcfcfc;
    text-align: left;
    float: left;
}

.message.sent {
    background-color: #dcf8c6;
    text-align: right;
    float: right;
    clear: both;
}

/* Etiqueta para adjuntar archivos */
.file-attach-label {
    cursor: pointer;
    font-size: 20px;
    color: #075E54;
    margin-right: 6px;
}
.file-attach-label:hover {
    color: #064e45;
}

/* Imágenes y audio en mensajes */
.received-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 5px;
}
.message img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 5px;
}
.message audio {
    width: 100%;
    margin-top: 5px;
}
.audio-container {
    display: flex;
    align-items: center;
    margin-top: 5px;
}
.play-button {
    background: none;
    border: none;
    margin-right: 10px;
    cursor: pointer;
}
.play-button i {
    font-size: 20px;
    color: #075E54;
}

/* ======================== */
/*     FORMULARIO DE MSG    */
/* ======================== */
#message-form {
    display: flex;
    padding: 10px;
    background-color: #fff;
    position: sticky;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
}
#message-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-right: 10px;
    max-height: 80px;
    overflow-y: auto;
    resize: none;
    box-sizing: border-box;
}
.message-time {
    margin-top: 5px;
    font-size: 11px;
    color: #888;
    text-align: right;
}

/* Botones */
button {
    padding: 10px 20px;
    background-color: #075E54;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 5px;
}
button:hover {
    background-color: #064e45;
}
.notification {
    background-color: #166b53;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    margin-left: 10px;
}
#emoji-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    margin-left: 5px;
}

/* ======================== */
/*          MODAL           */
/* ======================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
}
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}
.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}


/* ======================== */
/*  VISTA MOBILE Y RESPONSIVE */
/* ======================== */

/* Clases para alternar vistas en móvil */
.hide-list {
    display: none !important;
}
.show-chat {
    display: block !important;
    width: 100%;
}

/* Ajustes para pantallas pequeñas */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: row;
        height: 100vh;
        box-sizing: border-box;
    }
    button {
        padding: 8px 16px;
        font-size: 14px;
        flex-shrink: 0;
        min-width: 50px;
    }
    h3 {
        font-size: 0.9rem;
    }
    .contact-sidebar {
        width: 30%;
        min-width: 150px;
        height: 100vh;
    }
    #message-form {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        background-color: #fff;
        display: flex;
        align-items: center;
        box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        box-sizing: border-box;
    }
    #message-input {
        flex: 1;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 8px;
        margin-right: 10px;
        max-height: 80px;
        overflow-y: auto;
        min-width: 0;
    }
    .chat-content {
        flex: 1;
        height: 100vh;
        box-sizing: border-box;
        overflow-x: hidden;
        background-color: #f8efe2;
    }
    .chat-box {
        height: calc(100vh - 120px);
        overflow-y: auto;
        scroll-margin-bottom: 30px;
        background-color: #f8efe2;
        padding-bottom: 80px; /* Espacio para que el formulario no tape el último mensaje */
    }
    /* Por defecto, en móvil se muestra la lista a pantalla completa y se oculta el chat */
    #chatContent {
        display: none;
        width: 100%;
    }
    #contactSidebar {
        width: 100%;
        display: block;
    }
  /* Estilos para la vista móvil: el botón "Regresar" dentro del header */
.back-button-container {
    width: 100%;
    margin-top: 5px; /* Reducir el margen superior */
}

/* Botón "Regresar" oculto por defecto */
#back-button {
    display: none; /* Inicialmente oculto */
    border: 1px solid #ffffff; /* Borde más delgado */
    background: none;
    color: #ffffff;
    padding: 5px 8px; /* Reducir padding */
    font-size: 9px; /* Reducir tamaño de fuente */
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    border-radius: 20px; /* Ajustar bordes redondeados */
    text-align: center;
    font-weight: bold;
}

/* Efecto hover */
#back-button:hover {
    color: #0A7A6C;
    border-color: #f0f0f0;
    transform: scale(1.03); /* Reducir el efecto de agrandamiento */
}






}

/* Ajustes para pantallas aún más pequeñas */
@media (max-width: 600px) {
    #message-input {
        font-size: 12px;
    }
    button {
        font-size: 12px;
        padding: 6px 12px;
    }
    h3 {
        font-size: 0.8rem;
    }
}


/* Agregar scroll vertical a cada categoría de contactos */
.contact-list.whatsapp,
.contact-list.messenger,
.contact-list.instagram {
  max-height: 300px; /* Ajusta la altura según tu diseño */
  overflow-y: auto;
  padding-right: 5px; /* Opcional, para que no se corte el contenido al hacer scroll */
}
