/**
 * Advanced Post Grid Widget Styles
 * Version: 3.0.0
 */

/* =================================================================
   Grid Layout
   ================================================================= */
.apg-post-grid {
    display: grid;
    width: 100%;
}

.apg-post-item {
    position: relative;
    overflow: hidden;
    background: #fff;
    transition: all 0.3s ease;
    display: flex;
    /* Gap is handled via Elementor Control, but we need flex-wrap protection */
    width: 100%;
    box-sizing: border-box;
    min-height: auto;
}

/* RTL Layout - Image Right */
.apg-post-item.apg-post-horizontal.apg-dir-rtl {
    flex-direction: row-reverse;
}

/* LTR Layout - Image Left */
.apg-post-item.apg-post-horizontal.apg-dir-ltr {
    flex-direction: row;
}

/* =================================================================
   Image Styles
   ================================================================= */
.apg-post-image {
    position: relative;
    overflow: hidden;
    /* Default flex basis, overridden by Elementor control */
    flex: 0 0 35%; 
    width: 35%;
}

.apg-post-image a {
    display: block;
    height: 100%;
    width: 100%;
}

.apg-post-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.apg-post-item:hover .apg-post-image img {
    transform: scale(1.05);
}

.apg-post-category {
    position: absolute;
    /* Default coords, overridden by Elementor control */
    top: 15px; 
    right: 15px;
    padding: 6px 15px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    border-radius: 3px;
    line-height: 1.2;
}

/* =================================================================
   Content Styles
   ================================================================= */
.apg-post-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 100%;
    box-sizing: border-box;
}

.apg-post-meta {
    display: flex;
    flex-wrap: wrap;
    font-size: 13px;
    margin-bottom: 12px;
    align-items: center;
    width: 100%;
}

.apg-post-meta i,
.apg-post-meta svg {
    margin-right: 5px; /* Default, overridden by control */
    flex-shrink: 0;
}

.apg-post-meta .apg-post-category-meta,
.apg-post-meta .apg-post-date,
.apg-post-meta .apg-post-author {
    display: flex;
    align-items: center;
}

.apg-post-meta .apg-post-category-meta {
    font-weight: 600;
}

.apg-post-title {
    margin: 0 0 10px;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 700;
    width: 100%;
}

.apg-post-title a {
    text-decoration: none;
    transition: color 0.3s ease;
    display: block;
}

.apg-post-excerpt {
    line-height: 1.6;
    margin-bottom: 15px;
    font-size: 14px;
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apg-read-more {
    display: inline-block;
    padding: 10px 25px;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    font-weight: 600;
    align-self: flex-start;
    font-size: 14px;
}

.apg-read-more:hover {
    transform: translateY(-2px);
}

/* =================================================================
   Vertical Style
   ================================================================= */
.apg-post-item.apg-post-vertical {
    flex-direction: column !important;
}

.apg-post-item.apg-post-vertical .apg-post-image {
    flex: 0 0 auto !important;
    width: 100% !important;
}

/* =================================================================
   Carousel Styles
   ================================================================= */
.apg-carousel-wrapper {
    position: relative;
    padding: 0 50px;
}

.apg-carousel {
    display: flex;
    /* Gap is set via JS from Elementor setting, but default helps */
    gap: 30px; 
    overflow: hidden;
    scroll-behavior: smooth;
    padding-bottom: 10px; /* Space for shadows */
}

.apg-carousel .apg-post-item {
    flex: 0 0 auto;
    /* Width set via JS */
}

.apg-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.apg-carousel-arrow:hover {
    transform: translateY(-50%) scale(1.1);
}

.apg-carousel-prev {
    left: 0;
}

.apg-carousel-next {
    right: 0;
}

.apg-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.apg-carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
}

.apg-carousel-dot.active {
    transform: scale(1.3);
}

/* =================================================================
   Pagination Styles
   ================================================================= */
.apg-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.apg-pagination a,
.apg-pagination span {
    display: inline-block;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.apg-load-more {
    display: inline-block;
    padding: 12px 30px;
    border: none;
    border-radius: 3px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.apg-load-more:hover {
    transform: translateY(-2px);
}

.apg-load-more.loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

.apg-load-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =================================================================
   Responsive - Tablet
   ================================================================= */
@media (max-width: 1024px) {
    /* Let Elementor controls handle sizing primarily */
    .apg-post-content {
        padding: 18px;
    }
}

/* =================================================================
   Responsive - Mobile Landscape
   ================================================================= */
@media (max-width: 768px) {
    .apg-post-item,
    .apg-post-item.apg-dir-rtl,
    .apg-post-item.apg-dir-ltr,
    .apg-post-item.apg-post-horizontal {
        flex-direction: column !important;
    }
    
    .apg-post-image {
        flex: 0 0 auto !important;
        width: 100% !important;
    }
    
    .apg-carousel-wrapper {
        padding: 0 35px;
    }
}

/* =================================================================
   Loading State
   ================================================================= */
.apg-post-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}