:root {
    --primary-color: #0f172a;
    --bg-body: #f9fafb;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-width: 260px;
    --accent-blue: #38bdf8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: white;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease; /* Para que abra suavemente */
}

/* Adaptación para Móbiles */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 250px;
        z-index: 10000; /* Por enriba de todo */
        transform: translateX(-100%); /* Agochada á esquerda */
        background: #0f172a;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    /* Clase que aplicaremos con JS para amosar o menú */
    .sidebar.active {
        transform: translateX(0);
    }
}

/* 1. Oculto por defecto en PC e tablets grandes */
#mobile-menu-btn {
    display: none; 
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 11000;
}

@media (max-width: 768px) {
    #mobile-menu-btn {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 11000; /* Máis alto que a sidebar (10000) */
        background: white;
        border: 1px solid var(--border-color);
        padding: 8px;
        border-radius: 8px;
    }
}

.sidebar h2 span { color: var(--primary-color); }

.sidebar ul {
    list-style: none;
    margin-top: 3rem;
}

.sidebar li {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: 0.3s;
    margin-bottom: 0.5rem;
}

.sidebar li:hover, .sidebar li.active {
    background: rgba(255, 255, 255, 0.1); 
    color: var(--accent-blue);
}

.sidebar li.logout {
    margin-top: auto;
    color: #f87171;
}

/* Contenido Principal */
.profile-content {
    flex: 1;
    padding: 3rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.profile-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    padding: 2rem;
    display: grid;
    grid-template-columns: 200px 1fr;/* Dúas columnas en PC */
    gap: 3rem;
    align-items: start;
}

