/* ========================================
   RESPONSIVE CUSTOMIZATION FOR MENU & FILTERS
   Device-specific adaptations
   ======================================== */

/* ========================================
   1. FILTER SIDEBAR ADAPTATIONS
   ======================================== */

/* Desktop: sidebar normale */
@media (min-width: 1025px) {
  .sidebar {
    position: sticky;
    top: 90px;
  }

  .filter-toggle-btn {
    display: none !important;
  }

  #filter-overlay {
    display: none !important;
  }

  .sidebar-close-btn {
    display: none !important;
  }
}

/* Tablette landscape (769px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 240px;
  }

  .search-section h2 {
    font-size: 18px;
  }

  .form-group label {
    font-size: 13px;
  }

  .filter-toggle-btn {
    display: none !important;
  }

  .sidebar-close-btn {
    display: none !important;
  }
}

/* Tablette portrait et Mobile (< 768px) */
@media (max-width: 768px) {
  /* Réorganiser le layout principal */
  .main-content {
    display: flex;
    flex-direction: column;
  }

  /* Bouton pour ouvrir les filtres sur mobile */
  .filter-toggle-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: #01a185;
    color: white;
    border: none;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(1, 161, 133, 0.3);
    transition: all 0.3s ease;
    order: -1; /* Placer avant la sidebar */
  }

  .filter-toggle-btn:hover {
    background: #018f73;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(1, 161, 133, 0.4);
  }

  .filter-toggle-btn i {
    font-size: 16px;
  }

  /* Sidebar en drawer (tiroir) sur mobile */
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: 85%;
    max-width: 340px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    transition: left 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    padding-top: 20px;
  }

  .sidebar.show {
    left: 0;
  }

  /* Bouton fermer dans la sidebar mobile */
  .sidebar-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f3f4f6;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
    font-size: 18px;
    z-index: 10;
    transition: all 0.2s ease;
  }

  .sidebar-close-btn:hover {
    background: #e5e7eb;
    color: #111827;
  }

  /* Overlay pour fermer le drawer */
  #filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  #filter-overlay.show {
    display: block;
    opacity: 1;
  }

  /* Ajuster le content-section */
  .content-section {
    order: 1;
    width: 100%;
  }
}

/* Mobile small (< 480px) */
@media (max-width: 480px) {
  .sidebar {
    width: 90%;
    max-width: 100%;
  }

  .filter-toggle-btn {
    font-size: 14px;
    padding: 10px 16px;
  }
}

/* ========================================
   2. CATEGORY NAVIGATION ADAPTATIONS
   ======================================== */

/* Desktop: menu horizontal normal */
@media (min-width: 1025px) {
  .category-nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
  }

  .category-link {
    padding: 10px 18px;
    font-size: 15px;
  }
}

/* Tablette landscape: menu scrollable */
@media (max-width: 1024px) and (min-width: 769px) {
  .category-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 0;
  }

  .category-nav::-webkit-scrollbar {
    height: 4px;
  }

  .category-nav::-webkit-scrollbar-thumb {
    background: #01a185;
    border-radius: 4px;
  }

  .category-nav ul {
    display: flex;
    white-space: nowrap;
    gap: 12px;
  }

  .category-link {
    font-size: 14px;
    padding: 8px 14px;
  }
}

/* Tablette portrait: menu scrollable compact */
@media (max-width: 768px) and (min-width: 481px) {
  .category-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
  }

  .category-nav::-webkit-scrollbar {
    display: none; /* Cacher scrollbar sur tablette */
  }

  .category-nav ul {
    display: flex;
    white-space: nowrap;
    gap: 10px;
    padding: 0 15px;
  }

  .category-link {
    font-size: 13px;
    padding: 8px 12px;
  }

  .category-link i {
    font-size: 14px;
  }
}

/* Mobile: menu en grille 2 colonnes avec icônes */
@media (max-width: 480px) {
  .category-nav {
    margin-bottom: 15px;
    padding: 10px 15px;
  }

  .category-nav ul {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .category-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    padding: 12px 8px;
    text-align: center;
    min-height: 70px;
  }

  .category-link i {
    display: block;
    font-size: 20px;
    margin-bottom: 4px;
  }
}

/* ========================================
   3. FORM FIELDS ADAPTATIONS
   ======================================== */

/* Mobile: champs full-width */
@media (max-width: 768px) {
  .search-section {
    padding: 20px 15px;
  }

  .search-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
  }

  .form-group {
    margin-bottom: 15px;
  }

  .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
    display: block;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border-radius: 6px;
  }

  /* Carte plus petite sur mobile */
  #id_location_map {
    height: 150px !important;
    margin: 10px 0;
  }

  /* Sliders de prix */
  .price-slider-container {
    padding: 10px 0;
  }

  .price-values {
    font-size: 12px;
  }

  /* Champs spécifiques aux catégories */
  .hidden-fields {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
  }

  .hidden-fields p {
    font-size: 13px;
    margin-bottom: 10px;
  }

  /* Bouton rechercher */
  .search-btn {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    margin-top: 10px;
  }
}

@media (max-width: 480px) {
  #id_location_map {
    height: 120px !important;
  }

  .search-section h2 {
    font-size: 16px;
  }
}

/* ========================================
   4. PRODUCT GRID ENHANCEMENTS
   ======================================== */

/* Assurer la responsivité de la grille */
@media (max-width: 1200px) and (min-width: 1025px) {
  .content-section .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) and (min-width: 769px) {
  .content-section .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

@media (max-width: 768px) and (min-width: 481px) {
  .content-section .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .content-section .product-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .product-card {
    max-width: 100%;
  }
}

/* ========================================
   5. FEATURED ADS SLIDER ADAPTATIONS
   ======================================== */

@media (max-width: 768px) {
  .featured-ads h2 {
    font-size: 20px;
    margin-bottom: 15px;
  }

  .ad-slider {
    padding: 0 30px;
  }

  .slider-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .ad-card {
    min-width: 160px;
  }

  .ad-badge {
    font-size: 10px;
    padding: 4px 8px;
  }
}

@media (max-width: 480px) {
  .featured-ads {
    padding: 15px 10px;
  }

  .featured-ads h2 {
    font-size: 18px;
  }

  .ad-slider {
    padding: 0 25px;
  }

  .ad-card {
    min-width: 140px;
  }

  .ad-card h3 {
    font-size: 13px;
  }

  .ad-card .price {
    font-size: 14px;
  }
}

/* ========================================
   6. SUGGESTIONS DROPDOWN ADAPTATIONS
   ======================================== */

@media (max-width: 768px) {
  #suggestions {
    max-height: 120px;
    font-size: 13px;
  }
}

/* ========================================
   7. UTILITIES
   ======================================== */

/* Cacher éléments sur mobile si nécessaire */
@media (max-width: 480px) {
  .hide-on-mobile {
    display: none !important;
  }
}

/* Afficher uniquement sur mobile */
.show-on-mobile {
  display: none !important;
}

@media (max-width: 480px) {
  .show-on-mobile {
    display: block !important;
  }
}

/* Smooth scrolling pour le drawer */
.sidebar {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Animation d'entrée pour le drawer */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.sidebar.show {
  animation: slideInLeft 0.3s ease-out;
}