/* Performance Optimized CSS */
/* This file contains optimized styles for better performance */

/* === Critical Performance Styles === */

/* Reduce layout thrashing */
* {
    box-sizing: border-box;
}

/* Optimize font loading */
@font-face {
    font-family: 'IRANSans';
    src: url('/fonts/IRANSans/IRANSansWeb_FaNum_Medium.woff2') format('woff2'),
         url('/fonts/IRANSans/IRANSansWeb_FaNum_Medium.woff') format('woff');
    font-display: swap; /* Improve font loading performance */
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'IRANSans';
    src: url('/fonts/IRANSans/IRANSansWeb_FaNum_Bold.woff2') format('woff2'),
         url('/fonts/IRANSans/IRANSansWeb_FaNum_Bold.woff') format('woff');
    font-display: swap; /* Improve font loading performance */
    font-weight: bold;
    font-style: normal;
}

/* === GPU Acceleration for Animations === */
.navbar,
.card,
.btn,
.location-item,
.category-filter-item {
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden;
}

/* === Optimized Transitions === */
.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
}

.btn:hover,
.nav-link:hover,
.location-item:hover {
    transform: translateY(-2px) translateZ(0);
    transition: transform 0.2s ease-out;
}

/* === Efficient Animations === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translate3d(30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

/* === Optimized Card Styles === */
.card-optimized {
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    background: #ffffff;
    border: none;
    overflow: hidden;
}

.card-optimized:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(-4px) translateZ(0);
}

/* === Optimized Button Styles === */
.btn-modern {
    border-radius: 8px;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0.025em;
}

.btn-primary-modern {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary-modern:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary-modern {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-secondary-modern:hover {
    background: linear-gradient(135deg, #ee82f0 0%, #f34960 100%);
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 10px 20px rgba(240, 147, 251, 0.4);
}

/* === Optimized Form Styles === */
.form-control-modern {
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
}

.form-control-modern:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

/* === Loading States === */
.loading-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;
    }
}

/* === Enhanced Mobile Responsive Design === */

/* Mobile First Approach - Base styles for mobile */
.container-mobile {
    padding-left: 10px;
    padding-right: 10px;
}

/* Touch-friendly elements */
.touch-friendly {
    min-height: 44px;
    min-width: 44px;
    padding: 12px;
}

.btn-mobile {
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
    min-height: 48px;
}

/* Mobile card optimizations */
.card-mobile {
    margin-bottom: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Mobile typography */
.mobile-text {
    font-size: 16px;
    line-height: 1.5;
}

.mobile-heading {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* === Tablet Styles === */
@media (min-width: 576px) and (max-width: 991px) {
    .container-mobile {
        padding-left: 15px;
        padding-right: 15px;
    }

    .card-optimized {
        margin-bottom: 20px;
    }

    .btn-modern {
        padding: 12px 24px;
        font-size: 15px;
    }

    /* Two column layout for tablets */
    .tablet-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}

/* === Mobile Styles === */
@media (max-width: 575px) {
    .card-optimized {
        margin-bottom: 16px;
        border-radius: 8px;
    }

    .btn-modern {
        padding: 10px 20px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 8px;
    }

    /* Single column layout */
    .mobile-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Reduce animations on mobile for better performance */
    .smooth-transition,
    .btn:hover,
    .nav-link:hover,
    .location-item:hover {
        transition: none;
        transform: none;
    }

    /* Mobile navigation improvements */
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e0e0e0;
        padding: 8px 0;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px;
        text-decoration: none;
        color: #666;
        font-size: 12px;
        transition: color 0.2s ease;
    }

    .mobile-nav-item.active {
        color: #667eea;
    }

    .mobile-nav-item i {
        font-size: 18px;
        margin-bottom: 4px;
    }

    /* Add bottom padding to body to account for fixed mobile nav */
    body.mobile-nav-active {
        padding-bottom: 70px;
    }

    /* Mobile overlays */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9999;
        display: flex;
        align-items: flex-end;
    }

    .mobile-overlay-content {
        background: white;
        width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 80vh;
        overflow-y: auto;
        animation: slideUpMobile 0.3s ease-out;
    }

    .mobile-overlay-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-bottom: 1px solid #e0e0e0;
        background: #f8f9fa;
        border-radius: 20px 20px 0 0;
    }

    .mobile-overlay-body {
        padding: 20px;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    /* Touch feedback */
    .touch-feedback {
        transition: transform 0.1s ease;
    }

    .touch-feedback:active {
        transform: scale(0.95);
    }

    /* Improved touch targets */
    .mobile-touch-target {
        min-height: 48px;
        min-width: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* === Print Optimizations === */
@media print {
    .navbar,
    .btn,
    .advertisement,
    .text-ad-container {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    * {
        background: transparent !important;
        color: black !important;
    }
}

/* === Accessibility Improvements === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card-optimized {
        border: 2px solid #000;
    }

    .btn-modern {
        border: 2px solid #000;
    }
}

/* === Performance Critical Utilities === */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.hardware-accelerated {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

/* === Container Optimizations === */
.container-fluid-optimized {
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 1200px) {
    .container-fluid-optimized {
        max-width: 1140px;
    }
}

/* === Grid Optimizations === */
.grid-optimized {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (max-width: 768px) {
    .grid-optimized {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}
