/**
 * CLS (Cumulative Layout Shift) Prevention CSS
 * 
 * Critical fixes to prevent layout shifts across all templates
 * Adds explicit dimensions, min-heights, and aspect-ratios
 * 
 * @package Israel_News_Theme
 * @since 1.0.0
 */

/* ==========================================
   CRITICAL: Content Container Min-Heights
   Prevents shifts during JS content loading
   ========================================== */

/* CRITICAL: Elementor Container Wrapping Directory Pages */
/* This fixes the 0.578 CLS issue on directory pages */
/* Target specific directory pages by URL/slug */
body[class*="partnerships"] .elementor-widget-shortcode,
body[class*="partnerships"] .e-con,
body[class*="honorary-consuls"] .elementor-widget-shortcode,
body[class*="honorary-consuls"] .e-con,
body[class*="companies"] .elementor-widget-shortcode,
body[class*="companies"] .e-con,
body[class*="cryptocurrency"] .elementor-widget-shortcode,
body[class*="cryptocurrency"] .e-con,
body[class*="banks"] .elementor-widget-shortcode,
body[class*="banks"] .e-con,
body[class*="beach"] .elementor-widget-shortcode,
body[class*="beach"] .e-con,
body[class*="driving-school"] .elementor-widget-shortcode,
body[class*="driving-school"] .e-con,
body[class*="circumciser"] .elementor-widget-shortcode,
body[class*="circumciser"] .e-con,
body[class*="shabbat"] .elementor-widget-shortcode,
body[class*="shabbat"] .e-con,
body[class*="press-release"] .elementor-widget-shortcode,
body[class*="press-release"] .e-con,
body[class*="public-benefit"] .elementor-widget-shortcode,
body[class*="public-benefit"] .e-con {
    min-height: 1400px !important; /* Prevent collapse of Elementor containers */
}

/* Mobile - smaller min-height */
@media (max-width: 768px) {
    body[class*="partnerships"] .elementor-widget-shortcode,
    body[class*="partnerships"] .e-con,
    body[class*="honorary-consuls"] .elementor-widget-shortcode,
    body[class*="honorary-consuls"] .e-con,
    body[class*="companies"] .elementor-widget-shortcode,
    body[class*="companies"] .e-con,
    body[class*="cryptocurrency"] .elementor-widget-shortcode,
    body[class*="cryptocurrency"] .e-con,
    body[class*="banks"] .elementor-widget-shortcode,
    body[class*="banks"] .e-con,
    body[class*="beach"] .elementor-widget-shortcode,
    body[class*="beach"] .e-con,
    body[class*="driving-school"] .elementor-widget-shortcode,
    body[class*="driving-school"] .e-con,
    body[class*="circumciser"] .elementor-widget-shortcode,
    body[class*="circumciser"] .e-con,
    body[class*="shabbat"] .elementor-widget-shortcode,
    body[class*="shabbat"] .e-con,
    body[class*="press-release"] .elementor-widget-shortcode,
    body[class*="press-release"] .e-con,
    body[class*="public-benefit"] .elementor-widget-shortcode,
    body[class*="public-benefit"] .e-con {
        min-height: 1200px !important;
    }
}

/* Directory Page Containers */
#contentContainer {
    min-height: 800px;
    background: transparent;
    transition: min-height 0.3s ease;
}

#contentContainer.loaded {
    min-height: auto; /* Remove once content is loaded */
}

