/* ===== Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ===== Contenedor ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* ===== Encabezado ===== */
.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 24px;
    text-align: center;
    color: white;
    position: relative;
}

.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dots" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle fill="rgba(255,255,255,0.1)" cx="10" cy="10" r="1"/></pattern></defs><rect width="100" height="100" fill="url(%23dots)"/></svg>');
    opacity: 0.3;
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.header .subtitle {
    font-size: 16px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* ===== Buscador ===== */
.search-container {
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 16px;
    background: white;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== Lista de contactos ===== */
.contact-list {
    max-height: 600px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

.contact-list::-webkit-scrollbar {
    width: 6px;
}
.contact-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* ===== Ítem de contacto ===== */
.contact-item {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #f1f3f4;
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
    position: relative;
    flex-wrap: wrap; /* 🔹 Para que en móvil los textos no se encimen */
}

.contact-item:hover {
    background: #f8f9ff;
    transform: translateX(4px);
}

.contact-item:last-child {
    border-bottom: none;
}

/* Avatar */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    margin-right: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Info contacto */
.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-size: 16px;
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-preview {
    font-size: 14px;
    color: #718096;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Meta */
.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.contact-time {
    font-size: 12px;
    color: #a0aec0;
}

.unread-badge {
    background: #667eea;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

/* Estado en línea */
.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #48bb78;
    border: 2px solid white;
    border-radius: 50%;
}

/* Divisiones de secciones */
.section-divider {
    padding: 12px 24px;
    background: #f7fafc;
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #e2e8f0;
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: #a0aec0;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        width: 100%;
    }

    .contact-item {
        padding: 12px 16px;
    }

    .contact-name {
        font-size: 15px;
    }

    .contact-preview {
        font-size: 13px;
        max-width: 180px; /* 🔹 Evita que se encime con la hora */
    }

    .contact-meta {
        flex-direction: row; 
        gap: 8px;
        align-items: center;
        justify-content: flex-end;
        width: 100%;
        margin-top: 4px;
    }

    .unread-badge {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .contact-preview {
        display: none; /* 🔹 En pantallas muy chicas solo se ve nombre y hora */
    }
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.contact-item {
    animation: fadeIn 0.4s ease-out;
}

.contact-item:nth-child(odd) {
    animation-delay: 0.1s;
}

.contact-item:nth-child(even) {
    animation-delay: 0.2s;
}
