/* ===============================
   CONFIGURACIÓN GENERAL
   =============================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}

/* ===============================
   CONTENEDOR PRINCIPAL
   =============================== */

main {
    width: 90%;
    max-width: 1000px;
    margin: 40px auto;
}


/* ===============================
   TÍTULO
   =============================== */

h1 {
    text-align: center;
    margin-bottom: 35px;
    font-size: 32px;
}


/* ===============================
   TARJETA DEL CORREO
   =============================== */

.correo-principal {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}


/* ===============================
   TEXTO DEL CORREO
   =============================== */

.correo-principal p {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
}


/* ===============================
   ÁREA DEL CORREO
   =============================== */

.correo-acciones {
    display: flex;
    gap: 10px;
    align-items: center;
}


/* ===============================
   CAMPO DEL CORREO Y COPIAR
   =============================== */

#correo {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    background: #f9fafb;
    color: #111827;
}

#btnCopiar {
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    background: #6b7280;
    color: white;
    cursor: pointer;
    font-size: 15px;
}

/* ===============================
   BOTONES GENERAR Y ELIMINAR
   =============================== */

#btnGenerar,
#btnEliminar {
    padding: 12px 20px;
    margin-top: 15px;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 15px;
}

#btnGenerar {
    background: #2563eb;
}

#btnEliminar {
    background: #dc2626;
}

#btnGenerar:hover {
    background: #1d4ed8;
}

#btnEliminar:hover {
    background: #b91c1c;
}



/* ===============================
   BANDEJA DE ENTRADA
   =============================== */

section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.bandeja-encabezado {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.bandeja-encabezado h2 {
    margin: 0;
    font-size: 22px;
}

#btnActualizar {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: #6b7280;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

#btnActualizar:hover {
    background: #4b5563;
}


/* ===============================
   MENSAJES DE LA BANDEJA
   =============================== */

#listaMensajes {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mensaje {
    padding: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    cursor: pointer;
}

.mensaje:hover {
    background: #f3f4f6;
}

.mensaje p {
    margin: 5px 0;
}

.mensaje strong {
    color: #111827;
}



/* ===============================
   MODAL PARA LEER EL CORREO
   =============================== */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal.mostrar {
    display: flex;
}

.modal-contenido {
    position: relative;
    width: 90%;
    max-width: 650px;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.cerrar-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
}

#modalAsunto {
    margin-top: 0;
    margin-bottom: 20px;
}

.datos-correo p {
    margin: 8px 0;
}

.contenido-correo {
    margin-top: 20px;
    line-height: 1.6;
    white-space: pre-wrap;
}



/* ===============================
   BLOQUES DE MENSAJES
================================ */

.mensaje {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 18px;
    margin-bottom: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
}

/* Efecto al pasar el mouse */
.mensaje:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Línea lateral de mensaje NO LEÍDO */
.mensaje.no-leido {
    border-left: 5px solid #181a1b;
}

/* Información del mensaje */
.mensaje-info {
    min-width: 0;
    flex: 1;
}

/* Asunto */
.mensaje h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
}

/* Remitente */
.remitente {
    margin: 0 0 8px 0;
    color: #555;
}

/* Vista previa */
.vista-previa {
    margin: 0;
    color: #777;

    /* Evita que textos o URLs largas rompan la página */
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Fecha */
.fecha-mensaje {
    margin-left: 15px;
    white-space: nowrap;
    color: #888;
}


/* ===============================
   LINKS DE LOS MENSAJES
   =============================== */

#modalContenido {
    max-width: 100%;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;

    max-height: 400px;
    overflow-y: auto;
}

#modalContenido a {
    color: #0066cc;
    text-decoration: underline;
    font-weight: bold;

    overflow-wrap: anywhere;
    word-break: break-all;
}

#modalContenido a:hover {
    color: #004999;
}

/* ===============================
   BOTÓN MODO OSCURO
   =============================== */

/* ===============================
   BOTÓN MODO OSCURO
   =============================== */

#btnModoOscuro {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background: #374151;
    color: white;
    cursor: pointer;
    font-size: 14px;
    z-index: 1000;
}

#btnModoOscuro:hover {
    background: #1f2937;
}

/* ===============================
   MODO OSCURO
   =============================== */

body.modo-oscuro {
    background: #111827;
    color: #f9fafb;
}

body.modo-oscuro .correo-principal,
body.modo-oscuro section {
    background: #1f2937;
}

body.modo-oscuro .correo-principal p,
body.modo-oscuro .bandeja-encabezado h2 {
    color: #f9fafb;
}

body.modo-oscuro #correo {
    background: #374151;
    color: white;
    border-color: #4b5563;
}

body.modo-oscuro .mensaje {
    background: #374151;
    border-color: #4b5563;
}

body.modo-oscuro .mensaje:hover {
    background: #4b5563;
}

body.modo-oscuro .modal-contenido {
    background: #1f2937;
    color: #f9fafb;
}

body.modo-oscuro hr {
    border-color: #4b5563;
}

/* ===============================
   BOTÓN DESCARGAR ARCHIVO
   =============================== */

.btn-descargar {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background-color: #00AEEF;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 14px;
}

.btn-descargar:hover {
    opacity: 0.85;
}
/* ===============================
   IMÁGENES DE LOS ARCHIVOS ADJUNTOS
   =============================== */

.adjuntos-modal {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.archivo-modal {
    display: block;
}

/* Miniatura */
#modalContenido .imagen-adjunta {
    width: 180px;
    height: 130px;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid #ddd;
    background: #f5f5f5;
}


/* ===============================
   VISOR DE IMAGEN GRANDE
   =============================== */

.visor-imagen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);

    display: flex;
    justify-content: center;
    align-items: center;

    z-index: 2000;
    padding: 20px;

    cursor: pointer;
}

.visor-imagen img {
    max-width: 90%;
    max-height: 90vh;

    object-fit: contain;

    border-radius: 8px;

    cursor: default;
}