/* Adaptación reactiva para Móbiles */
@media (max-width: 768px) {
    .profile-card {
        display: flex; /* Cambiamos grid por flex para facilitar o aliñamento */
        flex-direction: column; /* Todo un debaixo do outro */
        align-items: center; /* Centramos todo o contido */
        text-align: center;  /* Centramos o texto (bio e nome) */
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .avatar-section {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .profile-info {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr; /* Os inputs que ían en parella agora van un debaixo do outro */
    }
}

/* Formulario */
.avatar-section {
    text-align: center;
}

.avatar-section img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: #eee;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Botones */
.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

@media (max-width: 768px) {
    .btn-primary {
        width: 100%; /* Botón grande e fácil de premer */
        padding: 1rem;
    }
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.notifications-dropdown { position: relative; }
.badge {
    position: absolute; top: -5px; right: -5px;
    background: #ef4444; color: white;
    font-size: 10px; padding: 2px 6px;
    border-radius: 50%; border: 2px solid white;
}
.notif-content {
    position: absolute; right: 0; top: 40px;
    width: 300px; background: white;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-radius: 8px; z-index: 1000;
    max-height: 400px; overflow-y: auto;
    border: 1px solid #e2e8f0;
}
.notif-item {
    padding: 12px; border-bottom: 1px solid #f1f5f9;
    cursor: pointer; font-size: 0.9rem;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { border-left: 4px solid #4f46e5; background: #f0f4ff; }
.notif-item small { color: #64748b; display: block; margin-top: 4px; }

        /* --- REDESEÑO CHAT ADAPTATIVO --- */
        #chat-modal {
            display: none;
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 380px;
            height: 550px;
            background: white;
            border-radius: 15px;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
            z-index: 9999;
            flex-direction: column;
            overflow: hidden;
            border: 1px solid #e2e8f0;
        }

        @media (max-width: 600px) {
            #chat-modal {
                width: 100% !important;
                height: 100% !important;
                bottom: 0 !important;
                right: 0 !important;
                border-radius: 0 !important;
                top: 0;
                left: 0;
            }
            .social-section { grid-template-columns: 1fr; }
        }

        #chat-messages { flex: 1; overflow-y: auto; padding: 15px; background: #f8fafc; display: flex; flex-direction: column; }
        
        /* Burbullas */
        .msg-container { margin-bottom: 12px; display: flex; flex-direction: column; }
        .msg-me { align-items: flex-end; }
        .msg-them { align-items: flex-start; }
        
        .msg-bubble {
            max-width: 85%;
            padding: 10px 14px;
            border-radius: 18px;
            font-size: 0.95rem;
            line-height: 1.4;
            word-wrap: break-word;
        }
        .msg-me .msg-bubble { background: #4f46e5; color: white; border-bottom-right-radius: 4px; }
        .msg-them .msg-bubble { background: #e5e7eb; color: #1f2937; border-bottom-left-radius: 4px; }

/* amigos */
        /* --- ESTILOS SOCIAL --- */
        .social-section { margin-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
        .social-card { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
        .request-item, .friend-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
        .status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
        .online { background: #22c55e; }
        .offline { background: #94a3b8; }
        .btn-small { padding: 5px 10px; border-radius: 6px; border: none; cursor: pointer; font-size: 0.8rem; }
        .btn-accept { background: #dcfce7; color: #15803d; }
        .btn-decline { background: #fee2e2; color: #ef4444; }
        
        .notification-badge { position: absolute !important; top: 2px; right: 2px; background: #ef4444; color: white; font-size: 0.7rem; font-weight: bold; border-radius: 50%; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; border: 2px solid white; z-index: 10; }


/* --- AXUSTES REACTIVOS PARA O PERFIL --- */
@media (max-width: 768px) {
    /* 1. Tarxeta de Perfil: Foto enriba, nome/bio embaixo */
    .profile-card {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 1.5rem !important;
    }

    .avatar-section {
        width: 100%;
    }

    .profile-form {
        width: 100%;
    }

    /* 2. Sección Social: De 2 columnas a 1 */
    .social-section {
        grid-template-columns: 1fr !important; 
        gap: 15px !important;
    }

    /* 3. Items de Amigos e Solicitudes: Foto/Info enriba, botóns embaixo */
    .request-item, .friend-item {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 15px !important;
        background: #f8fafc; /* Un lixeiro fondo para que pareza unha tarxeta */
        border-radius: 8px;
        text-align: center;
    }

    /* Aliñamos o contido do amigo no centro */
    .friend-item > div {
        justify-content: center !important;
        width: 100%;
    }

    /* Botóns de acción máis grandes para o dedo */
    .btn-small {
        position: relative; /* Fundamental */
        padding: 10px 20px !important;
        width: 100%;
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }

/* Contenedor do botón para que non se estire en móbil */
.btn-chat {
    position: relative !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;  /* Forzamos un tamaño fixo */
    height: 40px;
    padding: 0 !important; /* Evitamos que o padding de móbil desplace a icona */
    background: transparent;
    border: none;
    cursor: pointer;
}

}

/*Friends--------*/
        .search-box { max-width: 600px; margin: 2rem auto; position: relative; }
        .search-input { width: 100%; padding: 15px 15px 15px 45px; border-radius: 30px; border: 2px solid #e2e8f0; font-size: 1rem; outline: none; transition: 0.3s; }
        .search-input:focus { border-color: #4f46e5; box-shadow: 0 0 10px rgba(79, 70, 229, 0.1); }
        .search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
        
        .friends-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-top: 2rem; }
        .friend-card { background: white; padding: 1.5rem; border-radius: 15px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.05); transition: 0.3s; }
        .friend-card:hover { transform: translateY(-5px); }
        .avatar-placeholder { width: 70px; height: 70px; background: #f1f5f9; border-radius: 50%; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #4f46e5; border: 3px solid #fff; outline: 2px solid #4f46e5; }
        .status-badge { font-size: 0.75rem; padding: 4px 10px; border-radius: 12px; margin-top: 5px; display: inline-block; }
        .online { background: #dcfce7; color: #15803d; }
        .offline { background: #f1f5f9; color: #64748b; }

        /* O fondo escuro que cobre toda a pantalla */
        .modal-overlay {
            display: none; /* OCULTO POR DEFECTO */
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6); /* Fondo semi-transparente */
            backdrop-filter: blur(4px); /* Efecto de desenfoque elegante */
            justify-content: center;
            align-items: center;
            z-index: 9999; /* Por enriba de todo */
        }

        /* A tarxeta branca do centro */
        .modal-content {
            background: white;
            padding: 2.5rem;
            border-radius: 24px;
            width: 90%;
            max-width: 420px;
            position: relative;
            text-align: center;
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            animation: modalAppear 0.3s ease-out; /* Animación de entrada */
        }

        /* Animación para que non apareza de golpe */
        @keyframes modalAppear {
            from { transform: scale(0.9); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }

        /* Efecto de elevación nas tarxetas */
        .friend-card {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            border: 1px solid #f1f5f9;
        }

        .friend-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            border-color: #4f46e5;
        }

        /* Estilo para o avatar do modal */
        .avatar-large {
            width: 120px;
            height: 120px;
            margin: 0 auto 1rem;
            display: block;
            border: 4px solid #fff;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }