/**
 * Advanced Posts Widget Styles
 *
 * @package Advanced_Widget_Kit
 * @since 2.1.0
 */

/* ========================================
   POSTS GRID LAYOUT
   ======================================== */

.awke-advanced-posts-widget {
    width: 100%;
}

.awke-posts-container {
    display: flex;
    width: 100%;
    justify-content: flex-start;
}

.awke-posts-grid {
    display: grid;
    gap: 30px;
    margin-bottom: 30px;
    width: auto;
    flex: 1;
    max-width: 100%;
}

/* When centered or right-aligned, grid should not stretch */
.awke-grid-align-center .awke-posts-grid,
.awke-grid-align-right .awke-posts-grid {
    flex: 0 1 auto;
    width: auto;
}

/* Grid Layout */
.awke-posts-grid.awke-posts-grid {
    grid-template-columns: repeat(3, 1fr);
}

.awke-posts-grid[data-columns="1"] {
    grid-template-columns: repeat(1, 1fr);
}

.awke-posts-grid[data-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.awke-posts-grid[data-columns="3"] {
    grid-template-columns: repeat(3, 1fr);
}

.awke-posts-grid[data-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.awke-posts-grid[data-columns="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.awke-posts-grid[data-columns="6"] {
    grid-template-columns: repeat(6, 1fr);
}

/* Grid alignment - uses flexbox wrapper to position grid */
.awke-grid-align-left .awke-posts-container {
    justify-content: flex-start;
}

.awke-grid-align-left .awke-posts-grid {
    flex: 1;
    width: 100%;
}

.awke-grid-align-center .awke-posts-container {
    justify-content: center;
}

.awke-grid-align-center .awke-posts-grid {
    width: auto !important;
}

.awke-grid-align-right .awke-posts-container {
    justify-content: flex-end;
}

.awke-grid-align-right .awke-posts-grid {
    width: auto !important;
}

/* Tablet alignment */
@media (max-width: 1024px) {
    .awke-grid-align-tablet-left .awke-posts-container {
        justify-content: flex-start;
    }

    .awke-grid-align-tablet-left .awke-posts-grid {
        flex: 1;
        width: 100%;
    }

    .awke-grid-align-tablet-center .awke-posts-container {
        justify-content: center;
    }

    .awke-grid-align-tablet-center .awke-posts-grid {
        flex: 0 1 auto;
        width: auto !important;
    }

    .awke-grid-align-tablet-right .awke-posts-container {
        justify-content: flex-end;
    }

    .awke-grid-align-tablet-right .awke-posts-grid {
        flex: 0 1 auto;
        width: auto !important;
    }
}

/* Mobile alignment */
@media (max-width: 768px) {
    .awke-grid-align-mobile-left .awke-posts-container {
        justify-content: flex-start;
    }

    .awke-grid-align-mobile-left .awke-posts-grid {
        flex: 1;
        width: 100%;
    }

    .awke-grid-align-mobile-center .awke-posts-container {
        justify-content: center;
    }

    .awke-grid-align-mobile-center .awke-posts-grid {
        flex: 0 1 auto;
        width: auto !important;
    }

    .awke-grid-align-mobile-right .awke-posts-container {
        justify-content: flex-end;
    }

    .awke-grid-align-mobile-right .awke-posts-grid {
        flex: 0 1 auto;
        width: auto !important;
    }
}

/* List Layout */
.awke-posts-grid.awke-posts-list {
    grid-template-columns: 1fr;
}

.awke-posts-list .awke-post-item {
    display: flex;
    gap: 30px;
}

.awke-posts-list .awke-post-image {
    flex: 0 0 300px;
    max-width: 300px;
}

.awke-posts-list .awke-post-content {
    flex: 1;
}

/* List Layout - Image Position - Left (default) */
.awke-posts-list.awke-image-left .awke-post-item {
    flex-direction: row;
}

/* List Layout - Image Position - Right */
.awke-posts-list.awke-image-right .awke-post-item {
    flex-direction: row-reverse;
}

/* List Layout - Image Position - Top */
.awke-posts-list.awke-image-top .awke-post-item {
    flex-direction: column;
}

.awke-posts-list.awke-image-top .awke-post-image {
    flex: 1;
    max-width: 100%;
}

/* Grid/Masonry Layout - Image Position Bottom */
.awke-posts-grid.awke-image-bottom:not(.awke-posts-list) .awke-post-item {
    flex-direction: column-reverse;
}

.awke-posts-grid.awke-image-bottom:not(.awke-posts-list) .awke-post-image img {
    border-radius: 0 0 8px 8px !important;
}

.awke-posts-grid.awke-image-top:not(.awke-posts-list) .awke-post-image img {
    border-radius: 8px 8px 0 0;
}

/* Masonry Layout */
.awke-posts-grid.awke-posts-masonry {
    display: block;
    column-count: 3;
    column-gap: 30px;
}

.awke-posts-masonry .awke-post-item {
    break-inside: avoid;
    margin-bottom: 30px;
}

/* ========================================
   POST ITEM
   ======================================== */

.awke-post-item {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.awke-post-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ========================================
   POST IMAGE
   ======================================== */

.awke-post-image {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.awke-post-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.awke-post-item:hover .awke-post-image img {
    transform: scale(1.05);
}

.awke-post-image a {
    display: block;
    line-height: 0;
}

/* ========================================
   POST CONTENT
   ======================================== */

.awke-post-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    text-align: left;
    align-items: flex-start;
}

/* ========================================
   POST META
   ======================================== */

.awke-post-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #999999;
    width: 100%;
}

.awke-post-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.awke-post-meta i {
    font-size: 14px;
}

/* ========================================
   POST TITLE
   ======================================== */

.awke-post-title {
    margin: 0 0 15px;
    line-height: 1.4;
}

.awke-post-title a {
    color: #333333;
    text-decoration: none;
    transition: color 0.3s ease;
    display: inline-block;
}

.awke-post-title a:hover {
    color: #667eea;
}

/* ========================================
   POST EXCERPT
   ======================================== */

.awke-post-excerpt {
    color: #666666;
    line-height: 1.6;
    margin-bottom: 20px;
    flex-grow: 1;
}

/* ========================================
   READ MORE BUTTON
   ======================================== */

.awke-post-read-more {
    display: inline-block;
    padding: 10px 25px;
    background: #667eea;
    color: #ffffff;
    text-decoration: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.awke-post-read-more:hover {
    background: #764ba2;
    transform: translateX(5px);
}

/* ========================================
   PAGINATION
   ======================================== */

.awke-posts-pagination {
    margin-top: 40px;
    text-align: center;
}

.awke-posts-pagination .page-numbers {
    display: inline-block;
    padding: 10px 15px;
    margin: 0 5px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #333333;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.awke-posts-pagination .page-numbers:hover,
.awke-posts-pagination .page-numbers.current {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
}

.awke-posts-pagination .page-numbers.current {
    pointer-events: none;
}

/* Pagination Links */
.awke-pagination-link {
    display: inline-block;
    padding: 10px 15px;
    margin: 0 5px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #333333;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.awke-pagination-link:hover {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
}

.awke-pagination-link.current {
    background: #667eea;
    color: #ffffff;
    border-color: #667eea;
    pointer-events: none;
}

.awke-pagination-numbers {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.awke-posts-pagination .page-numbers i {
    font-size: 14px;
}

/* Previous/Next Pagination */
.awke-prev-next-pagination {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.awke-prev-next-pagination a {
    display: inline-block;
    padding: 12px 25px;
    background: #667eea;
    color: #ffffff;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.awke-prev-next-pagination a:hover {
    background: #764ba2;
}

/* Load More Button */
.awke-load-more-btn {
    display: inline-block;
    padding: 12px 40px;
    background: #667eea;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.awke-load-more-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

.awke-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.awke-load-more-btn.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 10px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: awke-spin 0.6s linear infinite;
}

@keyframes awke-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    .awke-posts-grid[data-columns="4"],
    .awke-posts-grid[data-columns="5"],
    .awke-posts-grid[data-columns="6"] {
        grid-template-columns: repeat(3, 1fr);
    }

    .awke-posts-masonry {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .awke-posts-grid[data-columns="3"],
    .awke-posts-grid[data-columns="4"],
    .awke-posts-grid[data-columns="5"],
    .awke-posts-grid[data-columns="6"] {
        grid-template-columns: repeat(2, 1fr);
    }

    .awke-posts-list .awke-post-item {
        flex-direction: column;
    }

    .awke-posts-list .awke-post-image {
        flex: 1;
        max-width: 100%;
    }

    .awke-posts-masonry {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    .awke-posts-grid {
        grid-template-columns: 1fr !important;
    }

    .awke-posts-masonry {
        column-count: 1;
    }

    .awke-prev-next-pagination {
        flex-direction: column;
    }

    .awke-post-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* ========================================
   NO POSTS FOUND
   ======================================== */

.awke-advanced-posts-widget > p {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    color: #666666;
    font-size: 16px;
}

