/* EESTI KOOSTÖÖ KOGU - ALAMLEHED PLUGIN */

/* RESET JA PÕHILINE KONTROLL */
.ek-alamlehed-container * {
    box-sizing: border-box !important;
}

/* KONTEINER - TÄIELIK KESKELE JOONDAMINE */
.ek-alamlehed-container {
    margin: 40px 0 !important;
    padding: 0 !important;
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    text-align: center !important;
}

.ek-alamlehed-globaalne,
.ek-alamlehed-taies-laiuses {
    width: 100% !important;
    max-width: 1400px !important;
    padding: 0 20px !important;
    margin: 0 auto !important;
    display: flex !important;
    justify-content: center !important;
}

/* GRID - FLEX SKALEERUMINE */
.ek-alamlehed-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 15px !important;
    justify-content: center !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* KAARDID - VÕRDSELT JAOTATUD, AUTOMAATSELT SKALEERUVAD */
.ek-alamleht-kaart {
    background: #f4c58f !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    box-shadow: none !important;
    transition: all 0.3s ease !important;

    /* FLEX - kõik kaardid võrdselt */
    flex: 1 1 0 !important;
    min-width: 0 !important; /* Oluline! Laseb väiksemaks kahaneda */

    /* Fikseeritud kõrgus */
    height: 280px !important;

    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    margin: 0 !important;
}

.ek-alamleht-kaart:hover {
    transform: none !important;
    box-shadow: none !important;
}

.ek-alamleht-link {
    display: flex !important;
    flex-direction: column !important;
    text-decoration: none !important;
    color: inherit !important;
    height: 100% !important;
    width: 100% !important;
}

.ek-alamleht-pilt {
    height: 200px !important;
    overflow: hidden !important;
    background: #f8f9fa !important;
    flex-shrink: 0 !important;
    width: 100% !important;
}

.ek-alamleht-pilt img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: none !important;
}

.ek-alamleht-placeholder {
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #6c757d !important;
    font-size: 14px !important;
}

.ek-alamleht-placeholder::before {
    content: "📄" !important;
    font-size: 32px !important;
    opacity: 0.5 !important;
}

.ek-alamleht-sisu {
    padding: 15px !important;
    position: relative !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 80px !important;
    background: #f4c58f !important;
}

.ek-alamleht-pealkiri {
    margin: 0 0 10px 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #000 !important;
    line-height: 1.3 !important;
    flex-grow: 1 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    text-align: left !important;
}

.ek-alamleht-nool {
    position: absolute !important;
    bottom: 10px !important;
    left: 15px !important;
    font-size: 18px !important;
    color: #000 !important;
    transition: all 0.3s ease !important;
    font-weight: bold !important;
}

.ek-alamleht-kaart:hover .ek-alamleht-nool {
    transform: translateX(4px) !important;
    color: #000 !important;
}

/* CUSTOM LEHED */
.ek-alamleht-kaart.custom {
    border-left: 4px solid #28a745 !important;
}

/* LAADIMISE ANIMATSIOON */
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart {
    opacity: 0 !important;
    transform: translateY(20px) !important;
    animation: fadeInUp 0.6s ease forwards !important;
}

.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(1) { animation-delay: 0.1s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(2) { animation-delay: 0.2s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(3) { animation-delay: 0.3s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(4) { animation-delay: 0.4s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(5) { animation-delay: 0.5s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(6) { animation-delay: 0.6s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(7) { animation-delay: 0.7s !important; }
.ek-alamlehed-grid[data-loading="true"] .ek-alamleht-kaart:nth-child(8) { animation-delay: 0.8s !important; }

@keyframes fadeInUp {
    to {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }
}

/* RESPONSIVE - AGGRESSIIVNE SKALEERUMINE */
@media (max-width: 1200px) {
    .ek-alamlehed-grid {
        gap: 12px !important;
    }
    .ek-alamleht-kaart {
        height: 240px !important;
    }
    .ek-alamleht-pilt {
        height: 160px !important;
    }
    .ek-alamleht-pealkiri {
        font-size: 13px !important;
    }
}

@media (max-width: 900px) {
    .ek-alamlehed-globaalne,
    .ek-alamlehed-taies-laiuses {
        padding: 0 15px !important;
    }
    .ek-alamlehed-grid {
        gap: 10px !important;
    }
    .ek-alamleht-kaart {
        height: 220px !important;
    }
    .ek-alamleht-pilt {
        height: 140px !important;
    }
    .ek-alamleht-sisu {
        padding: 12px !important;
    }
    .ek-alamleht-pealkiri {
        font-size: 12px !important;
        -webkit-line-clamp: 2 !important;
    }
    .ek-alamleht-nool {
        font-size: 16px !important;
        bottom: 8px !important;
        left: 12px !important;
    }
}

@media (max-width: 600px) {
    .ek-alamlehed-globaalne,
    .ek-alamlehed-taies-laiuses {
        padding: 0 10px !important;
    }
    .ek-alamlehed-grid {
        gap: 8px !important;
    }
    .ek-alamleht-kaart {
        height: 180px !important;
    }
    .ek-alamleht-pilt {
        height: 110px !important;
    }
    .ek-alamleht-sisu {
        padding: 10px !important;
        min-height: 70px !important;
    }
    .ek-alamleht-pealkiri {
        font-size: 11px !important;
        margin-bottom: 8px !important;
        -webkit-line-clamp: 2 !important;
    }
    .ek-alamleht-nool {
        font-size: 14px !important;
        bottom: 6px !important;
        left: 10px !important;
    }
}

@media (max-width: 400px) {
    .ek-alamlehed-globaalne,
    .ek-alamlehed-taies-laiuses {
        padding: 0 5px !important;
    }
    .ek-alamlehed-grid {
        gap: 4px !important;
    }
    .ek-alamleht-kaart {
        height: 150px !important;
    }
    .ek-alamleht-pilt {
        height: 90px !important;
    }
    .ek-alamleht-sisu {
        padding: 8px !important;
        min-height: 60px !important;
    }
    .ek-alamleht-pealkiri {
        font-size: 9px !important;
        margin-bottom: 5px !important;
        -webkit-line-clamp: 2 !important;
    }
    .ek-alamleht-nool {
        font-size: 12px !important;
        bottom: 5px !important;
        left: 8px !important;
    }
}

/* PRINT STIILID */
@media print {
    .ek-alamlehed-container {
        width: 100% !important;
    }

    .ek-alamlehed-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .ek-alamleht-kaart {
        border: 1px solid #ddd !important;
        break-inside: avoid !important;
        flex: 1 1 300px !important;
        height: auto !important;
        max-width: 300px !important;
    }

    .ek-alamleht-nool {
        display: none !important;
    }
}
