/* CLS Optimization - Cumulative Layout Shift Prevention */

/* ===== Logo Stability ===== */
.logo-img {
    width: 160px !important;
    height: 45px !important;
    object-fit: contain;
    display: block;
}

@media (max-width: 768px) {
    .logo-img {
        width: 120px !important;
        height: 35px !important;
    }
}

/* ===== Banner Section Stability ===== */
.banner-section {
    min-height: 500px; /* Reserve space */
    position: relative;
}

.banner-section::before {
    content: '';
    display: block;
    width: 100%;
    height: 500px;
    background: linear-gradient(135deg, #1a1f35 0%, #2a1f62 100%);
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
}

/* ===== Cookie Card Stability ===== */
.cookies-card {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-width: calc(100vw - 40px);
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.cookies-card.show {
    transform: translateY(0);
    opacity: 1;
}

/* ===== Modal Stability ===== */
.modal {
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    transform: translateY(-50px);
    transition: transform 0.3s ease;
}

.modal.show .modal-dialog {
    transform: translateY(0);
}

/* ===== Currency Images Stability ===== */
.currency-icon {
    width: 24px !important;
    height: 24px !important;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

/* ===== Contact Icons Stability ===== */
.header-info img[alt="icon"] {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

/* ===== Font Loading Stability ===== */
body {
    font-display: swap;
}

/* Reserve space for web fonts */
.font-loading {
    visibility: hidden;
}

.fonts-loaded .font-loading {
    visibility: visible;
}

/* ===== Prevent Flash of Unstyled Content ===== */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Image Placeholder ===== */
img:not([src]):not([srcset]) {
    visibility: hidden;
}

img[loading="lazy"] {
    min-height: 1px; /* Prevent layout shift */
}

/* ===== Skeleton Loading States ===== */
.skeleton {
    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;
    }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 4px;
}

/* ===== Reduce Layout Thrashing ===== */
* {
    box-sizing: border-box;
}

/* Force GPU acceleration for smooth animations */
.header,
.banner-section,
.cookies-card,
.modal {
    will-change: transform;
    transform: translateZ(0);
}

/* ===== Critical Above-the-fold Styles ===== */
.header {
    height: 80px; /* Fixed height */
    position: relative;
    z-index: 999;
}

.header-bottom {
    padding: 15px 0;
    min-height: 80px;
    display: flex;
    align-items: center;
}

/* ===== Prevent Content Jumping ===== */
.main-content {
    min-height: calc(100vh - 80px); /* Account for header */
}

/* ===== Optimize for Core Web Vitals ===== */
.cls-optimized {
    contain: layout style paint;
}

/* ===== Responsive Image Containers ===== */
.img-container {
    position: relative;
    overflow: hidden;
}

.img-container::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
