/* Killian authentication alignment and self-service profile UI. */

/*
 * Auth cards and Django messages are siblings in <main>. The base stylesheet
 * centers the card with flexbox; force a vertical stack so messages do not
 * push the card sideways after password reset or other auth redirects.
 */
body:has(.auth-card) main{
    flex-direction:column;
    align-items:center;
    justify-content:center;
}

body:has(.auth-card) main > .msg{
    width:min(100%,480px);
    max-width:480px;
    flex:0 0 auto;
}

body:has(.auth-card.wide) main > .msg{
    width:min(100%,620px);
    max-width:620px;
}

body:has(.auth-card) .auth-card{
    flex:0 0 auto;
}

.user-profile-chip{
    min-height:36px;
    display:inline-flex!important;
    align-items:center;
    gap:8px;
    padding:4px 10px 4px 5px;
    border:1px solid var(--line);
    border-radius:999px;
    color:var(--text);
    text-decoration:none;
    background:var(--panel);
}

.user-profile-chip:hover,
.user-profile-chip.active{
    border-color:var(--accent);
    background:var(--panel2);
}

.user-profile-chip-avatar{
    width:26px;
    height:26px;
    border-radius:50%;
    object-fit:cover;
    display:block;
}

.user-profile-chip-initial{
    display:grid;
    place-items:center;
    background:var(--panel2);
    color:var(--accent);
    font-weight:800;
    font-size:12px;
}

.user-profile-chip-label{
    line-height:1;
    font-weight:700;
}

.profile-page{
    width:min(100%,980px);
    margin:0 auto;
}

.profile-page-head{
    width:100%;
}

.profile-layout{
    display:grid;
    grid-template-columns:minmax(220px,280px) minmax(0,1fr);
    gap:20px;
    align-items:start;
}

.profile-summary-card{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:18px;
    text-align:center;
}

.profile-avatar{
    width:132px;
    height:132px;
    border-radius:50%;
    object-fit:cover;
    border:1px solid var(--line);
    background:var(--panel2);
}

.profile-avatar-placeholder{
    display:grid;
    place-items:center;
    color:var(--accent);
    font-size:52px;
    font-weight:800;
}

.profile-summary-copy{
    width:100%;
    display:flex;
    flex-direction:column;
    gap:5px;
    overflow-wrap:anywhere;
}

.profile-summary-copy strong{
    font-size:18px;
}

.profile-summary-copy span{
    color:var(--muted);
}

.profile-summary-actions{
    width:100%;
    display:grid;
    gap:10px;
}

.profile-security-link{
    width:100%;
}

.profile-content-stack{
    display:grid;
    gap:20px;
    min-width:0;
}

.profile-form-card{
    width:100%;
}

.profile-form-section + .profile-form-section{
    margin-top:26px;
    padding-top:24px;
    border-top:1px solid var(--line);
}

.profile-form-section h2{
    margin:0 0 16px;
    font-size:18px;
}

.profile-name-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
}

.profile-form-card .form-field{
    margin-bottom:16px;
}

.profile-form-card input[type="file"]{
    width:100%;
}

.profile-remove-avatar{
    display:flex;
    align-items:center;
    gap:9px;
    margin-top:8px;
}

.profile-remove-avatar input{
    width:auto;
}

.profile-password-dialog{
    width:min(520px,calc(100vw - 32px));
    max-width:520px;
    max-height:calc(100vh - 32px);
    padding:0;
    border:1px solid var(--line);
    border-radius:14px;
    background:var(--panel);
    color:var(--text);
    box-shadow:0 24px 70px rgba(0,0,0,.45);
    overflow:auto;
}

.profile-password-dialog::backdrop{
    background:color-mix(in srgb,var(--sh-0,rgb(3,8,18)) 72.0%,transparent);
    backdrop-filter:blur(2px);
}

.profile-password-dialog-card{
    margin:0;
    padding:24px;
}

.profile-password-dialog-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:18px;
    margin-bottom:20px;
}

.profile-password-dialog-head h2{
    margin:0 0 6px;
    font-size:22px;
}

.profile-password-dialog-head p{
    margin:0;
    color:var(--muted);
}

.profile-password-dialog-close{
    width:34px;
    min-width:34px;
    height:34px;
    padding:0;
    border:1px solid var(--line);
    border-radius:8px;
    background:var(--panel2);
    color:var(--muted);
    font-size:24px;
    line-height:1;
    cursor:pointer;
}

.profile-password-dialog-close:hover,
.profile-password-dialog-close:focus-visible{
    color:var(--text);
    border-color:var(--accent);
}

.profile-password-dialog-fields .form-field{
    margin-bottom:16px;
}

.profile-password-dialog .helptext ul{
    margin:8px 0 0 20px;
    padding:0;
}

.profile-password-actions{
    align-items:center;
    flex-wrap:wrap;
}

@media (max-width:760px){
    body:has(.auth-card) main{
        align-items:center;
        justify-content:center;
        padding:20px 14px;
    }

    body:has(.auth-card) .auth-card{
        margin-top:0;
    }

    .user-profile-chip{
        width:36px;
        min-width:36px;
        height:36px;
        padding:4px;
        justify-content:center;
    }

    .user-profile-chip-label{
        display:none;
    }

    .profile-layout{
        grid-template-columns:1fr;
    }

    .profile-summary-card{
        width:100%;
    }

    .profile-name-grid{
        grid-template-columns:1fr;
        gap:0;
    }

    .profile-password-dialog{
        width:calc(100vw - 24px);
        max-height:calc(100vh - 24px);
    }

    .profile-password-dialog-card{
        padding:20px;
    }

    .profile-password-actions{
        display:grid;
        grid-template-columns:1fr;
    }

    .profile-password-actions > *{
        width:100%;
    }
}
