/* Edit profile — aligned with profile details (pd-*) */
.page-profile-edit {
    --pe-sidebar-width: 220px;
}

.pe-edit {
    max-width: 1100px;
    margin: 0 auto;
    padding-bottom: 5rem;
}

.pe-edit__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.pe-edit__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid #e4e0ec;
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: 0 1px 3px rgba(31, 21, 51, 0.06);
    min-height: 96px;
}

.pe-edit__header-photo {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid #e4e0ec;
    background: #f3f0f8;
}

.pe-edit__header-photo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pe-edit__header-body {
    flex: 1;
    min-width: 0;
}

.pe-edit__header-title {
    margin: 0 0 0.15rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
}

.pe-edit__header-meta {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.pe-edit__completion {
    flex-shrink: 0;
    text-align: right;
    min-width: 100px;
}

.pe-edit__completion strong {
    display: block;
    font-size: 1.1rem;
    color: var(--primary);
}

.pe-edit__completion span {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.pe-progress-bar {
    height: 6px;
    background: #ede9f5;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.35rem;
}

.pe-progress-bar__fill {
    height: 100%;
    background: var(--gradient-rose);
    border-radius: 999px;
    transition: width 0.35s ease;
}

.pe-layout {
    display: grid;
    grid-template-columns: var(--pe-sidebar-width) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.pe-sidebar {
    position: sticky;
    top: calc(var(--nav-height, 64px) + 0.75rem);
    background: var(--white);
    border: 1px solid #e4e0ec;
    border-radius: var(--radius-md);
    padding: 0.65rem;
    box-shadow: 0 1px 3px rgba(31, 21, 51, 0.05);
}

.pe-step-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pe-step-nav__item,
.step-item.pe-step-nav__item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex: none;
    flex-direction: row;
    position: relative;
    z-index: auto;
}

.pe-step-nav__item:hover {
    background: #f8f6fc;
}

.pe-step-nav__item.active,
.step-item.pe-step-nav__item.active {
    background: #f3ebff;
}

.pe-step-nav__item.completed .pe-step-nav__icon,
.step-item.completed .pe-step-nav__icon {
    background: var(--gradient-rose);
    color: #fff;
    border-color: transparent;
}

.pe-step-nav__icon,
.step-item .step-circle.pe-step-nav__icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 10px;
    border: 1px solid #e4e0ec;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--primary);
    background: #fff;
    transition: var(--transition);
}

.pe-step-nav__item.active .pe-step-nav__icon,
.step-item.active .pe-step-nav__icon {
    border-color: var(--rose);
    color: var(--rose);
    background: #fff;
}

.pe-step-nav__label,
.step-item .step-label.pe-step-nav__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0;
    max-width: none;
    text-align: left;
    line-height: 1.25;
}

.pe-step-nav__item.active .pe-step-nav__label,
.step-item.active .pe-step-nav__label {
    color: var(--primary-dark);
}

.pe-step-nav__item.completed .pe-step-nav__label {
    color: var(--text);
}

.step-item.completed .step-circle.pe-step-nav__icon::after {
    content: none;
}

.pe-mobile-progress {
    display: none;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--white);
    border: 1px solid #e4e0ec;
    border-radius: var(--radius-md);
}

.pe-mobile-progress__meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.4rem;
}

.pe-form.card-modern,
.onboarding-form-card.pe-form {
    border: 1px solid #e4e0ec;
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem 1rem;
    background: var(--white);
    box-shadow: 0 1px 3px rgba(31, 21, 51, 0.06);
    min-height: 360px;
    padding-bottom: calc(var(--bottom-nav-height, 64px) + 1.5rem);
}

.onboarding-step.pe-step.active,
.onboarding-step.active {
    display: block;
    padding-bottom: 1.25rem;
}

.pe-section__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1.1rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.pe-section__title i {
    color: var(--primary);
    width: 1.25rem;
    text-align: center;
}

.pe-section__hint {
    margin: -0.65rem 0 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.onboarding-step.pe-step,
.pe-step {
    display: none;
    animation: peFadeStep 0.3s ease;
}

@keyframes peFadeStep {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pe-form .form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.pe-form .form-control,
.pe-form .form-select {
    border-color: #e4e0ec;
    border-radius: 10px;
    font-size: 0.9rem;
}

.pe-form .form-control:focus,
.pe-form .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(123, 44, 191, 0.12);
}

.pe-about-textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.5;
}

/* Family — parent row: expired checkbox vertically centered with name fields */
.pe-parent-row > .row {
    align-items: center;
}

.pe-parent-expired-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    min-height: 100%;
    padding: 0 0.5rem;
}

.pe-parent-expired {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    min-height: 72px;
    padding-top: 1.75rem;
}

