/* Advanced Posts Display - Frontend Styles */

/* Container */
.apd-posts-container {
    width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

/* Posts Grid */
.apd-posts-grid {
    display: grid;
    gap: 30px;
    margin-bottom: 40px;
}

/* List Layout */
.apd-layout-list .apd-posts-grid {
    grid-template-columns: 1fr;
}

/* Grid Layout */
.apd-layout-grid.apd-columns-2 .apd-posts-grid {
    grid-template-columns: repeat(2, 1fr);
}

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

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

.apd-layout-grid.apd-columns-5 .apd-posts-grid {
    grid-template-columns: repeat(5, 1fr);
}

/* Masonry Layout */
.apd-layout-masonry .apd-posts-grid {
    display: block;
}

.apd-layout-masonry.apd-columns-2 .apd-post-item {
    width: calc(50% - 15px);
}

.apd-layout-masonry.apd-columns-3 .apd-post-item {
    width: calc(33.333% - 20px);
}

.apd-layout-masonry.apd-columns-4 .apd-post-item {
    width: calc(25% - 22.5px);
}

.apd-layout-masonry.apd-columns-5 .apd-post-item {
    width: calc(20% - 24px);
}

/* Post Item */
.apd-post-item {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.apd-post-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.apd-post-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* List Layout Specific */
.apd-layout-list .apd-post-inner {
    flex-direction: row;
}

.apd-layout-list .apd-post-thumbnail {
    flex: 0 0 300px;
    max-width: 300px;
}

.apd-layout-list .apd-post-content {
    flex: 1;
}

/* Thumbnail */
.apd-post-thumbnail {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.apd-post-thumbnail::before {
    content: '';
    display: block;
    padding-top: 66.67%; /* 3:2 aspect ratio */
}

.apd-layout-list .apd-post-thumbnail::before {
    padding-top: 100%; /* 1:1 aspect ratio for list */
}

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

.apd-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.apd-post-item:hover .apd-post-thumbnail img {
    transform: scale(1.05);
}

/* Content */
.apd-post-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.apd-layout-list .apd-post-content {
    padding: 30px;
}

/* Title */
.apd-post-title {
    margin: 0 0 12px 0;
    font-size: 20px;
    line-height: 1.4;
    font-weight: 700;
    color: #1a1a1a;
}

.apd-post-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.apd-post-title a:hover {
    color: #2563eb;
}

.apd-layout-list .apd-post-title {
    font-size: 24px;
    margin-bottom: 16px;
}

/* Meta */
.apd-post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #666;
}

.apd-post-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.apd-post-meta svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Categories */
.apd-post-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.apd-category-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #f0f7ff;
    color: #2563eb;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.apd-category-badge:hover {
    background: #2563eb;
    color: #ffffff;
}

/* Excerpt */
.apd-post-excerpt {
    margin-bottom: 16px;
    color: #4a5568;
    line-height: 1.6;
    font-size: 14px;
    flex-grow: 1;
}

.apd-layout-list .apd-post-excerpt {
    font-size: 15px;
    margin-bottom: 20px;
}

/* Read More */
.apd-read-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: gap 0.2s ease;
    margin-top: auto;
}

.apd-read-more:hover {
    gap: 12px;
}

.apd-read-more svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.apd-read-more:hover svg {
    transform: translateX(4px);
}

/* Load More Button */
.apd-load-more-wrap {
    text-align: center;
    padding: 20px 0;
}

.apd-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.apd-load-more-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.apd-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.apd-loading {
    display: inline-block;
}

.apd-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: apd-spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .apd-layout-grid.apd-columns-5 .apd-posts-grid,
    .apd-layout-grid.apd-columns-4 .apd-posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .apd-layout-masonry.apd-columns-5 .apd-post-item,
    .apd-layout-masonry.apd-columns-4 .apd-post-item {
        width: calc(33.333% - 20px);
    }
}

@media (max-width: 768px) {
    .apd-posts-grid {
        gap: 20px;
    }
    
    .apd-layout-grid .apd-posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .apd-layout-masonry .apd-post-item {
        width: calc(50% - 10px) !important;
    }
    
    .apd-layout-list .apd-post-inner {
        flex-direction: column;
    }
    
    .apd-layout-list .apd-post-thumbnail {
        flex: none;
        max-width: 100%;
    }
    
    .apd-layout-list .apd-post-content {
        padding: 24px;
    }
    
    .apd-layout-list .apd-post-title {
        font-size: 20px;
    }
    
    .apd-layout-list .apd-post-excerpt {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .apd-posts-container {
        padding: 10px 0;
    }
    
    .apd-posts-grid {
        gap: 15px;
    }
    
    .apd-layout-grid .apd-posts-grid,
    .apd-layout-masonry .apd-posts-grid {
        grid-template-columns: 1fr;
    }
    
    .apd-layout-masonry .apd-post-item {
        width: 100% !important;
    }
    
    .apd-post-content {
        padding: 20px;
    }
    
    .apd-post-title {
        font-size: 18px;
    }
    
    .apd-post-meta {
        font-size: 12px;
        gap: 12px;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.apd-post-item {
    animation: fadeInUp 0.5s ease forwards;
}

/* Masonry Specific */
.apd-layout-masonry .apd-post-item {
    float: left;
    margin-bottom: 30px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .apd-post-item {
        background: #1a1a1a;
        box-shadow: 0 2px 8px rgba(255, 255, 255, 0.05);
    }
    
    .apd-post-item:hover {
        box-shadow: 0 8px 24px rgba(255, 255, 255, 0.08);
    }
    
    .apd-post-title,
    .apd-post-title a {
        color: #ffffff;
    }
    
    .apd-post-excerpt {
        color: #a0aec0;
    }
    
    .apd-post-meta {
        color: #718096;
    }
    
    .apd-category-badge {
        background: rgba(37, 99, 235, 0.2);
        color: #60a5fa;
    }
    
    .apd-category-badge:hover {
        background: #2563eb;
        color: #ffffff;
    }
}
