/* Theme22 Critical CSS for Maximum SEO Performance */
/* Inline critical styles to prevent render blocking and layout shifts */

/* 1. Above-the-fold Critical Styles with Layout Stability */
body {
    font-family: 'DM Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #fff;
    font-display: swap;
    scroll-behavior: smooth;
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    contain: layout style;
}

/* Prevent layout shifts with proper sizing */
img {
    display: block;
    max-width: 100%;
    height: auto;
    aspect-ratio: attr(width) / attr(height);
    object-fit: cover;
    font-family: 'object-fit: cover'; /* Fallback */
    /*background-color: #f3f4f6;*/
}

/* Logo image sizing with stable aspect ratio */
img[alt="Company Logo"],
header img,
.header img {
    width: auto;
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: 55px;
    max-height: 55px;
    min-width: 35px;
    min-height: 35px;
    contain: layout style;
}

@media (min-width: 768px) {
    img[alt="Company Logo"],
    header img,
    .header img {
        max-width: 55px;
        max-height: 55px;
    }
}

@media (max-width: 767px) {
    img[alt="Company Logo"],
    header img,
    .header img {
        max-width: 35px;
        max-height: 35px;
    }
}

.responsive-img {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    object-fit: cover;
    background-color: #f3f4f6;
    transition: opacity 0.3s ease;
    contain: layout style;
}

/* Header Critical Styles with CLS prevention */
.header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    min-height: 80px;
    max-height: 100px;
    contain: layout style paint;
    display: flex;
    align-items: center;
    will-change: none;
    overflow: hidden;
}

header {
    contain: layout style paint;
    min-height: 80px;
    max-height: 100px;
    overflow: hidden;
}

header .container {
    min-height: 80px;
    display: flex;
    align-items: center;
    contain: layout;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    max-width: 1200px;
    margin: 0 auto;
    contain: layout style;
    min-height: 80px;
}

/* Logo container stabilization */
.logo-container,
header a[href*="Home"],
header a[href*="Index"] {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 55px;
    min-height: 80px;
    contain: layout;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--theme-primary-color, #667eea);
    text-decoration: none;
    contain: layout;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-link {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    position: relative;
    transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link:focus {
    color: var(--theme-primary-color, #667eea);
}

/* Hero Section Critical Styles */
.hero {
    min-height: 60vh;
    background: linear-gradient(135deg, var(--theme-primary-color, #667eea) 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    margin-top: 70px;
    contain: layout style paint;
}

.hero-content {
    max-width: 800px;
    padding: 2rem;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero p {
    font-size: clamp(1rem, 2vw, 1.25rem);
    margin-bottom: 2rem;
    opacity: 0.95;
}

/* Button Critical Styles */
.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    line-height: 1;
}

.btn-primary {
    background: linear-gradient(45deg, #fff, #f8f9fa);
    color: var(--theme-primary-color, #667eea);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* Container Critical Styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.section {
    padding: 4rem 0;
}

/* Remove top padding and margin from first section after main */
main > .section:first-child,
main > section:first-child {
    padding-top: 0;
    margin-top: 0;
}

/* Grid Critical Styles */
.car-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* Car Card Critical Styles */
.car-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    contain: layout style paint;
}

.car-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.car-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f3f4f6;
}

.car-details {
    padding: 1.5rem;
}

.car-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.car-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--theme-primary-color, #667eea);
    margin-bottom: 0.5rem;
}

.car-specs {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 1rem;
}

/* Loading Critical Styles */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Accessibility Critical Styles */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
*:focus-visible {
    outline: 2px solid var(--theme-primary-color, #667eea);
    outline-offset: 2px;
}

/* Mobile Critical Styles */
@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    .hero {
        min-height: 50vh;
        padding: 2rem 0;
    }
    
    .car-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .section {
        padding: 2rem 0;
    }
    
    /* Remove top padding and margin from first section after main on mobile */
    main > .section:first-child,
    main > section:first-child {
        padding-top: 0;
        margin-top: 0;
    }
}

/* Performance Critical Styles */
img {
    max-width: 100%;
    height: auto;
}

.car-image {
    content-visibility: auto;
    contain-intrinsic-size: 300px 200px;
}

/* Print Critical Styles */
@media print {
    .header,
    .btn,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .hero {
        margin-top: 0;
        min-height: auto;
        padding: 1rem 0;
    }
    
    .car-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .car-card {
        border: 2px solid #000;
    }
    
    .btn-primary {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .skeleton {
        animation: none;
        background: #f0f0f0;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #fff;
    }
    
    .header {
        background: #2a2a2a;
        border-bottom: 1px solid #404040;
    }
    
    .car-card {
        background: #2a2a2a;
        color: #fff;
    }
    
    .skeleton {
        background: linear-gradient(90deg, #404040 25%, #505050 50%, #404040 75%);
    }
}