/**
 * Responsive Styles
 * ManualesCompletos.com
 */

/* ============================================
   Tablet (768px and below)
   ============================================ */
@media (max-width: 768px) {
    /* Enable horizontal scrolling */
    html, body {
        overflow-x: auto;
        width: 100%;
        min-width: 320px;
    }

    /* Navbar */
    .navbar-toggle {
        display: flex;
    }
    
    .navbar-menu {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: var(--spacing-lg);
        gap: var(--spacing-lg);
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        border-top: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
    }
    
    .navbar-menu.active {
        transform: translateX(0);
    }
    
    .navbar-nav {
        flex-direction: column;
        width: 100%;
        gap: 0;
    }
    
    .nav-item {
        width: 100%;
    }
    
    .nav-link {
        display: block;
        padding: var(--spacing-sm) 0;
        width: 100%;
    }
    
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        padding-left: var(--spacing-md);
    }
    
    .navbar-actions {
        flex-direction: column;
        width: 100%;
        gap: var(--spacing-sm);
    }
    
    .navbar-actions .btn {
        width: 100%;
    }
    
    /* Hero */
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .hero-search {
        flex-direction: column;
    }
    
    .hero-search input,
    .hero-search button {
        width: 100%;
    }
    
    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    /* Products Grid */
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: var(--spacing-md);
    }

    /* Search Page */
    .search-layout {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
        display: flex !important;
        flex-direction: column !important;
    }

    .search-filters {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        background: var(--bg-primary);
        border: 1px solid #e0e0e0;
        border-radius: var(--radius-lg);
        padding: var(--spacing-lg);
        margin-bottom: var(--spacing-lg);
        box-shadow: none !important;
        display: block !important;
        top: auto !important;
        order: 1 !important;
    }

    .search-results {
        width: 100%;
        order: 2 !important;
    }

    .filter-section {
        margin-top: 0;
    }

    /* Product Detail */
    .product-detail {
        flex-direction: column;
        gap: var(--spacing-lg);
        overflow-x: hidden;
    }

    .product-gallery {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .product-main-image {
        max-width: 100%;
        height: auto;
        display: block;
    }

    .product-info {
        flex: 1;
        width: 100%;
        overflow-x: hidden;
    }

    .buy-box {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Brands */
    .brands-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
    
    /* Section */
    .section {
        padding: var(--spacing-xl) 0;
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Container */
    .container {
        padding: 0 var(--spacing-sm);
        overflow-x: hidden;
        width: 100%;
    }
}

/* ============================================
   Mobile (480px and below)
   ============================================ */
@media (max-width: 480px) {
    /* Typography */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    /* Search Page - Landscape mobile fix */
    .search-layout {
        display: flex !important;
        flex-direction: column !important;
    }

    .search-filters {
        order: 1 !important;
        width: 100% !important;
    }

    .search-results {
        order: 2 !important;
        width: 100% !important;
    }

    /* Hero */
    .hero {
        padding: var(--spacing-xl) 0;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 0.875rem;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: var(--spacing-md);
    }

    .stat-number {
        font-size: 1.75rem;
    }

    /* Products Grid */
    .products-grid {
        grid-template-columns: 1fr;
    }

    /* Brands */
    .brands-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Buttons */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Forms */
    .form-control {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
    
    /* Product Card */
    .product-image {
        height: 180px;
    }
    
    .product-price {
        font-size: 1.25rem;
    }
    
    /* Back to Top */
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: var(--spacing-md);
        right: var(--spacing-md);
    }
    
    /* Search Modal */
    .search-modal-content {
        padding: var(--spacing-md);
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .search-input {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    
    .search-submit {
        padding: 0.75rem 1.5rem;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination-link,
    .pagination-current {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* ============================================
   Mobile Landscape (max-height: 500px)
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    /* Search Page - Force vertical layout on landscape mobile */
    .search-layout {
        display: flex !important;
        flex-direction: column !important;
    }

    .search-filters {
        order: 1 !important;
        width: 100% !important;
        position: relative !important;
        top: auto !important;
    }

    .search-results {
        order: 2 !important;
        width: 100% !important;
    }
}

/* ============================================
   Large Desktop (1440px and above)
   ============================================ */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    .hero h1 {
        font-size: 3.5rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* ============================================
   Touch Devices
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .dropdown:hover .dropdown-menu {
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
    }
    
    .dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .product-card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .navbar,
    .footer,
    .back-to-top,
    .search-modal,
    .btn {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .product-card {
        break-inside: avoid;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-behavior-smooth {
        scroll-behavior: auto;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --glass-border: rgba(255, 255, 255, 0.3);
    }
    
    .product-card,
    .stat-card,
    .brand-item {
        border-width: 2px;
    }
}