.pe-parent-expired .pe-parent-expired-input {
    width: 1.35rem;
    height: 1.35rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}

.pe-parent-expired .form-check-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.25;
    cursor: pointer;
    white-space: nowrap;
}

.pe-field-disabled,
.pe-field-disabled .form-control,
.pe-field-disabled .pf-dial-code {
    background-color: #f3f4f6;
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.85;
}

.pe-field-disabled.reg-yesno .reg-yesno__btn {
    pointer-events: none;
}

/* Family — parent row: expired checkbox + name + occupation on one line */
.pe-parent-row .pe-parent-late-col {
    flex: 0 0 auto;
    max-width: 100%;
    padding-left: 1rem;
}

.pe-parent-row .pe-parent-late {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding-left: 0;
    margin-right: 0;
    white-space: nowrap;
}

.pe-parent-row .pe-parent-late .form-check-input {
    margin-top: 0;
    flex-shrink: 0;
}

.pe-parent-row .pe-parent-late .form-check-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.2;
}

@media (max-width: 767.98px) {
    .pe-parent-row .pe-parent-late-col {
        width: 100%;
    }
}

.pe-form__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    padding-bottom: 0.5rem;
    border-top: 1px solid #e4e0ec;
    background: var(--white);
}

.pe-form__footer .btn {
    min-width: 120px;
}

.page-profile-edit .photo-visibility {
    border-color: #e4e0ec;
    border-radius: 10px;
    background: #faf9fc;
}

.page-profile-edit .photo-upload-grid {
    gap: 0.75rem;
}

.page-profile-edit .photo-upload-box {
    border-radius: 12px;
    border-color: #e4e0ec;
    min-height: 160px;
    position: relative;
    display: block;
    padding: 0;
}

.page-profile-edit .photo-upload-box.has-image {
    background: #111;
}

.page-profile-edit .photo-upload-box.has-image .pe-upload-placeholder {
    display: none !important;
}

.page-profile-edit .photo-upload-box .pe-upload-preview,
.page-profile-edit .photo-upload-box.has-image img,
.page-profile-edit .photo-upload-box.has-image img.preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
    border-radius: inherit;
}

.page-profile-edit .photo-upload-box .pe-upload-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 0;
    pointer-events: none;
}

.page-profile-edit .photo-upload-box .upload-progress {
    z-index: 2;
}

.pe-photo-slot__label {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--primary-dark);
    line-height: 1.2;
}

.page-profile-edit .photo-upload-box.main-photo .pe-photo-slot__label {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
}

.page-profile-edit .photo-upload-box .pe-photo-remove-btn,
.page-profile-edit .photo-upload-box .remove-photo {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    width: auto;
    height: auto;
    top: auto;
    right: auto;
}

.page-profile-edit .photo-upload-box.has-image .pe-photo-remove-btn,
.page-profile-edit .photo-upload-box.has-image .remove-photo,
.page-profile-edit .photo-upload-box.has-saved-photo .pe-photo-remove-btn {
    display: inline-flex;
}

.page-profile-edit .photo-upload-box .pe-photo-remove-btn:hover {
    background: rgba(185, 28, 28, 0.9);
}

.page-profile-edit .photo-upload-box.main-photo::before {
    display: none;
}

.page-profile-edit .photo-upload-box.is-load-failed .pe-upload-placeholder {
    display: flex !important;
}

.page-profile-edit .photo-upload-box.is-load-failed::after {
    content: 'Image unavailable';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2;
    pointer-events: none;
}

.page-profile-edit .select2-container--bootstrap-5 {
    width: 100% !important;
}

.page-profile-edit .pf-dial-code {
    max-width: 4.75rem;
    flex: 0 0 4.75rem;
    padding-left: 0.35rem;
    padding-right: 1.35rem;
    font-size: 0.85rem;
}

.page-profile-edit .pf-phone-group .pf-phone-input,
.page-profile-edit .pf-phone-group > .form-control:not(.pf-dial-code) {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 991.98px) {
    .pe-layout {
        grid-template-columns: 1fr;
    }

    .pe-sidebar {
        display: none;
    }

    .pe-mobile-progress {
        display: block;
    }

    .pe-edit__header {
        flex-wrap: wrap;
    }

    .pe-edit__completion {
        width: 100%;
        text-align: left;
    }
}

@media (max-width: 575.98px) {
    .pe-form.card-modern,
    .onboarding-form-card.pe-form {
        padding: 1rem 0.85rem;
    }

    .pe-form__footer {
        flex-wrap: wrap;
    }

    .pe-form__footer .ms-auto {
        margin-left: 0 !important;
        width: 100%;
    }

    .pe-form__footer .ms-auto .btn {
        width: 100%;
    }
}
