/*
 * CSS for Category Post Grid Shortcode (AJAX - Final Layout)
 * This CSS is designed to place the menu on the left and the 3-column post grid on the right.
 */

/* 1. Main Container & Layout (Desktop/General) */
.category-post-grid-container, 
.category-post-grid-wrapper { 
    display: flex !important; /* CRITICAL: Forces side-by-side layout (Menu on Left, Grid on Right) */
    gap: 30px; 
    padding: 20px 0;
    font-family: sans-serif;
}

.category-post-grid-wrapper {
  display: flex !important;
}

/* 2. Left Sidebar (Sticky Menu) */
.cpg-sidebar-sticky-wrap {
    flex: 0 0 250px; /* Fixed width for sidebar area */
}

.cpg-sidebar {
    position: sticky; 
    top: 40px; 
    padding: 15px;
    border-right: 1px solid #eee;
}

.cpg-category-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cpg-menu-item {
    margin-bottom: 5px;
}

.cpg-menu-item a {
    display: block;
    padding: 8px 10px;
    text-decoration: none;
    color: #333;
    background: #f9f9f9;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    white-space: normal; 
    word-break: break-word;
}

.cpg-menu-item a:hover,
.cpg-menu-item.active a {
    background: #10b981; 
    color: #fff;
}

/* 3. Right Content Grid Container (Used for AJAX and Loading) */
.cpg-content-grid-container {
    flex: 1; /* Takes up all remaining space */
    position: relative; 
    min-height: 400px; 
}

/* 4. AJAX Loading Overlay */
#cpg-posts-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none; 
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    color: #10b981; 
    z-index: 10;
}

/* 5. Post Grid Styles (Inner Container) */
.cpg-grid-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* <--- THIS SETS 3 EQUAL COLUMNS */
    gap: 20px; 
}

.cpg-grid-item {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cpg-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.cpg-post-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    aspect-ratio: 16 / 9; 
}

.cpg-no-image-placeholder { 
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    color: #999;
    min-height: 150px;
    aspect-ratio: 16 / 9;
}

.cpg-item-details {
    padding: 15px;
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
}

.cpg-post-category-title {
    font-size: 0.8rem;
    color: #4b5563;
    text-transform: uppercase;
    font-weight: 600;
    margin: 0 0 5px 0;
    letter-spacing: 0.5px;
}

.cpg-post-title {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 1.2em;
    color: #333;
}

.cpg-post-excerpt {
    font-size: 0.95em;
    color: #555;
    margin-top: 10px;
}

/* 6. Pagination Styling */
.cpg-pagination {
    margin-top: 40px;
    text-align: center;
}

.cpg-pagination .page-numbers {
    padding: 5px 10px;
    margin: 0 3px;
    border: 1px solid #e5e7eb;
    text-decoration: none;
    color: #4b5563;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.cpg-pagination .page-numbers:hover {
    background-color: #f3f4f6;
}

.cpg-pagination .page-numbers.current {
    background-color: #10b981;
    border-color: #10b981;
    color: #fff;
}


/* 7. Mobile Responsiveness */
@media (max-width: 900px) {
    .category-post-grid-container,
    .category-post-grid-wrapper {
        flex-direction: column !important; /* Stack menu/grid on tablet */
    }
    .cpg-sidebar-sticky-wrap {
        flex: auto; 
        position: static;
    }
    .cpg-sidebar {
        position: static;
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    .cpg-grid-row {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on tablet */
    }
}
@media (max-width: 600px) {
    .cpg-grid-row {
        grid-template-columns: 1fr; /* 1 column on phone */
    }
}