/* Advanced Posts Filter - Frontend Styles */

/* ==========================================================================
   Search Component
   ========================================================================== */

.apf-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

#single-template-topbar .apf-search-wrapper {
    max-width: 200px;
    margin: 0;
    float: right;
}

.apf-search-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.apf-search-input {
    width: 100%;
    padding: 15px !important;
    font-size: 16px;
    line-height: 1.5;
    border: 0 none !important;
    background-color: transparent !important;
    transition: all 0.3s ease;
    outline: none;
    color: #ffffff !important;
}

.apf-search-input::placeholder {
    color: #8E8F91;
    font-size: 16px;
}

.apf-search-input:focus {
    border: 0 none;
    outline: none;
}

.apf-search-icon {
    display: block;
    color: #ffffff;
}

#podcast-topbar .apf-search-icon {
    color: #141414;
}

.apf-search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.apf-search-dropdown.active {
    opacity: 1;
    transform: translateY(0);
}

.apf-search-results {
    padding: 10px 0;
}

.apf-search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.apf-search-result-item:hover {
    background-color: #f5f5f5;
}

.apf-search-result-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 15px;
    background-color: #f0f0f0;
}

.apf-search-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.apf-search-result-content {
    flex: 1;
    min-width: 0;
}

.apf-search-result-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 5px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apf-search-result-category {
    font-size: 13px;
    color: #D52738;
    font-weight: 500;
}

.apf-search-loading,
.apf-search-no-results {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* ==========================================================================
   Category Filter Component
   ========================================================================== */

.apf-category-filter {
    
}

.apf-category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

#podcast-category-filter .apf-category-list {
    justify-content: center !important;
}

.apf-category-item {
    padding: 5px 24px;
    font-size: 16px;
    font-weight: 700;
    color: #141414;
    border: 0 none;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    background: transparent;
    font-family: 'Montserrat', sans-serif;
    line-height: 150%;
    border-radius: 100px;
}

#podcast-topbar .apf-category-item {
    color: #141414;
}

.apf-category-item:hover {
    background-color: #D52738;
    color: #ffffff !important;
}

.apf-category-item.active {
    background-color: #D52738;
    color: #ffffff !important;
}

.apf-category-count {
    margin-left: 5px;
    opacity: 0.7;
    font-size: 13px;
}

/* ==========================================================================
   Posts Grid Component
   ========================================================================== */

.apf-posts-wrapper {
    width: 100%;
}

.apf-posts-grid-wrapper {
    margin-bottom: 30px;
    transition: opacity 0.3s ease;
}

.apf-posts-grid-wrapper.loading {
    opacity: 0.5;
    pointer-events: none;
}

.apf-posts-container {
    width: 100%;
}

/* Fullwidth Layout */
.apf-layout-fullwidth {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Grid Layout */
.apf-layout-grid {
    display: grid;
    gap: 30px;
}

.apf-layout-grid.apf-columns-1 {
    grid-template-columns: 1fr;
}

.apf-layout-grid.apf-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.apf-layout-grid.apf-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.apf-layout-grid.apf-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Masonry Layout */
.apf-layout-masonry {
    column-gap: 30px;
}

.apf-layout-masonry.apf-columns-2 {
    column-count: 2;
}

.apf-layout-masonry.apf-columns-3 {
    column-count: 3;
}

.apf-layout-masonry.apf-columns-4 {
    column-count: 4;
}

.apf-layout-masonry .apf-post-item {
    break-inside: avoid;
    margin-bottom: 30px;
}

/* Post Item */
.apf-post-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.apf-layout-fullwidth .apf-post-item {
    display: flex;
    gap: 60px;
    align-items: center;
}

.apf-post-item:hover {
    transform: translateY(-5px);
}

.apf-post-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 66.67%;
    overflow: hidden;
    background-color: #f0f0f0;
    border-radius: 10px;
    margin-bottom: 16px;
}

.apf-layout-fullwidth .apf-post-thumbnail {
    padding-top: 274px;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 0;
    max-width: 500px;
}

.apf-post-thumbnail a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.apf-post-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.apf-post-item:hover .apf-post-thumbnail img {

}

.apf-layout-fullwidth .apf-post-content {
    width: 100%;
}

.apf-post-category {
    margin-bottom: 12px;
}

.apf-post-category a {
    display: inline-block;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: #1DB280;
    text-decoration: none;
    transition: color 0.2s ease;
}

.apf-post-category a:hover {
    color: #005177;
}

.apf-post-title {
    margin: 0 0 15px;
    font-size: 22px;
    line-height: 1.2em;
    font-weight: 800;
}

.apf-post-title a {
    color: #141414;
    text-decoration: none;
    transition: color 0.2s ease;
}

.apf-post-title a:hover {
    color: #D52738;
}

