/* Main Layout Container */
.sauge-blog-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    align-items: start;
}

/* Main Content Area */
.sauge-blog-main-content {
    min-height: 500px;
    transition: padding-top 0.2s ease-in-out;
}

/* Grid layout */
.sauge-blog-posts-grid-container {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin: 0 auto;
    padding: 0;
}

/* Force full width and remove default sidebar */
.sauge-blog-custom-posts-grid-page {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sauge-blog-custom-posts-grid-page #page {
    width: 100% !important;
    max-width: 100% !important;
    display: flex;
    justify-content: center;
}

.sauge-blog-custom-posts-grid-page .site-content {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
}

.sauge-blog-custom-posts-grid-page .content-area,
.sauge-blog-custom-posts-grid-page #primary {
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    float: none !important;
}

/* Hide default sidebar */
.sauge-blog-custom-posts-grid-page #right-sidebar,
.sauge-blog-custom-posts-grid-page .sidebar,
.sauge-blog-custom-posts-grid-page #secondary {
    display: none !important;
}

/* Post card styling */
.sauge-blog-grid-post {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sauge-blog-grid-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* Post link */
.sauge-blog-post-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Thumbnail */
.sauge-blog-post-thumbnail {
    position: relative;
    padding-top: 66.67%;
    overflow: hidden;
    background: #f5f5f5;
}

.sauge-blog-post-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.sauge-blog-grid-post:hover .sauge-blog-post-thumbnail img {
    transform: scale(1.05);
}

/* Content area */
.sauge-blog-post-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Title */
.sauge-blog-post-title {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    line-height: 1.4;
    color: #005f73;
    font-weight: 600;
}

/* Excerpt */
.sauge-blog-post-excerpt {
    font-size: 0.9em;
    line-height: 1.5;
    color: #666;
    margin-top: auto;
}

/* Read more link */
.sauge-blog-read-more {
    display: block;
    margin-top: 10px;
    color: #005f73;
    font-weight: 500;
    font-size: 0.9em;
    text-decoration: none;
    transition: color 0.3s ease;
}

.sauge-blog-post-link:hover .sauge-blog-read-more {
    text-decoration: underline;
}

/* Ad Container Base Styles */
.sauge-blog-ad-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    width: 100%;
    position: relative;
    margin: 24px auto;
}

/* Ad Label */
.sauge-blog-ad-label {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Ad Placeholders */
.sauge-blog-ad-placeholder {
    width: 100%;
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Top Banner and In-feed Ad Containers */
.sauge-blog-main-content .sauge-blog-ad-container-top {
    max-width: 1500px;
    width: 100%;
    grid-column: 1 / -1;
    margin-bottom: 30px;
}

.sauge-blog-main-content .sauge-blog-ad-container-feed {
    max-width: 1500px;
    width: 100%;
    grid-column: 1 / -1;
    margin: 24px auto;
}

/* Ad Placeholders for Top Banner and In-feed */
.sauge-blog-main-content .sauge-blog-ad-container-top .sauge-blog-ad-placeholder,
.sauge-blog-main-content .sauge-blog-ad-container-feed .sauge-blog-ad-placeholder {
    width: 100%;
    height: 90px;
    min-height: 90px;
}

/* Sidebar Ad Containers */
.sauge-blog-sidebar .sauge-blog-sidebar-ad {
    width: 100%;
    max-width: 300px;
}

.sauge-blog-sidebar .sauge-blog-sidebar-ad .sauge-blog-ad-placeholder {
    width: 100%;
    height: 250px;
    min-height: 250px;
}

/* Sidebar Styles */
.sauge-blog-sidebar {
    width: 300px;
    height: calc(100vh - 40px);
    position: sticky;
    /* Initial position aligned with first post row */
    top: 127px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Add smooth transition for scrolling effect */
    transition: transform 0.3s ease-out;
    /* Initial position offset to align with first post row */
    margin-top: 176px; /* Adjust this value based on your top ad container height */
}

.sauge-blog-sidebar.scrolled {
    transform: translateY(-70px); /* Adjust this value to control how far up it moves */
}

/* Desktop Filters */
.sauge-blog-sidebar-filters {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sauge-blog-filters-title {
    margin-bottom: 16px;
    font-size: 18px;
    color: #1e293b;
}

.sauge-blog-category-filter {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1e293b;
    background-color: white;
}

.sauge-blog-category-filter:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 1px #6366f1;
}

/* Scrollable Ads Section */
.sauge-blog-sidebar-ads {
    flex: 1;
    overflow-y: auto;
    padding-right: 6px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Ad Placeholder Text */
.sauge-blog-ad-placeholder-text {
    color: #94a3b8;
    font-size: 14px;
    font-style: italic;
}

/* Load More Button */
.sauge-blog-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 40px auto;
    padding: 12px 32px;
    background: linear-gradient(135deg, #34d399 0%, #3b82f6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sauge-blog-load-more:hover {
    background: linear-gradient(135deg, #10b981 0%, #2563eb 100%);
    color: white;
    transform: translateY(-1px);
}

.sauge-blog-load-more:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.sauge-blog-load-more i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.sauge-blog-load-more:hover i {
    transform: translateY(2px);
}

/* Loading Spinner */
.sauge-blog-loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px;
    color: #3b82f6;
}

/* Mobile Filter Styles */
.sauge-blog-mobile-filter {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transform: translateY(-100%);
    transition: transform 0.2s ease-in-out;
}

.sauge-blog-mobile-filter.visible {
    transform: translateY(0);
}

.sauge-blog-mobile-filter-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sauge-blog-mobile-filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
}

.sauge-blog-mobile-category-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    color: #1e293b;
    background-color: white;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

.sauge-blog-mobile-category-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Add padding to main content when filter is visible */
.sauge-blog-main-content.filter-visible {
    padding-top: 60px;
}

/* Responsive Design */
@media screen and (max-width: 1200px) {
    .sauge-blog-posts-grid-container {
        gap: 20px;
    }
}

/* Tablet Layout (768px to 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .sauge-blog-container {
        grid-template-columns: 1fr 300px;
    }

    .sauge-blog-sidebar {
        display: block;
        position: sticky;
        top: 20px;
        margin-top: 90px; /* Keep the same offset */
    }

    .sauge-blog-sidebar.scrolled {
        transform: translateY(-70px); /* Keep the same transform */
    }

    .sauge-blog-mobile-filter {
        display: none !important;
    }
}

/* Mobile Layout (below 768px) */
@media screen and (max-width: 768px) {
    .sauge-blog-container {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .sauge-blog-sidebar {
        display: none;
    }

    .sauge-blog-custom-posts-grid-page .sauge-blog-mobile-filter {
        display: block;
    }

    .sauge-blog-posts-grid-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .sauge-blog-post-content {
        padding: 15px;
    }

    .sauge-blog-post-title {
        font-size: 1em;
    }

    .sauge-blog-post-excerpt {
        font-size: 0.85em;
    }
}