/*
Responsive Design Enhancements
Advanced Mobile-First Responsive Styles
*/

/* Extra Small Devices (Phones, less than 576px) */
@media (max-width: 575.98px) {
    .container {
        padding: 0 15px;
    }
    
    .site-header {
        padding: 0.5rem 0;
    }
    
    .header-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    .main-nav ul {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        flex-direction: column;
        padding: 1rem;
        gap: 0.5rem;
        z-index: 999;
    }
    
    .main-nav.active ul {
        display: flex;
    }
    
    .mobile-menu-toggle {
        display: block !important;
    }
    
    .hero-slider {
        height: 300px;
        margin-top: 90px;
    }
    
    .slide-title {
        font-size: 1.5rem !important;
    }
    
    .slide-description {
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }
    
    .slide-btn {
        padding: 10px 20px !important;
        font-size: 0.9rem !important;
    }
    
    .slider-nav {
        width: 35px !important;
        height: 35px !important;
        font-size: 1rem !important;
    }
    
    .slider-prev {
        left: 10px !important;
    }
    
    .slider-next {
        right: 10px !important;
    }
    
    .section-title {
        font-size: 1.8rem !important;
        margin-bottom: 2rem !important;
    }
    
    .features-grid,
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .feature-card,
    .product-card {
        padding: 1.5rem !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
    }
    
    .stat-number {
        font-size: 2rem !important;
    }
    
    .testimonials-grid,
    .blog-grid {
        grid-template-columns: 1fr !important;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        text-align: center !important;
        gap: 1.5rem !important;
    }
    
    .newsletter-form {
        max-width: 100% !important;
    }
    
    .quick-view-content {
        width: 95% !important;
        margin: 1rem !important;
        max-height: 90vh !important;
    }
    
    .quick-view-product {
        flex-direction: column !important;
    }
    
    .search-container {
        width: 95% !important;
        top: 50px !important;
    }
    
    .search-input {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .notification {
        min-width: 280px !important;
        margin: 0 10px !important;
    }
}

/* Small Devices (Landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .hero-slider {
        height: 400px;
        margin-top: 100px;
    }
    
    .slide-title {
        font-size: 2rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .testimonials-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium Devices (Tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .hero-slider {
        height: 500px;
    }
    
    .slide-title {
        font-size: 2.5rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large Devices (Desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .blog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Extra Large Devices (Large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-slider {
        height: 700px;
    }
    
    .slide-title {
        font-size: 3.5rem;
    }
    
    .slide-description {
        font-size: 1.3rem;
    }
}

/* Landscape Orientation Specific */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-slider {
        height: 100vh;
    }
    
    .slide-content {
        padding: 1rem;
    }
    
    .slide-title {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .slide-description {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .feature-icon,
    .slider-nav {
        -webkit-font-smoothing: antialiased;
    }
}

/* Print Styles */
@media print {
    .site-header,
    .hero-slider,
    .site-footer,
    .back-to-top,
    .slider-controls,
    .slider-nav,
    .add-to-cart-btn {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    .section-title {
        color: #000 !important;
        font-size: 1.5rem !important;
    }
    
    .feature-card,
    .product-card {
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }
    
    a:after {
        content: " (" attr(href) ")";
        font-size: 0.8rem;
        color: #666;
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .slide {
        transition: none !important;
    }
    
    .feature-card:hover,
    .product-card:hover {
        transform: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .site-header {
        background: #1a1a1a;
        color: #fff;
    }
    
    .main-nav a {
        color: #fff;
    }
    
    .main-nav a:hover {
        color: #e74c3c;
    }
    
    .feature-card,
    .product-card {
        background: #2a2a2a;
        color: #fff;
    }
    
    .testimonial-card {
        background: #2a2a2a;
        color: #fff;
    }
    
    .blog-card {
        background: #2a2a2a;
        color: #fff;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .feature-card:hover,
    .product-card:hover,
    .testimonial-card:hover {
        transform: none;
    }
    
    .add-to-cart-btn,
    .slide-btn {
        min-height: 44px; /* iOS recommended minimum touch target */
        min-width: 44px;
    }
    
    .slider-nav {
        min-height: 44px;
        min-width: 44px;
    }
    
    .back-to-top {
        width: 60px;
        height: 60px;
    }
}

/* Focus Styles for Accessibility */
.slide-btn:focus,
.add-to-cart-btn:focus,
.newsletter-form button:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 2px solid #e74c3c;
    outline-offset: 2px;
}

/* Skip Link for Screen Readers */
.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999999;
    padding: 8px 16px;
    background: #000;
    color: #fff;
    text-decoration: none;
}

.skip-link:focus {
    left: 6px;
    top: 7px;
}

/* Loading States */
.loading {
    display: inline-block;
    position: relative;
}

.loading:after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #e74c3c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.error {
    background: #ffebee;
    color: #c62828;
    padding: 1rem;
    border-radius: 5px;
    border-left: 4px solid #c62828;
}

.success {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 1rem;
    border-radius: 5px;
    border-left: 4px solid #2e7d32;
}

/* Performance Optimizations */
.feature-card,
.product-card,
.testimonial-card {
    will-change: transform;
}

.slide {
    will-change: opacity;
}

/* Browser Specific Fixes */
/* Safari */
@supports (-webkit-appearance: none) {
    .newsletter-form input[type="email"] {
        -webkit-appearance: none;
        border-radius: 5px;
    }
}

/* Firefox */
@-moz-document url-prefix() {
    .feature-card,
    .product-card {
        background-clip: padding-box;
    }
}

/* IE11 Fallbacks */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .features-grid,
    .products-grid {
        display: -ms-flexbox;
        -ms-flex-wrap: wrap;
    }
    
    .feature-card,
    .product-card {
        -ms-flex: 0 0 calc(33.333% - 1rem);
        flex: 0 0 calc(33.333% - 1rem);
    }
}
