/**
 * SQO Posts Display - ULTIMATE VERSION
 * Fixed: Nested grid problem & proper structure
 */

/* ====================================
   Base Wrapper (NO GRID HERE!)
   ==================================== */
.sqo-posts-wrapper {
    width: 100% !important;
    max-width: 100%;
    position: relative;
    display: block;
}

/* ====================================
   Grid Layout (ONLY on inner .sqo-posts-grid)
   ==================================== */
.sqo-posts-grid {
    display: grid !important;
    grid-template-columns: repeat(var(--columns, 3), 1fr) !important;
    gap: var(--gap, 30px);
    width: 100% !important;
    max-width: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force cards to fill their grid cells */
.sqo-posts-grid > .sqo-post-card {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
}

/* Responsive Grid */
@media (max-width: 1024px) {
    .sqo-posts-grid {
        grid-template-columns: repeat(var(--columns-tablet, 2), 1fr) !important;
    }
}

@media (max-width: 767px) {
    .sqo-posts-grid {
        grid-template-columns: repeat(var(--columns-mobile, 1), 1fr) !important;
    }
}

/* ====================================
   Pagination
   ==================================== */
.sqo-posts-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.sqo-posts-pagination a,
.sqo-posts-pagination .current,
.sqo-posts-pagination .page-numbers,
.sqo-posts-pagination .dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sqo-posts-pagination a:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.sqo-posts-pagination .current,
.sqo-posts-pagination .page-numbers.current {
    background: #000;
    color: #fff;
    border-color: #000;
}

.sqo-posts-pagination .dots {
    border: none;
    background: transparent;
}

/* ====================================
   Slider Layout
   ==================================== */
.sqo-posts-slider .swiper {
    width: 100%;
    padding: 10px 0 50px;
}

.sqo-posts-slider .swiper-wrapper {
    display: flex;
    align-items: stretch;
}

.sqo-posts-slider .swiper-slide {
    height: auto;
    display: flex;
}

/* ====================================
   Post Card
   ==================================== */
.sqo-post-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    width: 100%;
}

/* Card Hover: None */
.sqo-hover-none .sqo-post-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Card Hover: Lift */
.sqo-hover-lift .sqo-post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.2);
}

/* Card Hover: Scale */
.sqo-hover-scale .sqo-post-card:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.sqo-post-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ====================================
   Post Image
   ==================================== */
.sqo-post-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f5f5f5;
    /* Default: Desktop aspect ratio */
    aspect-ratio: calc(1 / var(--aspect-desktop, 1.3333));
}

/* Tablet breakpoint */
@media (max-width: 1024px) {
    .sqo-post-image {
        aspect-ratio: calc(1 / var(--aspect-tablet, 1.3333));
    }
}

/* Mobile breakpoint */
@media (max-width: 767px) {
    .sqo-post-image {
        aspect-ratio: calc(1 / var(--aspect-mobile, 1));
    }
}

.sqo-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
}

/* Image Hover: Zoom */
.sqo-img-hover-zoom .sqo-post-card:hover .sqo-post-image img {
    transform: scale(1.1);
}

/* Image Hover: Fade */
.sqo-img-hover-fade .sqo-post-card:hover .sqo-post-image img {
    opacity: 0.7;
}

/* No image placeholder */
.sqo-post-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.sqo-post-no-image .dashicons {
    font-size: 48px;
    color: rgba(255,255,255,0.5);
    width: 48px;
    height: 48px;
}

/* ====================================
   Brand Logo Styling (for Jobs)
   ==================================== */
.sqo-brand-image {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.sqo-brand-image img.sqo-brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Default: contain */
    object-position: center;
}

/* Cover style: Fill area completely */
.sqo-brand-image.sqo-brand-cover img.sqo-brand-logo {
    object-fit: cover;
    padding: 0;
}

/* Contain style: Full logo visible with padding */
.sqo-brand-image.sqo-brand-contain {
    padding: 30px;
}

.sqo-brand-image.sqo-brand-contain img.sqo-brand-logo {
    object-fit: contain;
}

/* Featured badge */
.sqo-post-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: #000;
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    z-index: 10;
}

/* ====================================
   Post Content
   ==================================== */
.sqo-post-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.sqo-post-category {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sqo-post-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    color: #000;
    transition: color 0.3s ease;
}

.sqo-post-card:hover .sqo-post-title {
    color: #667eea;
}

