/* Preview Modal - Zhaket Demo */

.mlm-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mlm-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.mlm-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.mlm-preview-container {
    position: relative;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.mlm-preview-modal.active .mlm-preview-container {
    transform: scale(1);
}

.mlm-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    background: linear-gradient(135deg, #FEA000 0%, #FF8C00 100%);
    border-bottom: 3px solid #e69500;
}

.mlm-preview-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
}

.mlm-preview-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    font-size: 18px;
}

.mlm-preview-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.mlm-preview-body {
    padding: 0;
    background: #f5f5f5;
    min-height: 300px;
    flex: 1;
    overflow: hidden; /* پیش‌فرض بدون اسکرول */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* فقط برای PDF اسکرول فعال باشه */
.mlm-preview-body:has(.mlm-pdf-viewer:not([style*="display: none"])) {
    overflow: auto;
}

/* Fallback برای مرورگرهای قدیمی که :has() ندارن */
.mlm-preview-body.show-pdf {
    overflow: auto;
}

/* سایر حالت‌ها بدون اسکرول */
.mlm-preview-body.show-audio,
.mlm-preview-body.show-video,
.mlm-preview-body.show-image,
.mlm-preview-body.show-error {
    overflow: hidden;
}

/* Player Wrappers */
.mlm-player-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Audio Player - ثابت با ارتفاع محدود */
.mlm-audio-player {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 20px;
    height: auto;
}

.mlm-audio-container {
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.mlm-audio-container audio {
    width: 100%;
    margin-bottom: 20px;
    border-radius: 50px;
    outline: none;
}

.mlm-audio-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #FEA000 0%, #FF8C00 100%);
    border-radius: 10px;
    color: #fff;
}

.mlm-audio-info .icon {
    font-size: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.mlm-audio-name {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

/* Video Player - ثابت بدون اسکرول */
.mlm-video-player {
    background: #000;
    padding: 0;
    height: auto;
}

.mlm-video-player video {
    width: 100%;
    height: auto;
    max-height: calc(90vh - 100px); /* ارتفاع ثابت منهای header */
    display: block;
    outline: none;
    object-fit: contain;
}

/* PDF Viewer - قابل اسکرول */
.mlm-pdf-viewer {
    padding: 0;
    background: #525659;
    height: auto;
    width: 100%;
}

.mlm-pdf-viewer iframe {
    width: 100%;
    height: calc(90vh - 100px); /* ارتفاع ثابت */
    min-height: 600px;
    border: none;
    display: block;
}

/* Image Viewer - ثابت بدون اسکرول */
.mlm-image-viewer {
    background: #000;
    padding: 20px;
    height: auto;
}

.mlm-image-viewer img {
    max-width: 100%;
    max-height: calc(90vh - 140px); /* ارتفاع ثابت منهای header و padding */
    width: auto;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

/* Error Message */
.mlm-preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 60px 20px;
    color: #666;
}

.mlm-preview-error .icon {
    font-size: 64px;
    color: #FEA000;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.mlm-preview-error p {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mlm-preview-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .mlm-preview-header {
        padding: 15px 20px;
    }
    
    .mlm-preview-title {
        font-size: 16px;
    }
    
    .mlm-preview-close {
        width: 35px;
        height: 35px;
    }
    
    .mlm-audio-container {
        padding: 20px;
    }
    
    .mlm-pdf-viewer iframe {
        min-height: 400px;
        height: calc(95vh - 80px);
    }
    
    .mlm-video-player video {
        max-height: calc(95vh - 80px);
    }
    
    .mlm-image-viewer img {
        max-height: calc(95vh - 120px);
    }
}

/* Loading Animation */
.mlm-preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FEA000;
    font-size: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Prevent body scroll when modal is open */
body.mlm-preview-open {
    overflow: hidden;
}

