/* === Avatar Crop Overlay === */
.avatar-crop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.avatar-crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
}

/* Rounded-square guide overlay — uses box-shadow trick for the cutout */
.avatar-crop-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 30px)); /* match canvas cy offset */
    width: min(75vw, 75vh);
    height: min(75vw, 75vh);
    border-radius: 20%;
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    z-index: 1;
}

/* Action buttons at bottom */
.avatar-crop-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 2;
}

.avatar-crop-btn {
    padding: 10px 28px;
    border: none;
    border-radius: 24px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    min-width: 100px;
    transition: background 0.2s;
}

.avatar-crop-btn-cancel {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.avatar-crop-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.25);
}

.avatar-crop-btn-done {
    background: #1976D2;
    color: white;
}

.avatar-crop-btn-done:hover {
    background: #1565C0;
}

/* === Avatar Upload Badge (camera icon) === */
.avatar-upload-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    z-index: 1;
}

.avatar-upload-badge .mud-icon-root {
    font-size: 16px;
    color: #424242;
}

/* === Avatar Rounded Square (Discord-style) === */
.avatar-rounded-square {
    border-radius: 20% !important;
}

.avatar-rounded-square img,
.avatar-rounded-square .mud-image {
    border-radius: 20%;
}

.avatar-rounded-square.mud-avatar {
    overflow: hidden;
}

/* === Avatar Upload Trigger (tappable wrapper) === */
.avatar-upload-trigger {
    position: relative;
    cursor: pointer;
    display: inline-block;
    -webkit-tap-highlight-color: transparent;
}

.avatar-upload-trigger:active {
    opacity: 0.8;
}

/* === Source Dialog (bottom sheet style) === */
.avatar-source-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1300;
}

.avatar-source-dialog {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mud-palette-surface);
    border-radius: 16px 16px 0 0;
    z-index: 1301;
    padding: 8px 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
    animation: avatar-source-slide-up 0.25s ease-out;
}

@keyframes avatar-source-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.avatar-source-dialog .avatar-source-handle {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: var(--mud-palette-lines-default);
    margin: 4px auto 12px;
}

.avatar-source-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-size: 1rem;
    color: var(--mud-palette-text-primary);
    min-height: 48px;
    transition: background 0.15s;
}

.avatar-source-option:hover {
    background: var(--mud-palette-action-default-hover);
}

.avatar-source-option:active {
    background: var(--mud-palette-action-default-hover);
}

.avatar-source-option .mud-icon-root {
    font-size: 24px;
    color: var(--mud-palette-primary);
    flex-shrink: 0;
}

.avatar-source-cancel {
    text-align: center;
    padding: 12px 20px;
    border-top: 1px solid var(--mud-palette-lines-default);
    margin-top: 4px;
}

/* === URL Input Row === */
.avatar-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px 12px;
}

.avatar-url-row .mud-input-control {
    flex: 1;
}
