/* Aparat Playlist Widget Styles */
.aparat-playlist-widget {
    width: 100%;
}

.aparat-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* Grid Layout */
.elementor-view-grid .aparat-container {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* List Layout */
.elementor-view-list .aparat-container {
    flex-direction: column;
}

.elementor-view-list .aparat-item {
    width: 100%;
}

/* Individual Item Styles */
.aparat-item {
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.aparat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Video Wrapper */
.aparat-video-wrapper {
    position: relative;
    width: 100%;
    height: 0;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio */
    background: #000;
    overflow: hidden;
}

/* Modern aspect-ratio support */
@supports (aspect-ratio: 16 / 9) {
    .aparat-video-wrapper {
        height: auto;
        padding-top: 0;
        aspect-ratio: 16 / 9;
    }
}

.aparat-video-wrapper>div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.aparat-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Description Styles */
.aparat-description {
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .elementor-view-grid .aparat-container {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 15px;
    }

    .aparat-container {
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .elementor-view-grid .aparat-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 12px;
    }

    .aparat-container {
        gap: 12px;
    }

    .aparat-description {
        padding: 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .elementor-view-grid .aparat-container {
        grid-template-columns: 1fr !important;
        /* Ensure single column on very small screens */
        gap: 15px;
    }

    .aparat-video-wrapper {
        min-height: 180px;
        /* Safety min-height for mobile */
    }

    .aparat-container {
        gap: 15px;
    }

    .aparat-item {
        border-radius: 6px;
    }

    .aparat-description {
        padding: 10px;
        font-size: 12px;
    }
}

/* RTL Support */
.rtl .aparat-playlist-widget {
    direction: rtl;
}

.rtl .aparat-description {
    text-align: right;
}

/* Loading State */
.aparat-video-wrapper.loading {
    background: #1a1a1a;
}

.aparat-video-wrapper.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin-top: -15px;
    margin-left: -15px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 5;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Error State */
.aparat-video-wrapper.error {
    background: #fff5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e53e3e;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* Accessibility */
.aparat-item:focus-within {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .aparat-playlist-widget {
        page-break-inside: avoid;
    }

    .aparat-video-wrapper {
        display: none;
    }

    .aparat-description {
        border: 1px solid #ddd;
        background: white !important;
    }
}