/* Staged profile photo upload widget */

.profile-photo-upload .current-photo {
    position: relative;
}

.profile-photo-upload.is-uploading .current-photo::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.65);
    pointer-events: none;
}

.profile-photo-upload.is-uploading .current-photo::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 3px solid rgba(76, 175, 80, 0.25);
    border-top-color: var(--accent-color, #4caf50);
    border-radius: 50%;
    animation: profile-photo-upload-spin 0.75s linear infinite;
    z-index: 1;
}

.profile-photo-upload--dashboard.is-uploading .current-photo::after,
.profile-photo-upload--dashboard.is-uploading .current-photo::before {
    display: none;
}

.profile-photo-upload__preview-signature {
    max-height: 120px;
    max-width: 100%;
    object-fit: contain;
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 8px;
    padding: 0.5rem;
    background: #fff;
}

.profile-photo-upload .btn-upload.disabled,
.profile-photo-upload .btn-upload[aria-disabled='true'] {
    opacity: 0.65;
    pointer-events: none;
    transform: none;
}

.profile-photo-upload-form-busy button[type='submit'],
.profile-photo-upload-form-busy input[type='submit'] {
    cursor: wait;
}

.profile-photo-upload__error[hidden] {
    display: none !important;
}

@keyframes profile-photo-upload-spin {
    to {
        transform: rotate(360deg);
    }
}

/* —— Dashboard card layout (add/edit staff & student) —— */

.profile-photo-upload--dashboard {
    display: block;
    width: 100%;
}

.profile-photo-upload--dashboard .profile-photo-upload__card {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.5rem 2rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    background: var(--bg-secondary, #f8faf9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.light-theme .profile-photo-upload--dashboard .profile-photo-upload__card {
    background: #f8faf9;
}

.profile-photo-upload--dashboard.is-dragover .profile-photo-upload__card {
    border-color: var(--accent-color, #4caf50);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.profile-photo-upload--dashboard.is-ready .profile-photo-upload__card {
    border-color: rgba(76, 175, 80, 0.45);
}

.profile-photo-upload__preview-col {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 8.5rem;
}

.profile-photo-upload__preview-frame {
    position: relative;
    flex-shrink: 0;
}

.profile-photo-upload__avatar,
.profile-photo-upload--dashboard .preview-avatar {
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.1);
    display: block;
    transition: opacity 0.2s ease;
}

.profile-photo-upload__placeholder,
.profile-photo-upload--dashboard .preview-avatar-placeholder {
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    border: 2px dashed var(--border-color, #cbd5e1);
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 2.25rem;
    color: var(--text-secondary, #94a3b8);
    margin: 0;
}

.profile-photo-upload__placeholder-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-secondary, #94a3b8);
}

.profile-photo-upload__preview-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.profile-photo-upload__preview-overlay[hidden] {
    display: none !important;
}

.profile-photo-upload__spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(76, 175, 80, 0.2);
    border-top-color: var(--accent-color, #4caf50);
    border-radius: 50%;
    animation: profile-photo-upload-spin 0.7s linear infinite;
}

.profile-photo-upload__status {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    min-height: 1.125rem;
    color: var(--text-secondary, #64748b);
    max-width: 8.5rem;
}

.profile-photo-upload--dashboard.is-uploading .profile-photo-upload__status {
    color: var(--accent-color, #4caf50);
}

.profile-photo-upload--dashboard.is-ready .profile-photo-upload__status {
    color: #15803d;
}

.profile-photo-upload__actions-col {
    flex: 1 1 14rem;
    min-width: 0;
    gap: 0.65rem !important;
}

.profile-photo-upload__title {
    margin: 0 0 0.15rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.profile-photo-upload__extra {
    margin-bottom: 0.25rem;
}

.profile-photo-upload__extra .text-muted {
    margin-bottom: 0 !important;
    line-height: 1.45;
}

.profile-photo-upload__btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.profile-photo-upload__btn-primary {
    margin: 0;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.profile-photo-upload__btn-primary:focus-visible {
    outline: 2px solid var(--accent-color, #4caf50);
    outline-offset: 2px;
}

.profile-photo-upload__btn-remove {
    margin: 0;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
}

.profile-photo-upload__btn-remove:focus-visible {
    outline: 2px solid #dc3545;
    outline-offset: 2px;
}

.profile-photo-upload__btn-remove:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.profile-photo-upload__hint {
    margin: 0.15rem 0 0 !important;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-secondary, #64748b);
}

.profile-photo-upload__formats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.profile-photo-upload__format-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-secondary, #64748b);
    background: #fff;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 999px;
}

.profile-photo-upload--dashboard .profile-photo-upload__error {
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

.profile-photo-upload--dashboard .profile-photo-upload__error[hidden] {
    display: none !important;
}

.profile-photo-upload--dashboard .selected-file-name {
    display: none !important;
}

.profile-photo-upload .file-input-hidden + .selected-file-name {
    display: none !important;
}

@media (max-width: 576px) {
    .profile-photo-upload.is-uploading .current-photo::before {
        width: 1.75rem;
        height: 1.75rem;
        margin: -0.875rem 0 0 -0.875rem;
    }

    .profile-photo-upload--dashboard .profile-photo-upload__card {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }

    .profile-photo-upload__preview-col {
        align-items: center;
        width: 100%;
    }

    .profile-photo-upload__btn-row {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-photo-upload__btn-row .btn-upload,
    .profile-photo-upload__btn-row .btn-remove {
        width: 100%;
        justify-content: center;
    }
}
