/* ==========================================================================
   AvatarEditor — LinkedIn-style cropper modal
   ========================================================================== */

.avatar-editor-open {
    overflow: hidden;
}

.avatar-editor-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    transition: background 0.18s ease;
}

.avatar-editor-backdrop.is-visible {
    background: rgba(0, 0, 0, 0.55);
}

.avatar-editor-modal {
    background: #fff;
    border-radius: 0;
    width: 100%;
    max-width: 880px;
    max-height: calc(100vh - 2.5rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    transform: translateY(10px) scale(0.98);
    opacity: 0;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.avatar-editor-backdrop.is-visible .avatar-editor-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Header ---------------------------------------------------------------- */
.avatar-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e8e8e8);
}

.avatar-editor-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary, #111);
}

.avatar-editor-close {
    background: transparent;
    border: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--text-secondary, #525252);
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 1rem;
}

.avatar-editor-close:hover {
    background: var(--bg-muted, #f0f0f0);
}

/* Body ------------------------------------------------------------------ */
.avatar-editor-body {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 1.25rem;
    padding: 1.25rem;
    overflow: auto;
    background: var(--bg-light, #fafafa);
}

@media (max-width: 720px) {
    .avatar-editor-body {
        grid-template-columns: 1fr;
    }
}

/* Stage / cropper area -------------------------------------------------- */
.avatar-editor-stage {
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    min-height: 320px;
    aspect-ratio: 1 / 1;
    max-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-editor-stage-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The stage background div is a structural placeholder. Cropper.js paints
   over the stage with its own canvas + dim mask, so we don't render the
   chosen background colour here — the live Preview circle in the sidebar
   shows exactly what the saved image will look like. */
.avatar-editor-stage-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: transparent;
}

.avatar-editor-image {
    display: block;
    max-width: 100%;
}

/* Cropper.js overrides — circular / square crop window mask */
.avatar-editor-stage .cropper-view-box,
.avatar-editor-stage .cropper-face {
    outline: 0;
    border-radius: 0;
}

.avatar-editor-stage .cropper-view-box {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
    outline: 0;
}

.avatar-editor-stage .cropper-modal {
    background-color: rgba(15, 15, 15, 0.65);
}

/* Round crop window when shape == circle */
.avatar-editor-stage.is-circle .cropper-view-box,
.avatar-editor-stage.is-circle .cropper-face {
    border-radius: 50%;
}

.avatar-editor-stage.is-square .cropper-view-box,
.avatar-editor-stage.is-square .cropper-face {
    border-radius: 4px;
}

/* Sidebar --------------------------------------------------------------- */
.avatar-editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.25rem 0;
}

.avatar-editor-section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--text-secondary, #525252);
    margin-bottom: 0.25rem;
}

/* Preview --------------------------------------------------------------- */
.avatar-editor-preview {
    width: 140px;
    height: 140px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color, #e8e8e8);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.avatar-editor-preview.is-circle {
    border-radius: 50%;
}

.avatar-editor-preview.is-square {
    border-radius: 6px;
}

.avatar-editor-preview-bg,
.avatar-editor-preview-inner {
    position: absolute;
    inset: 0;
}

.avatar-editor-preview-bg {
    background: #fff;
    transition: background 0.12s ease;
}

.avatar-editor-preview-bg.is-transparent {
    background-image:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 14px 14px;
    background-position: 0 0, 0 7px, 7px -7px, -7px 0;
    background-color: #fff;
}

.avatar-editor-preview-inner {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Zoom + rotate controls ----------------------------------------------- */
.avatar-editor-zoom-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.avatar-editor-rotate-row {
    display: flex;
    gap: 0.5rem;
}

.avatar-editor-iconbtn {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color, #e8e8e8);
    background: #fff;
    color: var(--text-primary, #111);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, border-color 0.12s ease;
    font-size: 0.875rem;
}

.avatar-editor-iconbtn:hover {
    background: var(--bg-muted, #f0f0f0);
    border-color: var(--border-color-dark, #ddd);
}

.avatar-editor-zoom-slider {
    flex: 1 1 auto;
    appearance: none;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 4px;
    background: var(--color-gray-300, #e0e0e0);
    outline: none;
    cursor: pointer;
}

.avatar-editor-zoom-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-black, #111);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.avatar-editor-zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-black, #111);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Background swatches -------------------------------------------------- */
.avatar-editor-bg-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.avatar-editor-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color, #e8e8e8);
    cursor: pointer;
    padding: 0;
    background: #fff;
    position: relative;
    transition: transform 0.1s ease, box-shadow 0.12s ease;
}

.avatar-editor-swatch:hover {
    transform: scale(1.05);
}

.avatar-editor-swatch.is-active {
    box-shadow: 0 0 0 2px var(--color-black, #111);
    border-color: #fff;
}

.avatar-editor-swatch.is-transparent {
    background-image:
        linear-gradient(45deg, #ddd 25%, transparent 25%),
        linear-gradient(-45deg, #ddd 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ddd 75%),
        linear-gradient(-45deg, transparent 75%, #ddd 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
    background-color: #fff;
}

.avatar-editor-swatch-custom {
    overflow: hidden;
    background: conic-gradient(from 0deg, #ff5e5b, #f7c948, #00b894, #0984e3, #6c5ce7, #d63031, #ff5e5b);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.avatar-editor-color-input {
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: 0;
    padding: 0;
    background: transparent;
}

/* Footer --------------------------------------------------------------- */
.avatar-editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-color, #e8e8e8);
    background: #fff;
}

.avatar-editor-cancel,
.avatar-editor-save {
    min-width: 96px;
}
