/* ===============================
   RESPONSIVE DESIGN
=============================== */

/* Mobile First Approach */

/* Base styles are mobile-first (up to 767px) */

/* ===============================
   TABLET STYLES (768px - 1023px)
=============================== */

@media (min-width: 768px) {
    /* Container adjustments */
    .container {
        padding: 0 30px;
    }

    /* Navigation */
    .nav-list {
        gap: 1.5rem;
    }

    .nav-link {
        font-size: 0.95rem;
    }

    /* Hero section */
    .hero-title {
        font-size: 3.5rem;
    }

    .hero-subtitle {
        font-size: 1.2rem;
    }

    .hero-buttons {
        gap: 1.5rem;
    }

    /* Section headers */
    .section-title {
        font-size: 2.5rem;
    }

    .section-subtitle {
        font-size: 1.15rem;
    }

    /* Products grid */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    /* Services grid */
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    /* About section */
    .about-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .about-text .section-header {
        text-align: center;
    }

    .about-text .section-title::after {
        left: 50%;
        transform: translateX(-50%);
    }

    /* Contact section */
    .contact-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .footer-bottom {
        flex-direction: row;
        text-align: left;
    }

    /* Product quick view modal */
    .product-quickview {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Cart modal */
    .cart-modal {
        width: 450px;
    }
}

/* ===============================
   DESKTOP STYLES (1024px+)
=============================== */

@media (min-width: 1024px) {
    /* Container adjustments */
    .container {
        padding: 0 40px;
    }

    /* Navigation */
    .nav-list {
        gap: 2.5rem;
    }

    /* Hero section */
    .hero-content {
        max-width: 900px;
    }

    .hero-title {
        font-size: 4rem;
    }

    .hero-subtitle {
        font-size: 1.3rem;
    }

    /* Products grid */
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }

    /* Services grid */
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* About section */
    .about-content {
        grid-template-columns: 1fr 1fr;
        gap: 4rem;
    }

    .about-text .section-header {
        text-align: left;
    }

    .about-text .section-title::after {
        left: 0;
        transform: none;
    }

    /* Contact section */
    .contact-content {
        grid-template-columns: 1fr 1fr;
        gap: 4rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Product quick view modal */
    .product-quickview {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    /* Hover effects for desktop */
    .product-card {
        cursor: pointer;
    }

    .service-card {
        cursor: pointer;
    }

    /* Enhanced animations for desktop */
    .product-card:hover {
        transform: translateY(-15px);
    }

    .service-card:hover {
        transform: translateY(-15px);
    }
}

/* ===============================
   LARGE DESKTOP (1200px+)
=============================== */

@media (min-width: 1200px) {
    /* Container max width */
    .container {
        max-width: 1200px;
        padding: 0 20px;
    }

    /* Products grid */
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Services grid */
    .services-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Hero section */
    .hero-title {
        font-size: 4.5rem;
    }

    /* Section titles */
    .section-title {
        font-size: 3rem;
    }
}

/* ===============================
   MOBILE SPECIFIC STYLES (up to 767px)
=============================== */

@media (max-width: 767px) {
    /* Hide desktop navigation, show mobile menu */
    /* Overlay detrás del menú (el menú vive dentro del header) */
    .overlay.menu-backdrop.active {
        z-index: 2900;
        pointer-events: auto;
    }

    .header.menu-open {
        z-index: 3000;
    }

    .nav-menu {
        position: fixed;
        top: 80px;
        left: 0;
        width: 100%;
        height: calc(100vh - 80px);
        height: calc(100dvh - 80px);
        background: var(--white);
        transform: translateX(-100%);
        transition: var(--transition-medium);
        z-index: 3001;
        box-shadow: var(--shadow-medium);
        pointer-events: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-menu.active {
        transform: translateX(0);
    }

    .nav-menu .nav-link,
    .nav-menu .nav-dropdown-menu a {
        pointer-events: auto;
        cursor: pointer;
        touch-action: manipulation;
    }

    .nav-list {
        flex-direction: column;
        gap: 0;
        padding: 2rem 0;
        height: 100%;
        overflow-y: auto;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        display: block;
        padding: 1rem 2rem;
        font-size: 1.1rem;
        border-radius: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link:hover,
    .nav-link.active {
        background: var(--light-bg);
        color: var(--primary-color);
    }

    /* Show mobile menu toggle */
    .header.menu-open .nav-actions {
        position: relative;
        z-index: 3002;
    }

    .nav-actions {
        position: relative;
        z-index: 3002;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 3003;
        min-width: 44px;
        min-height: 44px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Submenú Grupo SCAL en móvil */
    .nav-dropdown .dropdown-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 0.5rem;
    }

    .dropdown-toggle-label {
        flex: 1;
        text-align: left;
    }

    .dropdown-chevron-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        margin: -0.5rem -0.75rem -0.5rem 0;
        padding: 0 0.75rem;
        flex-shrink: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .dropdown-chevron-btn i {
        pointer-events: none;
    }

    .nav-dropdown .dropdown-toggle::after {
        display: none;
    }

    .nav-dropdown:hover .nav-dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .nav-dropdown .nav-dropdown-menu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        display: block !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        box-shadow: none;
        border-radius: 0;
        background: var(--light-bg);
        min-width: 100%;
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .nav-dropdown.open .nav-dropdown-menu,
    .nav-menu.active .nav-dropdown .nav-dropdown-menu {
        max-height: 280px;
    }

    .nav-dropdown.open .dropdown-toggle i {
        transform: rotate(180deg);
    }

    .nav-dropdown-menu li {
        list-style: none;
    }

    .nav-dropdown-menu a {
        padding: 0.85rem 2rem 0.85rem 3rem;
        font-size: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-menu {
        -webkit-overflow-scrolling: touch;
    }

    /* Hero section mobile */
    .hero {
        min-height: 100svh;
    }

    .hero .container {
        padding-top: calc(var(--header-height, 80px) + 1rem);
    }

    .hero-title {
        font-size: 2.5rem;
        line-height: 1.1;
    }

    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    .hero-buttons .btn {
        width: 200px;
    }

    /* Section padding mobile */
    .section-padding {
        padding: 50px 0;
    }

    /* Estadísticas móvil */
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .stat-item {
        padding: 1.75rem 1rem;
    }

    .stat-icon {
        width: 80px;
        height: 80px;
        min-width: 80px;
        min-height: 80px;
    }

    .stat-icon i {
        font-size: 2rem;
        width: 2rem;
        height: 2rem;
    }

    .stats-section .stat-icon i:not(.fa-loaded)::after {
        font-size: 2rem !important;
    }

    .stat-number {
        font-size: 2.5rem;
    }

    /* Products mobile */
    .product-filters {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }

    .filter-btn {
        width: 200px;
        text-align: center;
    }

    .products-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Services mobile */
    .services-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .service-card {
        padding: 2rem 1.5rem;
    }

    /* About section mobile */
    .about-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .about-text .section-header {
        text-align: center;
        margin-bottom: 1.5rem;
    }

    .about-text .section-title::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .about-features {
        gap: 1rem;
    }

    .feature-item {
        text-align: left;
    }

    /* Contact mobile */
    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .contact-info {
        gap: 1.5rem;
    }

    .contact-form {
        padding: 1.5rem;
    }

    /* Footer mobile */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
        gap: 1rem;
    }

    /* Cart modal mobile */
    .cart-modal {
        width: 100%;
        right: -100%;
    }

    .cart-modal.active {
        right: 0;
    }

    /* Modal mobile */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin: 1rem;
    }

    .product-quickview {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .quickview-actions {
        flex-direction: column;
    }

    /* Form elements mobile */
    .btn {
        padding: 14px 25px;
        font-size: 1rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Search box mobile */
    .search-box {
        max-width: 100%;
        margin-bottom: 1.5rem;
    }

    /* Toast notifications mobile */
    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast {
        margin-bottom: 0.5rem;
        padding: 0.75rem 1rem;
    }

    /* Cart actions mobile */
    .cart-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    /* Pagination mobile */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .pagination-btn {
        min-width: 35px;
        padding: 6px 8px;
        font-size: 0.85rem;
    }
}

@media (min-width: 768px) {
    .dropdown-chevron-btn {
        display: none;
    }
}

/* ===============================
   SMALL MOBILE (up to 480px)
=============================== */

@media (max-width: 480px) {
    /* Extra small adjustments */
    .container {
        padding: 0 15px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .section-subtitle {
        font-size: 1rem;
    }

    .service-card {
        padding: 1.5rem 1rem;
    }

    .service-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .contact-form {
        padding: 1rem;
    }

    .modal-content {
        padding: 1rem;
    }

    .cart-content .cart-header,
    .cart-content .cart-footer {
        padding: 1rem;
    }
}

/* ===============================
   LANDSCAPE ORIENTATION MOBILE
=============================== */

@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        min-height: 60vh;
    }

    .hero-title {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .hero-buttons {
        flex-direction: row;
        gap: 1rem;
    }

    .hero-buttons .btn {
        width: auto;
        padding: 10px 20px;
    }
}

/* ===============================
   HIGH DPI / RETINA DISPLAYS
=============================== */

@media (-webkit-min-device-pixel-ratio: 2), 
       (min-resolution: 192dpi) {
    /* Ensure crisp images and icons on retina displays */
    .logo,
    .footer-logo {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===============================
   PRINT STYLES
=============================== */

@media print {
    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
    }

    .header,
    .nav-toggle,
    .cart-btn,
    .btn,
    .footer,
    .cart-modal,
    .overlay,
    .modal {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
    }

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .section-padding {
        padding: 20px 0;
    }
}

/* ===============================
   ACCESSIBILITY ENHANCEMENTS
=============================== */

/* Focus styles for keyboard navigation */
@media (prefers-reduced-motion: no-preference) {
    .btn:focus,
    .nav-link:focus,
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero-background {
        background-attachment: scroll !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
        --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.4);
        --shadow-heavy: 0 8px 30px rgba(0, 0, 0, 0.5);
        --border-color: #666;
    }

    .btn-outline {
        border-width: 2px;
    }

    .nav-link:hover,
    .nav-link.active {
        outline: 2px solid currentColor;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    /* Dark mode variables would go here */
    /* This is prepared for future dark mode implementation */
    /*
    :root {
        --primary-color: #4fc3f7;
        --text-dark: #ffffff;
        --text-light: #b0bec5;
        --white: #121212;
        --light-bg: #1e1e1e;
        --dark-color: #ffffff;
        --border-color: #333333;
        --shadow-color: rgba(255, 255, 255, 0.1);
    }
    */
}