/* RAFTELSHOP - Products Page Mobile CSS */
/* Responsive mobile optimisé avec corrections hamburger, tailles, touch targets */

/* Tablette */
@media (max-width: 1024px) {
    .products-page-container {
        padding: 16px 12px;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 9999;
        height: 100vh;
        max-height: 100vh;
        width: 280px;
        max-width: 90vw;
        border-radius: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-header { 
        position: sticky; 
        top: 0; 
        background: #4d5d7d; 
        z-index: 10000; 
        padding-right: 20px;
    }
    
    .products-content {
        width: 100%;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .products-page-container {
        padding: 16px;
        gap: 0;
    }
    
    /* Bouton hamburger corrigé - position dynamique */
    .hamburger-btn {
        display: flex;
        position: fixed;
        top: calc(var(--navbar-height, 70px) + 12px);
        left: 16px;
        z-index: 10001;
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        transition: all 0.3s ease;
        align-items: center;
        justify-content: center;
        font-size: 1.3rem;
        opacity: 1;
        visibility: visible;
    }
    
    /* Masquer le bouton hamburger quand le sidebar est ouvert - via classe CSS */
    body.sidebar-open .hamburger-btn,
    body.sidebar-open #hamburgerBtn {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transform: scale(0) !important;
        left: -9999px !important;
        top: -9999px !important;
    }
    
    /* Hamburger en bas lors du scroll vers le bas */
    .hamburger-btn.scrolled {
        top: auto !important;
        bottom: 20px !important;
        left: 16px !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @media (max-width: 480px) {
        .hamburger-btn.scrolled {
            bottom: 16px !important;
            left: 12px !important;
        }
    }
    
    body.rtl .hamburger-btn.scrolled {
        left: auto !important;
        right: 16px !important;
    }
    
    @media (max-width: 480px) {
        body.rtl .hamburger-btn.scrolled {
            right: 12px !important;
        }
    }
    
    .hamburger-btn:hover,
    .hamburger-btn:focus {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
        outline: 2px solid rgba(255, 255, 255, 0.5);
        outline-offset: 2px;
    }
    
    .hamburger-btn i {
        color: white;
    }
    
    .sidebar {
        width: 100%;
        max-width: 100%;
        z-index: 9999;
        left: -100%;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }
    
    /* Header sidebar mobile amélioré */
    .sidebar-header {
        position: sticky;
        top: 0;
        background: #4d5d7d;
        z-index: 10000;
        padding: 16px 20px;
        margin-bottom: 0;
        border-bottom: 2px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar-header h3 {
        font-size: 1.3rem;
        margin: 0;
        color: #ffffff;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .close-sidebar {
        position: absolute;
        top: 50%;
        right: 16px;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        background: rgba(255, 255, 255, 0.2);
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 10px;
        color: #ffffff;
        font-size: 1.1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    .close-sidebar:hover,
    .close-sidebar:focus {
        background: #ef4444;
        border-color: #ef4444;
        transform: translateY(-50%) scale(1.1);
        outline: 2px solid rgba(255, 255, 255, 0.5);
        outline-offset: 2px;
    }
    
    /* Sidebar scroll amélioré */
    .sidebar {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar::-webkit-scrollbar {
        width: 4px;
    }
    
    .sidebar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
    
    .sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }
    
    .products-content {
        width: 100%;
        padding: 0;
    }
    
    .page-header {
        padding: 24px 16px;
        margin-bottom: 24px;
    }
    
    .page-header h1 {
        font-size: 1.8rem;
        line-height: 1.3;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .product-card {
        border-radius: 12px;
    }
    
    .product-image {
        height: 180px;
        width: 100%;
        object-fit: cover;
        aspect-ratio: 1 / 1;
    }
    
    .product-info {
        padding: 14px;
    }
    
    .product-name {
        font-size: 1rem;
        line-height: 1.4;
        min-height: 2.8em;
    }
    
    .product-price {
        font-size: 1.1rem;
        margin-top: 8px;
        direction: ltr !important;
        unicode-bidi: isolate !important;
    }
    
    .product-vendor {
        font-size: 0.9rem;
        margin-top: 12px;
    }
    
    .pagination {
        gap: 8px;
        flex-wrap: wrap;
        margin-top: 32px;
        margin-bottom: 32px;
    }
    
    .pagination a, 
    .pagination span {
        padding: 12px 16px;
        font-size: 1rem;
        min-width: 48px;
        min-height: 48px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .results-count {
        font-size: 0.95rem;
        margin-bottom: 20px;
    }
    
    /* Sidebar mobile améliorée - Design propre et simple */
    .sidebar-section {
        padding: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }
    
    .sidebar-section:last-child {
        border-bottom: none;
    }
    
    .sidebar-section-title {
        font-size: 1.1rem;
        font-weight: 700;
        color: #ffffff;
        margin-bottom: 16px;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .sidebar-section-title i {
        font-size: 1rem;
        color: rgba(255, 255, 255, 0.9);
    }
    
    .sidebar-search {
        position: relative;
        margin-bottom: 0;
    }
    
    .sidebar-search input {
        font-size: 1rem;
        padding: 16px 16px 16px 48px;
        min-height: 52px;
        width: 100%;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.15);
        color: #ffffff;
        font-weight: 500;
    }
    
    .sidebar-search input::placeholder {
        color: rgba(255, 255, 255, 0.7);
    }
    
    .sidebar-search input:focus {
        border-color: rgba(255, 255, 255, 0.6);
        background: rgba(255, 255, 255, 0.2);
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
        outline: none;
    }
    
    .sidebar-search i {
        position: absolute;
        left: 18px;
        top: 50%;
        transform: translateY(-50%);
        color: rgba(255, 255, 255, 0.8);
        font-size: 1.1rem;
        pointer-events: none;
    }
    
    .category-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .category-item {
        margin-bottom: 8px;
    }
    
    .category-item a {
        padding: 16px 18px;
        font-size: 1.05rem;
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-radius: 12px;
        transition: all 0.2s ease;
        font-weight: 500;
    }
    
    .category-item a:active {
        transform: scale(0.98);
    }
    
    .category-count {
        font-size: 0.95rem;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.8);
    }

    .category-sublist {
        list-style: none;
        padding: 6px 0 6px 14px;
        margin: 6px 0 0 0;
        border-left: 2px solid rgba(255, 255, 255, 0.25);
    }

    .category-item-child {
        margin-bottom: 6px;
    }

    .category-item-child a {
        padding: 12px 14px;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .category-item-parent.has-children > a {
        font-weight: 700;
    }
    
    .price-inputs {
        gap: 12px;
    }
    
    .price-inputs input {
        font-size: 1rem;
        padding: 16px 12px;
        min-height: 52px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.15);
        color: #ffffff;
        font-weight: 600;
    }
    
    .price-inputs input:focus {
        border-color: rgba(255, 255, 255, 0.6);
        background: rgba(255, 255, 255, 0.2);
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
        outline: none;
    }
    
    .sort-option {
        margin-bottom: 8px;
    }
    
    .sort-option label {
        padding: 16px 18px;
        font-size: 1.05rem;
        min-height: 52px;
        border-radius: 12px;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .sort-option label:active {
        transform: scale(0.98);
    }
    
    .sort-option input[type="radio"] {
        width: 22px;
        height: 22px;
        min-width: 22px;
        min-height: 22px;
        margin-right: 12px;
        cursor: pointer;
    }
    
    .sidebar-filter-actions {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin: 20px 0;
    }

    .sidebar-filter-actions .apply-filters-btn {
        margin-top: 0;
    }

    .sidebar-filter-actions .reset-filters-btn {
        margin-top: 0;
    }

    .apply-filters-btn {
        padding: 18px;
        font-size: 1.15rem;
        min-height: 56px;
        font-weight: 700;
        border-radius: 12px;
        margin-top: 20px;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }
    
    .apply-filters-btn:active {
        transform: translateY(1px);
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    }
    
    .reset-filters-btn {
        width: 100%;
        text-align: center;
        margin-top: 12px;
        padding: 14px;
        color: rgba(255, 255, 255, 0.8);
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.2);
        border-radius: 12px;
        cursor: pointer;
        font-size: 1rem;
        font-weight: 600;
        transition: all 0.3s ease;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .reset-filters-btn:hover,
    .reset-filters-btn:focus {
        background: rgba(239, 68, 68, 0.2);
        border-color: rgba(239, 68, 68, 0.5);
        color: #ffffff;
        outline: 2px solid rgba(239, 68, 68, 0.3);
        outline-offset: 2px;
    }
    
    .reset-filters-btn:active {
        transform: scale(0.98);
    }
}

/* Très petits écrans */
@media (max-width: 480px) {
    .hamburger-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        top: calc(var(--navbar-height, 70px) + 10px);
        left: 12px;
        font-size: 1.2rem;
    }
    
    .products-page-container {
        padding: 12px;
    }
    
    .page-header {
        padding: 20px 14px;
        margin-bottom: 20px;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .product-image {
        height: 220px;
    }
    
    .product-info {
        padding: 16px;
    }
    
    .product-name {
        font-size: 1.05rem;
    }
    
    .product-price {
        font-size: 1.15rem;
    }
    
    .pagination a, 
    .pagination span {
        padding: 10px 14px;
        font-size: 0.95rem;
        min-width: 44px;
        min-height: 44px;
    }
}

/* RTL mobile */
body.rtl .hamburger-btn {
    left: auto;
    right: 16px;
}

@media (max-width: 480px) {
    body.rtl .hamburger-btn {
        right: 12px;
    }
}