/* Grid Layouts */
.israel-consuls-grid,
.israel-companies-grid,
.israel-beaches-grid,
.israel-schools-grid,
.israel-crypto-grid,
.israel-partnerships-grid,
.israel-shabbat-grid,
.israel-circumcisers-grid,
.israel-banks-grid,
.israel-exchange-grid,
.israel-releases-grid {
    min-height: 600px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

/* ==========================================
   Card Containers - Fixed Heights
   Prevents shifts as cards load
   ========================================== */

.israel-consul-card,
.israel-company-card,
.israel-beach-card,
.israel-school-card,
.israel-crypto-card,
.israel-partnership-card,
.israel-shabbat-card,
.israel-circumciser-card,
.israel-bank-card,
.israel-exchange-card,
.israel-release-card {
    min-height: 320px;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Mobile Card Heights */
@media (max-width: 768px) {
    .israel-consul-card,
    .israel-company-card,
    .israel-beach-card,
    .israel-school-card,
    .israel-crypto-card,
    .israel-partnership-card,
    .israel-shabbat-card,
    .israel-circumciser-card,
    .israel-bank-card,
    .israel-exchange-card,
    .israel-release-card {
        min-height: 280px;
    }
}

/* ==========================================
   Image Containers - Aspect Ratios
   Prevents shifts during image loading
   ========================================== */

/* Logo/Icon Containers */
.company-logo-container,
.crypto-logo-container,
.partner-logo-container {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.company-logo-container img,
.crypto-logo-container img,
.partner-logo-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    aspect-ratio: 1 / 1;
}

/* Press Release Images */
.nw-release-img {
    width: 110px !important;
    height: 70px !important;
    aspect-ratio: 110 / 70 !important;
    object-fit: cover !important;
}

/* Flag Images */
.boi-flag-img {
    width: 24px !important;
    height: 16px !important;
    aspect-ratio: 3 / 2 !important;
    object-fit: cover !important;
}

/* Cryptocurrency Logos */
.trending-logo,
.coin-logo {
    width: 28px !important;
    height: 28px !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: cover !important;
    border-radius: 50%;
}

/* ==========================================
   Hero Section - Prevent Header Shifts
   ========================================== */

.israel-hero-section {
    min-height: 400px;
    background: #ffffff;
    padding: 3rem 1rem 2rem;
    margin-bottom: 2rem;
}

.israel-hero-content {
    max-width: 900px;
    margin: 0 auto;
}

.israel-hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
    min-height: 120px;
}

.israel-stat-card {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1.5rem 1rem;
    text-align: center;
    min-height: 100px;
}

/* Mobile Hero */
@media (max-width: 768px) {
    .israel-hero-section {
        min-height: 350px;
        padding: 2rem 1rem 1.5rem;
    }
    .israel-hero-stats {
        min-height: 100px;
    }
    .israel-stat-card {
        min-height: 80px;
    }
}

/* ==========================================
   Loading States - Skeleton Loaders
   ========================================== */

.israel-loading {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.israel-loading-spinner {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   Filter Sections - Prevent Collapse
   ========================================== */

.israel-filters {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    min-height: 100px;
}

.israel-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ==========================================
   Table Containers - Prevent Shift
   ========================================== */

.israel-table-container {
    min-height: 400px;
    overflow-x: auto;
}

.israel-table-container table {
    width: 100%;
    border-collapse: collapse;
}

/* ==========================================
   Single Page Templates - Content Areas
   ========================================== */

.single-consul-container,
.single-company-container,
.single-beach-container,
.single-school-container,
.single-crypto-container,
.single-partnership-container,
.single-shabbat-container,
.single-circumciser-container,
.single-benefit-container {
    min-height: 600px;
}

.single-hero-section {
    min-height: 300px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 1rem;
}

.single-content-area {
    min-height: 400px;
    padding: 2rem 1rem;
}

/* Mobile Single Pages */
@media (max-width: 768px) {
    .single-consul-container,
    .single-company-container,
    .single-beach-container,
    .single-school-container,
    .single-crypto-container,
    .single-partnership-container,
    .single-shabbat-container,
    .single-circumciser-container,
    .single-benefit-container {
        min-height: 500px;
    }
    .single-hero-section {
        min-height: 250px;
        padding: 2rem 1rem;
    }
    .single-content-area {
        min-height: 350px;
    }
}

/* ==========================================
   Info Cards - Consistent Sizing
   ========================================== */

.israel-info-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-height: 150px;
}

.israel-detail-card {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    min-height: 120px;
}

/* ==========================================
   Responsive Grid Adjustments
   ========================================== */

@media (max-width: 1200px) {
    .israel-consuls-grid,
    .israel-companies-grid,
    .israel-beaches-grid,
    .israel-schools-grid,
    .israel-crypto-grid,
    .israel-partnerships-grid,
    .israel-shabbat-grid,
    .israel-circumcisers-grid,
    .israel-banks-grid,
    .israel-exchange-grid,
    .israel-releases-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    #contentContainer {
        min-height: 600px;
    }
    
    .israel-consuls-grid,
    .israel-companies-grid,
    .israel-beaches-grid,
    .israel-schools-grid,
    .israel-crypto-grid,
    .israel-partnerships-grid,
    .israel-shabbat-grid,
    .israel-circumcisers-grid,
    .israel-banks-grid,
    .israel-exchange-grid,
    .israel-releases-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        min-height: 500px;
    }
}

/* ==========================================
   Prevent FOUC - Ensure Visibility
   ========================================== */

html, body {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==========================================
   Performance: Contain Layout Changes
   ========================================== */

.israel-consul-card,
.israel-company-card,
.israel-beach-card,
.israel-school-card,
.israel-crypto-card,
.israel-partnership-card,
.israel-shabbat-card,
.israel-circumciser-card,
.israel-bank-card,
.israel-exchange-card,
.israel-release-card {
    contain: layout style;
    content-visibility: auto;
}

/* ==========================================
   Image Placeholders
   ========================================== */

.image-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

