:root {
    --bg-color: #fafafa;
    --text-color: #262626;
    --border-color: #dbdbdb;
    --primary-color: #000;
}

body, html { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg-color); color: var(--text-color); }

/* --- PERFIL / HEADER --- */
.profile-header { display: flex; justify-content: center; padding: 40px 20px 30px; border-bottom: 1px solid var(--border-color); background: #fff; }
.profile-container { display: flex; align-items: center; gap: 30px; max-width: 800px; width: 100%; }
.profile-image { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; border: 1px solid #eee; }
.profile-info { flex: 1; }
.profile-info h1 { margin: 0 0 10px 0; font-size: 28px; font-weight: normal; }
.profile-info p { margin: 0 0 15px 0; font-size: 16px; line-height: 1.4; color: #444; }
.profile-tags { font-size: 12px; font-weight: bold; letter-spacing: 1.5px; text-transform: uppercase; color: #555; margin-bottom: 15px; }
.btn-contact { display: inline-block; padding: 10px 24px; background: var(--primary-color); color: white; text-decoration: none; font-weight: bold; border-radius: 6px; font-size: 14px; transition: background 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.1);}
.btn-contact.hidden { display: none !important; }
.btn-contact:hover { background: #333; }

/* --- GRID FEED --- */
.grid-container { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; max-width: 1200px; margin: 20px auto; padding: 0 5px; }
.grid-item { position: relative; aspect-ratio: 1 / 1; overflow: hidden; cursor: pointer; background: #eee; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.grid-item:hover img { transform: scale(1.02); }

/* RESPONSIVE: 3 COLUMNAS EN MÓVIL (Y HEADER APILADO) */
@media (max-width: 768px) {
    .profile-container { flex-direction: column; text-align: center; gap: 15px; }
    .grid-container { grid-template-columns: repeat(3, 1fr); gap: 2px; }
    .profile-image { width: 150px; height: 150px; }
    .profile-info h1 { font-size: 22px; }
}

/* --- MODAL OVERLAY (NIVEL 1) --- */
.hidden { display: none !important; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 1000; display: flex; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; backdrop-filter: blur(2px); transition: opacity 0.3s ease, background 0.3s ease;}
.close-modal { position: absolute; top: 15px; right: 20px; background: none; border: none; color: white; cursor: pointer; font-size: 30px; padding: 0; z-index: 1001; text-shadow: 0 2px 4px rgba(0,0,0,0.5);}
.modal-content { background: white; max-width: 1000px; width: 100%; height: 90vh; max-height: 935px; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; transform: scale(0.95); animation: modalOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; box-shadow: 0 10px 30px rgba(0,0,0,0.3);}
@keyframes modalOpen { to { transform: scale(1); } }

/* Botones de Navegación Lateral */
.nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: white; border: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1001; color: #333; box-shadow: 0 4px 10px rgba(0,0,0,0.2); transition: background 0.2s, transform 0.2s; }
.nav-btn:hover { background: #f0f0f0; transform: translateY(-50%) scale(1.05); }
.prev-btn { left: 20px; }
.next-btn { right: 20px; }

.modal-body { display: flex; flex-direction: row; height: 100%; flex: 1; min-height: 0; }
.modal-image-col { flex: 2; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;}
.modal-image-col img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* MODAL RIGHT COLUMN / DETAILS */
.modal-details-col { flex: 1; min-width: 320px; max-width: 400px; display: flex; flex-direction: column; border-left: 1px solid var(--border-color); background: #fff; min-height: 0;}
.modal-header { display: flex; align-items: center; padding: 15px; border-bottom: 1px solid var(--border-color); gap: 10px;}
.modal-header img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.modal-username { font-weight: 600; font-size: 14px;}

.modal-scrollable { flex: 1; overflow-y: auto; padding: 15px; border-bottom: 1px solid var(--border-color);}
.modal-description { font-size: 14px; line-height: 1.5; margin-bottom: 15px; word-wrap: break-word;}

/* Preview de comentarios */
.comments-preview { color: #8e8e8e; font-size: 14px; cursor: pointer; padding: 10px 0; user-select: none; }
.comments-preview:hover { color: #262626; }

.modal-footer { padding: 15px 15px 20px; background: #fff;}
.modal-actions { display: flex; gap: 15px; }
.action-btn { background: none; border: none; display: flex; align-items: center; gap: 5px; font-size: 14px; cursor: pointer; padding: 0; font-weight: 600; color: #262626;}
.action-btn i { font-size: 28px; transition: transform 0.1s; }
.action-btn:active i { transform: scale(0.9); }
.action-btn:hover i { opacity: 0.7; }

/* --- MODAL NIVEL 2: COMENTARIOS --- */
.comments-overlay { z-index: 2000; background: rgba(0,0,0,0.5); }
.comments-modal-content { background: white; width: 100%; max-width: 500px; height: 80vh; max-height: 600px; border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.4); animation: slideUpFade 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.comments-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--border-color); }
.comments-header h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; text-align: center; }
.comments-back-btn, .comments-close-btn { background: none; border: none; cursor: pointer; padding: 5px; color: #262626; display: flex; align-items: center; justify-content: center; }
.comments-back-btn i, .comments-close-btn i { font-size: 24px; }

.comments-body { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 15px; }
.comment-item { display: flex; gap: 12px; font-size: 14px; line-height: 1.4; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.comment-content { flex: 1; }
.comment-author { font-weight: 600; margin-right: 5px; }
.comment-text { color: #262626; word-break: break-word;}
.comment-meta { display: flex; gap: 15px; margin-top: 5px; font-size: 12px; color: #8e8e8e; font-weight: 600; }

.comments-footer { border-top: 1px solid var(--border-color); padding: 15px; background: #fff;}
.comment-form { display: flex; gap: 12px; align-items: center; }
.form-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.form-inputs { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.form-input-row { display: flex; gap: 8px; align-items: center; }
.comment-input-email, .comment-input-text { border: 1px solid var(--border-color); padding: 10px 12px; border-radius: 20px; font-size: 14px; outline: none; background: #fafafa; }
.comment-input-email { width: 100%; box-sizing: border-box; }
.comment-input-text { flex: 1; }
.btn-publish { background: none; border: none; color: #0095f6; font-weight: 600; font-size: 14px; cursor: pointer; padding: 0 5px; }
.btn-publish:disabled { color: #b2dffc; cursor: default; }

/* RESPONSIVE MÓVIL (NIVEL 1 Y NIVEL 2) */
@media (max-width: 768px) {
    /* Modal 1 */
    .modal-content { height: 100vh; max-height: none; border-radius: 0; }
    .modal-body { flex-direction: column; }
    .modal-image-col { flex: none; height: 50vh; }
    .modal-details-col { flex: 1; max-width: 100%; border-left: none; min-height: 0; }
    .nav-btn { background: rgba(0,0,0,0.4); color: white; top: 25vh; transform: translateY(-50%); }
    .prev-btn { left: 10px; }
    .next-btn { right: 10px; }
    .close-modal { top: 10px; right: 10px; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
    
    /* Modal 2: Bottom Sheet */
    .comments-overlay { align-items: flex-end; padding: 0; }
    .comments-modal-content { height: 85vh; max-height: none; border-radius: 16px 16px 0 0; animation: bottomSheetSlide 0.3s cubic-bezier(0.1, 0.8, 0.2, 1) forwards; }
    @keyframes bottomSheetSlide { from { transform: translateY(100%); } to { transform: translateY(0); } }
    .comments-close-btn { display: none; /* Oculta X en móvil si hay flecha atrás */ }
}
