/*
 * Shared "profile card" layout - reused by every page built around the same
 * card: profile.html (own profile and any other account's - same template,
 * see accounts.views._build_profile_context), settings.html, search_users,
 * follow_requests. Page-specific bits (profile-table, logger-config-form,
 * ...) stay inline in settings.html itself.
 */

.profile-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    width: 100%;
}

/* Plat, sans fond ni ombre - aligné sur le style du reste du site (feed,
   sessions, circuits : un simple .container). */
.profile-card {
    padding: var(--space-lg);
}

.profile-card h1 {
    font-size: 1.5rem;
    color: var(--color-text);
    margin: 0;
}

.profile-card h2 {
    font-size: 1.2rem;
    color: var(--color-text);
    margin: 0 0 var(--space-md) 0;
}

.profile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.profile-info-row {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border-light);
}

.profile-info-row:last-child {
    border-bottom: none;
}

.profile-info-row dt {
    flex: 0 0 170px;
    font-weight: 600;
    color: var(--color-text);
}

.profile-info-row dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--color-text);
}

.text-muted {
    color: var(--color-text-muted);
}

.profile-card-footer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-light);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

@media (max-width: 480px) {
    .profile-info-row {
        flex-direction: column;
        gap: 0.25rem;
    }

    .profile-info-row dt {
        flex: none;
    }
}

/*
 * Social components (Strava/Instagram-inspired) - avatar, person rows
 * (search results, follow requests), follow button, Instagram-style
 * profile header. Shared with comdata/templates/comdata/feed.html and
 * sessions_list.html for the avatar/follow-btn classes (loaded there via
 * the same static file).
 */

.avatar {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    object-fit: cover;
    overflow: hidden;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.85rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.95rem; }
.avatar-lg { width: 112px; height: 112px; font-size: 2.3rem; }

.avatar-color-0 { background: #667eea; }
.avatar-color-1 { background: #e74c3c; }
.avatar-color-2 { background: #2ecc71; }
.avatar-color-3 { background: #ed8936; }
.avatar-color-4 { background: #764ba2; }
.avatar-color-5 { background: #16a085; }
.avatar-color-6 { background: #d35400; }
.avatar-color-7 { background: #2980b9; }

/* Person row - one result in search_users.html / one entry in follow_requests.html */
.person-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border-light);
    text-decoration: none;
    color: inherit;
}

.person-row:last-child {
    border-bottom: none;
}

a.person-row:hover {
    background: var(--color-bg-page);
}

.person-row-info {
    flex: 1;
    min-width: 0;
}

.person-row-name {
    font-weight: 600;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.person-row-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

.person-row-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

/* Follow button - pill, three visual states */
.follow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    min-height: var(--touch-target-min);
    white-space: nowrap;
}

.follow-btn--follow {
    background: var(--gradient-accent);
    color: white;
}

.follow-btn--following {
    background: var(--color-secondary-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.follow-btn--pending {
    background: var(--color-secondary-bg);
    color: var(--color-text-muted);
    cursor: default;
}

/* Profile header - Instagram-style (accounts/profile.html). Toujours en
   ligne (nom/équipe/numéro à côté de la photo), y compris sur mobile - pas
   de flex-wrap ni de flex-direction:column ici. */
.profile-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

/* Wrapper autour de l'avatar (own profile) pour ancrer le bouton crayon
   "modifier la photo" en haut à droite. */
.profile-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar-edit-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    font-size: 0.9rem;
}

.profile-header-info {
    flex: 1;
    min-width: 0;
}

.profile-header-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 0.25rem 0;
    text-align: center;
}

.profile-stats-row {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin: var(--space-md) 0;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
}

.profile-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Sous 480px, resserrer l'en-tête pour qu'il tienne dans la largeur sans
   jamais casser la mise en ligne avatar+nom (voir .profile-header ci-dessus,
   toujours en row) - seule .profile-stats-row a un filet de sécurité
   (flex-wrap) si les 3 chiffres ne tiennent vraiment pas. */
@media (max-width: 480px) {
    .profile-header {
        gap: var(--space-md);
    }

    .profile-header .avatar-lg {
        width: 72px;
        height: 72px;
        font-size: 1.5rem;
    }

    .profile-stats-row {
        gap: var(--space-sm);
        flex-wrap: wrap;
    }
}

/*
 * Header block wrapper (accounts/profile.html) - deliberately NOT
 * .profile-card (no background/shadow): a plain bottom border is enough to
 * separate it from the session feed below, which itself sits directly on
 * the page background exactly like the home feed (comdata/feed.html).
 */
.profile-header-block {
    padding-bottom: var(--space-lg);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-border-light);
}

.profile-km-line {
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: var(--space-md) 0 0 0;
}

/* Véhicule/Logger/Réglages (own profile) / Suivre (other account) - a
   centered action row below the header, see profile-header-block above. */
#profile-action {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

/* btn.css force .btn/.btn-sm à width:100% sous 768px (pensé pour les boutons
   seuls ou les .btn-group, qui eux s'empilent volontairement en colonne sur
   mobile) - on l'annule ici pour que les 3 boutons du profil restent en
   ligne y compris sur mobile, en se partageant la largeur disponible. */
#profile-action .btn {
    width: auto;
    flex: 1 1 0;
    min-width: 0;
}

/*
 * Settings menu (accounts/settings.html) - a Strava/Instagram-style list of
 * access rows (icon + label + chevron) replacing a plain row of buttons for
 * Notes/Véhicules/Demandes de suivi/Mot de passe/Confidentialité.
 */
.settings-menu {
    display: flex;
    flex-direction: column;
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-xs);
    border-bottom: 1px solid var(--color-border-light);
    text-decoration: none;
    color: var(--color-text);
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    min-height: var(--touch-target-min);
}

.settings-menu-item:last-child {
    border-bottom: none;
}

.settings-menu-item:hover {
    background: var(--color-bg-page);
}

.settings-menu-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 1.5em;
    text-align: center;
}

.settings-menu-label {
    flex: 1;
    font-weight: 600;
}

.settings-menu-chevron {
    color: var(--color-text-muted);
    font-size: 1.3rem;
    flex-shrink: 0;
}