.apf-post-excerpt {
    margin: 0 0 24px;
    font-size: 18px;
    line-height: 156%;
    color: #141414;
    font-weight: 400;
}

.apf-post-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 13px;
    color: #999;
}

.apf-post-date {
    display: flex;
    align-items: center;
}

/* No Posts Message */
.apf-no-posts {
    text-align: center;
    padding: 60px 20px;
    font-size: 18px;
    color: #666;
}

/* ==========================================================================
   Pagination (Next/Previous) Component
   ========================================================================== */

.apf-pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
}

.apf-prev-btn,
.apf-next-btn {
    padding: 10px 24px;
    border: 1px solid #D52738;
    background: transparent;
    color: #D52738;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    border-radius: 4px;
    font-family: 'Montserrat', sans-serif;
    min-width: 100px;
}

.apf-prev-btn:hover:not(:disabled),
.apf-next-btn:hover:not(:disabled) {
    background-color: #D52738;
    color: #ffffff;
}

.apf-prev-btn:disabled,
.apf-next-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #cccccc;
    color: #cccccc;
}

.apf-prev-btn[data-loading="true"] .apf-btn-text,
.apf-next-btn[data-loading="true"] .apf-btn-text {
    display: none;
}

.apf-prev-btn[data-loading="false"] .apf-btn-loading,
.apf-next-btn[data-loading="false"] .apf-btn-loading {
    display: none;
}

.apf-prev-btn[data-loading="true"] .apf-btn-loading,
.apf-next-btn[data-loading="true"] .apf-btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.apf-page-info {
    font-size: 14px;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
}

.apf-current-page {
    color: #D52738;
    font-weight: 700;
}

/* ==========================================================================
   Loading Spinner
   ========================================================================== */

.apf-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(213, 39, 56, 0.3);
    border-top-color: #D52738;
    border-radius: 50%;
    animation: apf-spin 0.6s linear infinite;
}

.apf-search-loading .apf-spinner {
    border-color: rgba(0, 0, 0, 0.2);
    border-top-color: #333;
}

@keyframes apf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media screen and (max-width: 1024px) {
    .apf-layout-grid.apf-columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .apf-layout-masonry.apf-columns-4 {
        column-count: 3;
    }
}

@media screen and (max-width: 768px) {
    .apf-search-wrapper {
        max-width: 150px !important;
        float: right;
    }
    
    .apf-search-input {
        padding: 15px !important;
        font-size: 15px;
    }
    
    .apf-category-list {
        gap: 8px;
    }
    
    .apf-category-item {
        padding: 8px 20px;
        font-size: 14px;
    }
    
    .apf-layout-grid.apf-columns-3,
    .apf-layout-grid.apf-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .apf-layout-masonry.apf-columns-3,
    .apf-layout-masonry.apf-columns-4 {
        column-count: 2;
    }
    
    .apf-posts-container {
        gap: 20px;
    }
    
    .apf-post-title {
        font-size: 18px;
    }
    .apf-search-dropdown {
        width: 82vw;
        max-width: 620px;
        right: auto;
        left: 50%;
        transform: translateX(-70vw) !important;
    }
    
    .apf-pagination-wrapper {
        gap: 15px;
    }
    
    .apf-prev-btn,
    .apf-next-btn {
        min-width: 80px;
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .apf-page-info {
        font-size: 13px;
    }
    .apf-layout-fullwidth .apf-post-item {
        flex-wrap: wrap !important;
    }
}

@media screen and (max-width: 540px) {
    .apf-post-title {
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    .apf-layout-grid.apf-columns-2,
    .apf-layout-grid.apf-columns-3,
    .apf-layout-grid.apf-columns-4 {
        grid-template-columns: 1fr;
    }
    
    .apf-layout-masonry.apf-columns-2,
    .apf-layout-masonry.apf-columns-3,
    .apf-layout-masonry.apf-columns-4 {
        column-count: 1;
    }
    
    .apf-search-result-thumbnail {
        width: 50px;
        height: 50px;
        margin-right: 12px;
    }
    
    .apf-search-result-title {
        font-size: 14px;
    }
    .apf-search-dropdown {
        width: 80vw;
        max-width: 100vw;
        right: auto;
        left: 50%;
        transform: translateX(-65vw) !important;
    }
    .apf-post-title {
        font-size: 18px;
    }
    .random-article-post__item {
        flex-wrap: wrap;
    }
    .random-article-post__featured-img {
        max-width: 100% !important;
    }
    
    .apf-pagination-wrapper {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .apf-page-info {
        width: 100%;
        text-align: center;
        order: -1;
        margin-bottom: 10px;
    }
    .apf-layout-fullwidth .apf-post-thumbnail {
        padding-top: 164px;
    }
}