.sqo-post-excerpt {
    font-size: 15px;
    line-height: 1.6;
    color: #666;
    flex: 1;
}

/* ====================================
   Post Meta
   ==================================== */
.sqo-post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: #999;
    border-top: none;  /* Default: ingen border (Elementor control overridar) */
    padding-top: 0;
}

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

.sqo-post-meta .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ====================================
   Read More Button
   ==================================== */
.sqo-post-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #000;
    color: #fff;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    align-self: flex-start;
    margin-top: auto;
}

.sqo-post-card:hover .sqo-post-button {
    background: #667eea;
    transform: translateX(4px);
}

.sqo-post-button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ====================================
   Button Layout: Beside Title
   ==================================== */
.sqo-title-button-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sqo-title-button-row .sqo-post-title {
    flex: 1;
    margin: 0;
    min-width: 0; /* Allow text truncation */
}

.sqo-button-beside-title {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 16px;
    font-size: 13px;
    margin-top: 0;
}

/* Mobile: Stack button below title */
@media (max-width: 600px) {
    .sqo-title-button-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sqo-button-beside-title {
        align-self: flex-start;
    }
}

/* ====================================
   Button Layout: Over Image
   ==================================== */
.sqo-button-over-image {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 0;
}

.sqo-post-card:hover .sqo-button-over-image {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* ====================================
   Slider Navigation
   ==================================== */
.sqo-posts-slider .swiper-button-prev,
.sqo-posts-slider .swiper-button-next {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.sqo-posts-slider .swiper-button-prev:hover,
.sqo-posts-slider .swiper-button-next:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.sqo-posts-slider .swiper-button-prev::after,
.sqo-posts-slider .swiper-button-next::after {
    font-size: 20px;
    font-weight: bold;
    color: #000;
}

/* Arrows Outside */
.sqo-arrows-outside .swiper {
    margin: 0 60px;
}

.sqo-arrows-outside .swiper-button-prev {
    left: -60px;
}

.sqo-arrows-outside .swiper-button-next {
    right: -60px;
}

/* Arrows Bottom */
.sqo-arrows-bottom .swiper {
    padding-bottom: 80px;
}

.sqo-arrows-bottom .swiper-button-prev,
.sqo-arrows-bottom .swiper-button-next {
    top: auto;
    bottom: 10px;
}

.sqo-arrows-bottom .swiper-button-prev {
    left: calc(50% - 60px);
}

.sqo-arrows-bottom .swiper-button-next {
    right: calc(50% - 60px);
}

/* ====================================
   Slider Pagination
   ==================================== */
.sqo-posts-slider .swiper-pagination {
    bottom: 10px;
}

.sqo-posts-slider .swiper-pagination-bullet {
    width: 10px;
    height: 10px;
    background: #000;
    opacity: 0.3;
    transition: all 0.3s ease;
}

.sqo-posts-slider .swiper-pagination-bullet-active {
    opacity: 1;
    transform: scale(1.2);
}

/* ====================================
   Empty State
   ==================================== */
.sqo-no-posts {
    text-align: center;
    padding: 60px 20px;
    background: #f8f8f8;
    border-radius: 8px;
    color: #666;
}

/* ====================================
   Mobile Responsiveness
   ==================================== */
@media (max-width: 767px) {
    .sqo-post-content {
        padding: 20px;
        gap: 10px;
    }
    
    .sqo-post-title {
        font-size: 18px;
    }
    
    .sqo-post-excerpt {
        font-size: 14px;
    }
    
    .sqo-post-meta {
        font-size: 12px;
        gap: 12px;
    }
    
    .sqo-post-button {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .sqo-posts-slider .swiper {
        padding: 10px 0 40px;
    }
    
    /* FIX: Visa pilar på mobil men gör dem mindre */
    .sqo-posts-slider .swiper-button-prev,
    .sqo-posts-slider .swiper-button-next {
        width: 36px;
        height: 36px;
    }
    
    .sqo-posts-slider .swiper-button-prev::after,
    .sqo-posts-slider .swiper-button-next::after {
        font-size: 16px;
    }
    
    .sqo-arrows-outside .swiper {
        margin: 0;
    }
    
    .sqo-posts-pagination a,
    .sqo-posts-pagination .current,
    .sqo-posts-pagination .page-numbers {
        min-width: 36px;
        height: 36px;
        font-size: 14px;
    }
}