/* ============================================================
   SadTik Media CSS – Professional Square Grid
   Modern UI / Clean / Responsive
   با فونت Estedad و Font Awesome 7.2.0
============================================================ */

:root {
    --m-size: 110px;
    --m-radius: 16px;
    --m-primary: #3b82f6;
    --m-danger: #ef4444;
    --m-bg: #f8fafc;
    --m-border: #e2e8f0;
}

.sadtik-media-wrapper {
    background: #fff;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    border: 1px solid #f1f5f9;
    margin-bottom: 20px;
    font-family: 'Estedad', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Header --- */
.media-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}
.media-header .icon-box {
    width: 46px;
    height: 46px;
    background: #eff6ff;
    color: var(--m-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 5 Free', sans-serif;
    font-weight: 900;
}
.media-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #1e293b;
    font-family: 'Estedad', sans-serif;
}
.media-header p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #64748b;
    font-family: 'Estedad', sans-serif;
    font-weight: 400;
}

/* --- Grid System --- */
.media-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* wrapper برای آیتم‌های گالری */
.gallery-items-wrapper {
    display: contents;
}

/* --- Slots (Featured & Gallery Items) --- */
.media-slot {
    width: var(--m-size);
    height: var(--m-size);
    position: relative;
    flex-shrink: 0;
}

/* --- Upload Trigger (Dashed Box) --- */
.upload-trigger {
    width: 100%;
    height: 100%;
    cursor: pointer;
    border-radius: var(--m-radius);
    overflow: hidden;
    transition: all 0.2s ease;
}

.dashed-border {
    width: 100%;
    height: 100%;
    border: 2px dashed #cbd5e1;
    border-radius: var(--m-radius);
    background: var(--m-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    gap: 8px;
    transition: all 0.2s;
}

.upload-trigger:hover .dashed-border {
    border-color: var(--m-primary);
    background: #eff6ff;
    color: var(--m-primary);
}
.upload-trigger i {
    font-size: 24px;
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 5 Free', sans-serif;
    font-weight: 900;
}
.upload-trigger span {
    font-size: 11px;
    font-weight: 700;
    font-family: 'Estedad', sans-serif;
}

/* حالت غیرفعال دکمه آپلود گالری */
.uploader-slot.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

/* --- Preview Card (Image) --- */
.image-preview-card {
    width: 100%;
    height: 100%;
    border-radius: var(--m-radius);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--m-border);
    background: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

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

/* --- Circle Remove Button --- */
.circle-remove-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 26px;
    height: 26px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: 0.2s;
    z-index: 10;
    padding: 0;
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 5 Free', sans-serif;
    font-weight: 900;
}
.circle-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* --- Badges --- */
.badge-featured {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    color: #fbbf24;
    font-size: 10px;
    text-align: center;
    padding: 4px 0;
    font-weight: bold;
    font-family: 'Estedad', sans-serif;
}

/* --- Loading Spinner --- */
.loading-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: var(--m-radius);
    font-size: 24px;
    color: #cbd5e1;
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 5 Free', sans-serif;
    font-weight: 900;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    :root {
        --m-size: 90px;
    }
    .media-grid {
        gap: 10px;
        justify-content: flex-start;
    }
}

/* ===================================================== */
/* مودال کراپ - طراحی کاملاً اصلاح شده */
/* ===================================================== */

/* پس‌زمینه مودال - حذف backdrop-filter و اصلاح موقعیت */
.crop-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

/* جعبه مودال - طراحی جدید */
.crop-modal-box {
    background: #fff;
    width: 90%;
    max-width: 550px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    margin: 20px auto;
    animation: modalSlideIn 0.25s ease-out;
    font-family: 'Estedad', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* هدر مودال */
.crop-modal-box .crop-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    background: #fff;
    font-size: 16px;
    color: #1e293b;
    font-family: 'Estedad', sans-serif;
}

/* دکمه بستن */
.crop-modal-box .crop-header #sadtik-crop-cancel-x {
    cursor: pointer;
    font-size: 18px;
    color: #94a3b8;
    transition: all 0.2s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 5 Free', sans-serif;
    font-weight: 900;
}

.crop-modal-box .crop-header #sadtik-crop-cancel-x:hover {
    background: #f1f5f9;
    color: #ef4444;
}

/* ===================================================== */
/* اصلاح مهم: بدنه مودال - حذف ارتفاع ثابت و پس‌زمینه تیره */
/* ===================================================== */
.crop-modal-box .crop-body {
    height: auto;
    min-height: 260px;
    max-height: 55vh;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
}

/* تصویر داخل مودال */
.crop-modal-box .crop-body img {
    max-width: 100%;
    max-height: 45vh;
    display: block;
    margin: 0 auto;
}

/* کانتینر کراپر (Cropper.js) */
.crop-modal-box .cropper-container {
    max-width: 100%;
    max-height: 45vh;
    margin: 0 auto;
}

/* فوتر مودال */
.crop-modal-box .crop-footer {
    padding: 16px 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #fff;
}

/* دکمه انصراف */
.crop-modal-box .btn-text {
    background: #f1f5f9;
    border: none;
    padding: 8px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s;
    color: #475569;
    font-family: 'Estedad', sans-serif;
}

.crop-modal-box .btn-text:hover {
    background: #e2e8f0;
}

/* دکمه تایید */
.crop-modal-box .btn-primary {
    background: #0373ec;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    font-family: 'Estedad', sans-serif;
}

.crop-modal-box .btn-primary:hover {
    background: #0259b5;
}

.crop-modal-box .btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

/* ریسپانسیو برای موبایل */
@media (max-width: 640px) {
    .crop-modal-box {
        width: 95%;
        max-width: 95%;
        border-radius: 16px;
    }
    
    .crop-modal-box .crop-body {
        min-height: 200px;
        padding: 15px;
    }
    
    .crop-modal-box .crop-footer {
        padding: 12px 15px;
    }
    
    .crop-modal-box .btn-text,
    .crop-modal-box .btn-primary {
        padding: 6px 18px;
        font-size: 12px;
    }
}
