/* =====================================================================
   LiberacionTV - Chat estilo WhatsApp
   Común al frontend (/chat.php) y al panel admin (/admin/chat.php).
   ===================================================================== */

.chat-layout {
    display: grid; grid-template-columns: 320px 1fr; gap: 0;
    max-width: 1100px; margin: 2rem auto; height: calc(100vh - 200px);
    min-height: 500px; background: #fff; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); overflow: hidden;
    border: 1px solid #e2e8f0;
}
.chat-sidebar {
    background: #f8fafc; border-right: 1px solid #e2e8f0;
    display: flex; flex-direction: column;
}
.chat-sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid #e2e8f0; }
.chat-sidebar-header h2 { margin: 0 0 0.3rem; color: #172554; font-size: 1.15rem; }
.chat-sidebar-header p { margin: 0; color: #64748b; font-size: 0.85rem; }
.chat-lista { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.chat-vacio { text-align: center; padding: 2rem 1rem; color: #94a3b8; }
.chat-vacio i { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; opacity: 0.5; }
.chat-vacio p { margin: 0; font-size: 0.9rem; line-height: 1.5; }
.chat-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem;
    cursor: pointer; border-bottom: 1px solid #e2e8f0; transition: background 0.15s;
    text-decoration: none; color: inherit;
}
.chat-item:hover { background: #f1f5f9; }
.chat-item.activo { background: #e0e7ff; border-left: 3px solid #1e3a8a; }
.chat-item-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a, #d4a017);
    color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0;
}
.chat-item-avatar-grande { width: 50px; height: 50px; font-size: 1.8rem; }
.chat-item-meta { flex: 1; min-width: 0; }
.chat-item-titulo { display: block; color: #1e293b; font-weight: 600; font-size: 0.95rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-preview { display: block; color: #64748b; font-size: 0.85rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0.15rem; }
.chat-item-badge {
    background: #dc2626; color: #fff; font-size: 0.7rem; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px; padding: 0 0.4rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-main-header {
    display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.25rem;
    background: #fff; border-bottom: 1px solid #e2e8f0;
}
.chat-main-header strong { display: block; color: #1e293b; }
.chat-main-header small { display: block; color: #16a34a; font-size: 0.8rem; }

.chat-mensajes {
    flex: 1; overflow-y: auto; padding: 1.25rem; background: #f0f4f8;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.chat-msg { max-width: 70%; display: flex; flex-direction: column; }
.chat-msg-mio { align-self: flex-end; }
.chat-msg-otro { align-self: flex-start; }
.chat-msg-contenido {
    padding: 0.6rem 0.9rem; border-radius: 14px; line-height: 1.4;
    word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat-msg-mio .chat-msg-contenido {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: #fff; border-bottom-right-radius: 4px;
}
.chat-msg-otro .chat-msg-contenido {
    background: #fff; color: #1e293b; border-bottom-left-radius: 4px;
}
.chat-msg-meta { display: flex; align-items: center; gap: 0.3rem; padding: 0 0.4rem; margin-top: 0.15rem; }
.chat-msg-mio .chat-msg-meta { justify-content: flex-end; }
.chat-msg-hora { font-size: 0.7rem; color: #94a3b8; }
.chat-msg-mio .chat-msg-hora { color: #cbd5e1; }
.chat-msg-check { font-size: 0.7rem; color: #94a3b8; }
.chat-msg-mio .chat-msg-check { color: #60a5fa; }

.chat-mensaje-vacio {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 2rem; color: #64748b;
}
.chat-mensaje-vacio i { font-size: 3.5rem; color: #cbd5e1; margin-bottom: 1rem; }
.chat-mensaje-vacio h3 { margin: 0 0 0.5rem; color: #1e3a8a; }
.chat-mensaje-vacio p { margin: 0; max-width: 380px; line-height: 1.5; }
.chat-selecciona { padding: 3rem 2rem; }

.chat-input {
    display: flex; gap: 0.5rem; padding: 1rem; background: #fff;
    border-top: 1px solid #e2e8f0;
}
.chat-input input {
    flex: 1; padding: 0.75rem 1rem; border: 1px solid #cbd5e1; border-radius: 24px;
    font-size: 1rem; font-family: inherit; outline: none;
    transition: border-color 0.2s;
}
.chat-input input:focus { border-color: #1e3a8a; }
.chat-input button { border-radius: 50%; width: 44px; height: 44px; padding: 0; flex-shrink: 0; }
.chat-input button i { margin: 0; }

@media (max-width: 768px) {
    .chat-layout { grid-template-columns: 1fr; height: auto; }
    .chat-sidebar { max-height: 40vh; }
    .chat-msg { max-width: 85%; }
}
