/* ==========================================================================
   Aparat Video Manager - Final Version 4.0 (Grid Layout)
   ========================================================================== */

/* ==========================================================================
   1. Grid System (Reverted to a simple and robust Grid)
   ========================================================================== */
.avm-videos-grid {
    display: grid;
    gap: 25px;
    margin-bottom: 25px;
}

.avm-grid-cols-1 { grid-template-columns: 1fr; }
.avm-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.avm-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.avm-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }


/* ==========================================================================
   2. Video Card (Item) Styles
   ========================================================================== */
.avm-video-item {
    background-color: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}
.avm-video-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.12);
}
.avm-video-link-wrapper {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.avm-video-item-inner {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.avm-video-thumbnail { position: relative; }
.avm-video-thumbnail img { width: 100%; height: auto; display: block; aspect-ratio: 16 / 9; object-fit: cover; }
.avm-video-duration {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(18, 25, 38, 0.85);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 4px;
    line-height: 1;
}
.avm-video-duration svg { stroke: #fff; }
.avm-title-wrapper { padding: 20px; display: flex; flex-direction: column; flex-grow: 1; }
.avm-video-title { font-size: 17px; font-weight: 600; margin: 0; line-height: 1.5; color: #222; }
.avm-video-meta { margin-top: 12px; }
.avm-video-date { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #888; }
.avm-video-date svg { stroke: #888; }
.avm-video-excerpt { margin-top: 15px; font-size: 14px; color: #555; line-height: 1.6; flex-grow: 1; }
.avm-video-excerpt p { margin: 0; }

/* ==========================================================================
   3. Single Video Page & Other Styles
   ========================================================================== */
.avm-video-player-wrapper { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; margin-bottom: 25px; border-radius: 10px; }
.avm-video-player-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }
.avm-related-videos { margin-top: 100px; padding-top: 40px; border-top: 1px solid #eee; clear: both; }
.related-videos-title { margin-bottom: 30px; font-size: 22px; text-align: center; }
body.single-aparat_video .wd-content-area.site-content { padding-top: 50px !important; }

/* ==========================================================================
   4. Pagination & AJAX Loader
   ========================================================================== */
.avm-pagination { margin-top: 30px; text-align: center; }
.avm-pagination .page-numbers { display: inline-block; padding: 8px 14px; margin: 0 2px; border: 1px solid #ccc; border-radius: 4px; text-decoration: none; transition: background-color 0.2s, color 0.2s; }
.avm-pagination .page-numbers.current, .avm-pagination .page-numbers:hover { background-color: #0073aa; color: #fff; border-color: #0073aa; }
.avm-shortcode-wrapper { position: relative; }
.avm-loader-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.7); z-index: 10; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.avm-loader { border: 5px solid #f3f3f3; border-top: 5px solid #3498db; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================================================
   5. Responsive Media Queries
   ========================================================================== */
@media (max-width: 992px) {
    .avm-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on tablets */
    }
}

@media (max-width: 768px) {
    .avm-grid-cols-3,
    .avm-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on small tablets */
    }
}

@media (max-width: 600px) {
    .avm-videos-grid {
        grid-template-columns: 1fr; /* 1 column on mobile */
    }
}

/*
 * ==========================================================================
   FINAL FIX: Top margin for Single Video Page (Content + Sidebar)
   ==========================================================================
*/
body.single-aparat_video .content-layout-wrapper {
    margin-top: 150px !important;
}