/**
 * Avatar Crop Field — framework-agnostic styles
 * @version 7.12.0
 */

/* ============================================================
   FIELD WRAPPER & DROPZONE
   ============================================================ */
.avatarcrop-wrapper {
    margin: 15px 0;
    max-width: 600px;
    box-sizing: border-box;
}
.avatarcrop-wrapper *,
.avatarcrop-modal *,
.avatarcrop-modal *::before,
.avatarcrop-modal *::after {
    box-sizing: border-box;
}

.avatarcrop-dropzone {
    border: 3px dashed #d3d3d3;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    position: relative;
}
.avatarcrop-dropzone:hover {
    border-color: #1e87f0;
    background: linear-gradient(135deg, #e7f4ff 0%, #f0f8ff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 135, 240, 0.15);
}
.avatarcrop-dropzone.dragover {
    border-color: #1e87f0;
    background: linear-gradient(135deg, #d4ebff 0%, #e7f4ff 100%);
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(30, 135, 240, 0.25);
}

/* Preview area */
.avatarcrop-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 240px;
    padding: 20px;
}
.avatarcrop-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    border: 4px solid #e5e5e5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
    display: block;
}
.avatarcrop-image-circle {
    width: 200px;
    height: 200px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
}
.avatarcrop-image:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    transform: scale(1.05);
    border-color: #1e87f0;
}

/* Placeholder */
.avatarcrop-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
}
.avatarcrop-placeholder-icon {
    width: 70px;
    height: 70px;
    color: #999;
    margin-bottom: 10px;
}
.avatarcrop-placeholder-title {
    font-size: 18px;
    font-weight: 500;
    margin: 15px 0 8px 0;
    color: #333;
}
.avatarcrop-placeholder-text {
    font-size: 14px;
    color: #666;
    margin: 0 0 5px 0;
}
.avatarcrop-placeholder-meta {
    font-size: 12px;
    color: #999;
    margin: 0;
}

/* ============================================================
   ACTION BUTTONS (native, framework-free)
   ============================================================ */
.avatarcrop-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}
.avatarcrop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}
.avatarcrop-btn-sm {
    padding: 7px 14px;
    font-size: 13px;
}
.avatarcrop-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.avatarcrop-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.avatarcrop-btn-default {
    background: #fff;
    color: #333;
    border-color: #d3d3d3;
}
.avatarcrop-btn-default:hover {
    background: #f5f5f5;
    border-color: #b3b3b3;
}
.avatarcrop-btn-primary {
    background: #1e87f0;
    color: #fff;
    border-color: #1e87f0;
}
.avatarcrop-btn-primary:hover {
    background: #0e72c8;
    border-color: #0e72c8;
    color: #fff;
}
.avatarcrop-btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}
.avatarcrop-btn-danger:hover {
    background: #b52a37;
    border-color: #b52a37;
    color: #fff;
}

/* ============================================================
   NATIVE MODAL (used in admin and on frontend when framework=native)
   ============================================================ */
.avatarcrop-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    animation: avatarcrop-fade-in 0.2s ease;
}
.avatarcrop-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100001;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 30px 15px;
    overflow-y: auto;
    animation: avatarcrop-fade-in 0.2s ease;
}
@keyframes avatarcrop-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Skip native dialog styles when uk-modal is also present (UIkit takes over) */
.avatarcrop-modal.uk-modal .avatarcrop-modal-dialog,
.avatarcrop-modal.uk-modal {
    /* Let UIkit handle layout */
}

.avatarcrop-modal .avatarcrop-modal-dialog {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 800px;
    margin: auto;
    padding: 25px 30px;
    position: relative;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.avatarcrop-modal-x {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    border-radius: 4px;
    transition: all 0.15s;
}
.avatarcrop-modal-x:hover {
    background: #f0f0f0;
    color: #000;
}

.avatarcrop-modal-title {
    margin: 0 0 20px 0;
    padding-right: 30px;
    font-size: 20px;
    font-weight: 600;
    color: #222;
}

.avatarcrop-modal-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.avatarcrop-modal-cropbox {
    flex: 1 1 60%;
    min-width: 280px;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px;
}
.avatarcrop-modal-cropbox img {
    display: block;
    max-width: 100%;
    height: auto;
}

.avatarcrop-modal-side {
    flex: 1 1 30%;
    min-width: 200px;
    text-align: center;
}
.avatarcrop-modal-side-label {
    font-size: 13px;
    color: #777;
    margin: 0 0 10px 0;
}
.avatarcrop-modal-side-meta {
    font-size: 12px;
    color: #999;
    margin: 10px 0 0 0;
}

.avatarcrop-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
}

@media (max-width: 600px) {
    .avatarcrop-modal {
        padding: 10px;
    }
    .avatarcrop-modal .avatarcrop-modal-dialog {
        padding: 20px 15px;
    }
    .avatarcrop-modal-body {
        flex-direction: column;
    }
    .avatarcrop-modal-cropbox,
    .avatarcrop-modal-side {
        flex-basis: 100%;
        width: 100%;
    }
}

/* ============================================================
   PREVIEW BOXES (used inside modal, both frameworks)
   ============================================================ */
.avatarcrop-preview-circle,
.avatarcrop-preview-square {
    overflow: hidden;
    border: 2px solid #ddd;
    background-color: #f9f9f9;
    margin: 0 auto;
}
.avatarcrop-preview-circle { border-radius: 50%; }
.avatarcrop-preview-square { border-radius: 4px; }

/* ============================================================
   CROPPER.JS — circular mask only when explicitly enabled
   ============================================================ */
body.avatarcrop-cropper-circle .cropper-view-box,
body.avatarcrop-cropper-circle .cropper-face {
    border-radius: 50%;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .avatarcrop-image {
        max-width: 200px;
        max-height: 200px;
    }
    .avatarcrop-image-circle {
        width: 150px;
        height: 150px;
    }
}

/* ---------- Profile-card mode ---------- */

.avatarcrop-card {
    display: inline-block;
    line-height: 0;
}

.avatarcrop-card-inner {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    background: #f0f2f5;
    border: 2px solid #e5e7eb;
    transition: border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}

.avatarcrop-card-inner:hover {
    border-color: #4a90e2;
    box-shadow: 0 2px 12px rgba(74, 144, 226, 0.25);
}

.avatarcrop-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatarcrop-card-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.avatarcrop-card-empty svg {
    width: 42px;
    height: 42px;
}

.avatarcrop-card-inner:hover .avatarcrop-card-empty {
    color: #4a90e2;
}

.avatarcrop-card-hover {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.avatarcrop-card-inner:hover .avatarcrop-card-hover {
    opacity: 1;
}

.avatarcrop-card-edit-icon svg {
    width: 32px;
    height: 32px;
}

.avatarcrop-card-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.9);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s, transform 0.15s;
    z-index: 2;
}

.avatarcrop-card-inner:hover .avatarcrop-card-remove {
    opacity: 1;
}

.avatarcrop-card-remove:hover {
    transform: scale(1.1);
    background: rgb(220, 38, 38);
}
