/* =============================================================
   Common Image Cropper — circular avatar upload with pan/zoom crop
   Reusable across pages. Markup contract:
   <div class="ic-avatar" data-image-cropper>
     <svg class="ic-avatar__plus">…</svg>
     <img class="ic-avatar__img" alt="">
     <div class="ic-avatar__cam">…camera…</div>
     <div class="ic-avatar__remove">…x…</div>
   </div>
   ============================================================= */

.ic-avatar {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px dashed #007aff;
    display: grid;
    place-items: center;
    cursor: pointer;
    background: #f8fbff;
    overflow: visible;
    transition: border-color .2s ease;
}
.ic-avatar:hover { border-color: #0056d6; }
.ic-avatar.has-image { border-style: solid; border-color: #e2e8f0; background: #fff; }

.ic-avatar__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: none;
}
.ic-avatar.has-image .ic-avatar__img { display: block; }
.ic-avatar.has-image .ic-avatar__plus { display: none; }
.ic-avatar__plus { color: #007aff; opacity: .55; }

.ic-avatar__cam {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 32px;
    height: 32px;
    background: #007aff;
    border-radius: 50%;
    display: grid;
    place-items: center;
    box-shadow: 0 3px 10px rgba(0, 122, 255, .45);
    border: 3px solid #fff;
    z-index: 2;
}
.ic-avatar__remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 26px;
    height: 26px;
    background: #ef4444;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 50%;
    display: none;
    place-items: center;
    cursor: pointer;
    z-index: 3;
    box-shadow: 0 3px 10px rgba(239, 68, 68, .4);
    transition: transform .15s ease;
}
.ic-avatar__remove:hover { transform: scale(1.12); }
.ic-avatar.has-image .ic-avatar__remove { display: grid; }

/* ===== Crop modal ===== */
.ic-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(3px);
}
.ic-modal.open { display: flex; }
.ic-box {
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    padding: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
    animation: ic-pop .3s cubic-bezier(.16, 1, .3, 1);
}
@keyframes ic-pop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.ic-box__title { font-size: 17px; font-weight: 800; margin: 0 0 4px; color: #0f172a; }
.ic-box__sub { font-size: 13px; color: #64748b; margin: 0 0 18px; }

.ic-stage {
    position: relative;
    width: 280px;
    height: 280px;
    max-width: 100%;
    margin: 0 auto;
    border-radius: 14px;
    overflow: hidden;
    background: #0b1220;
    touch-action: none;
    cursor: grab;
    user-select: none;
}
.ic-stage.dragging { cursor: grabbing; }
.ic-stage__img {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none;
    user-select: none;
    /* base.css sets `img{max-width:100%;height:auto}` which would cap the crop
       image to the stage width and break the pan/zoom math — opt out here. */
    max-width: none;
    height: auto;
}
.ic-stage__mask {
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: 0 0 0 2000px rgba(11, 18, 32, .55);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .9);
}

.ic-zoom { display: flex; align-items: center; gap: 12px; margin: 18px 2px 4px; }
.ic-zoom svg { color: #94a3b8; flex: 0 0 auto; }
.ic-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    border-radius: 5px;
    background: #e2e8f0;
    outline: none;
}
.ic-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007aff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 122, 255, .5);
}
.ic-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: #007aff;
    cursor: pointer;
}

.ic-actions { display: flex; gap: 12px; margin-top: 20px; }
.ic-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s ease;
}
.ic-btn--ghost { background: #f1f5f9; color: #475569; }
.ic-btn--ghost:hover { background: #e2e8f0; }
.ic-btn--primary { background: #007aff; color: #fff; box-shadow: 0 6px 16px rgba(0, 122, 255, .35); }
.ic-btn--primary:hover { background: #0056d6; }

/* ===== dark theme ===== */
[data-theme="dark"] .ic-box { background: #111a2e; }
[data-theme="dark"] .ic-box__title { color: #f8fafc; }
[data-theme="dark"] .ic-btn--ghost { background: #1e293b; color: #cbd5e1; }
[data-theme="dark"] .ic-avatar.has-image { background: #0f172a; border-color: #334155; }

/* ===== responsive (R6) ===== */
@media (max-width: 420px) {
    .ic-stage { width: 240px; height: 240px; }
}
