/**
 * ════════════════════════════════════════════════════════════
 * LAYOUT DE MENSAJERÍA - DISEÑO DE 2 COLUMNAS
 * Version: 1.0 - Layout moderno con lista + chat
 * ════════════════════════════════════════════════════════════
 */

/* ════════════════════════════════════════════════════════════
   CONTENEDOR PRINCIPAL
   ════════════════════════════════════════════════════════════ */
.mensajes-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 600px;
    max-height: 800px;
}

/* ════════════════════════════════════════════════════════════
   COLUMNA IZQUIERDA - SIDEBAR (Lista de mensajes)
   ════════════════════════════════════════════════════════════ */
.mensajes-sidebar {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

/* Botones superiores */
.mensajes-sidebar .btn {
    margin: 0 !important;
    border-radius: 0 !important;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mensajes-sidebar .btn:first-of-type {
    border-radius: 16px 16px 0 0 !important;
}

.mensajes-sidebar #btnNuevoMensaje {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s ease;
}

.mensajes-sidebar #btnNuevoMensaje:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6b3d91 100%);
    transform: translateY(-1px);
}

.mensajes-sidebar #btnEnviarATodos,
.mensajes-sidebar #btnEnviarPorCurso {
    background: #10b981;
    color: white;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
}

.mensajes-sidebar #btnEnviarPorCurso {
    background: #3b82f6;
}

/* ════════════════════════════════════════════════════════════
   LISTA DE MENSAJES
   ════════════════════════════════════════════════════════════ */
.mensajes-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.mensajes-list .mensaje-item {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.mensajes-list .mensaje-item:hover {
    background: #f9fafb;
}

.mensajes-list .mensaje-item.active {
    background: #eff6ff;
    border-left: 4px solid #2563eb;
}

.mensajes-list .mensaje-item.no-leido {
    background: #fef3c7;
}

/* Avatar del mensaje */
.mensaje-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

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

.mensaje-nombre {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mensaje-fecha {
    font-size: 11px;
    color: #9ca3af;
}

.mensaje-preview {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.badge-no-leido {
    background: #ef4444;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 700;
    margin-left: 6px;
}

/* ════════════════════════════════════════════════════════════
   COLUMNA DERECHA - VISOR DE MENSAJES (Chat)
   ════════════════════════════════════════════════════════════ */
.mensajes-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.mensaje-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Estado vacío */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 80px;
    color: #e5e7eb;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
}

/* Header del chat */
.mensaje-header {
    padding: 20px 24px;
    background: linear-gradient(to right, #f9fafb, #ffffff);
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mensaje-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mensaje-header .badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
}

/* Contenido del chat */
.mensaje-contenido-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}

.mensaje-texto-completo {
    background: white;
    padding: 20px 24px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    line-height: 1.7;
    color: #374151;
    font-size: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Metadatos del mensaje */
.mensaje-metadata {
    display: flex;
    gap: 24px;
    padding: 20px 24px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    flex-wrap: wrap;
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 13px;
}

.metadata-item i {
    color: #9ca3af;
}

.metadata-item strong {
    color: #111827;
    font-weight: 600;
}

/* Acciones del mensaje */
.mensaje-acciones {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.mensaje-acciones .btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mensaje-acciones .btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    border: none;
    color: white;
}

.mensaje-acciones .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.mensaje-acciones .btn-danger {
    background: #ef4444;
    border: none;
    color: white;
}

.mensaje-acciones .btn-danger:hover {
    background: #dc2626;
}

.mensaje-acciones .btn-success {
    background: #10b981;
    border: none;
    color: white;
}

.mensaje-acciones .btn-success:hover {
    background: #059669;
}

/* ════════════════════════════════════════════════════════════
   SCROLLBAR PERSONALIZADO
   ════════════════════════════════════════════════════════════ */
.mensajes-list::-webkit-scrollbar,
.mensaje-contenido-wrapper::-webkit-scrollbar {
    width: 8px;
}

.mensajes-list::-webkit-scrollbar-track,
.mensaje-contenido-wrapper::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.mensajes-list::-webkit-scrollbar-thumb,
.mensaje-contenido-wrapper::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.mensajes-list::-webkit-scrollbar-thumb:hover,
.mensaje-contenido-wrapper::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .mensajes-layout {
        grid-template-columns: 320px 1fr;
    }
}

@media (max-width: 768px) {
    .mensajes-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .mensajes-sidebar {
        max-height: 400px;
    }
    
    .mensajes-content {
        min-height: 500px;
    }
}

/* ════════════════════════════════════════════════════════════
   ANIMACIONES
   ════════════════════════════════════════════════════════════ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.mensaje-item,
.mensaje-viewer > * {
    animation: fadeIn 0.3s ease;
}

/* ════════════════════════════════════════════════════════════
   FIX PARA ASEGURAR LAYOUT DE 2 COLUMNAS
   ════════════════════════════════════════════════════════════ */

/* Forzar que mensajes-content esté visible */
#section-mensajes .mensajes-content {
    display: flex !important;
    flex-direction: column !important;
}

/* Asegurar que el layout sea grid de 2 columnas */
#section-mensajes .mensajes-layout {
    display: grid !important;
    grid-template-columns: 380px 1fr !important;
}

/* Asegurar que sidebar no crezca */
#section-mensajes .mensajes-sidebar {
    width: 100% !important;
    max-width: 380px !important;
}

/* El visor debe ocupar todo el espacio disponible */
#section-mensajes #mensajeViewer {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Remover cualquier estilo que oculte la columna derecha */
.mensajes-content {
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
}
