/* 
 * Styles responsives communs pour le site
 */

/* ------------------------------------------- 
   Grands écrans (1201px et plus)
------------------------------------------- */
@media (min-width: 1201px) {
    /* Grilles et layout */
    .categories {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ------------------------------------------- 
   Entre 1200px et 1025px (Grands écrans et ordinateurs standards)
------------------------------------------- */
@media (max-width: 1200px) and (min-width: 1025px) {
    /* Grilles et layout */
    .categories {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Header et navigation */
    .header-left {
        margin-right: 10px;
        flex: 0 0 auto;
    }
    
    .user-actions {
        margin-left: 10px;
        flex: 0 0 auto;
    }

    .logo img {
        width: 100px;
    }
    
    .logo-text {
        display: inline-block;
        font-size: 1.5rem;
    }
    
    .header-center {
        left: 180px;
        right: 180px;
        width: calc(100% - 360px);
    }
}

/* ------------------------------------------- 
   Entre 1024px et 769px (Tablettes et petits écrans)
------------------------------------------- */
@media (max-width: 1024px) and (min-width: 769px) {
    /* Réduction des marges pour les tablettes */
    .section-title-container {
        margin: 0px;
    }
    
    .container > .section-title-container:first-child {
        margin-top: 35px;
    }
    
    /* Header pour les tablettes */
    .main-header {
        height: 130px !important; /* Hauteur optimisée pour le header */
        align-items: flex-start !important;
        padding-top: 12px !important;
    }

    .logo img {
        width: 100px;
    }
    
    .header-container {
        flex-wrap: wrap;
        height: 130px;
        padding-top: 0;
        align-content: flex-start;
    }
    
    .header-left {
        flex: 0 0 auto;
        order: 1;
        min-width: 0;
        margin-right: auto;
        height: 50px;
        margin-top: 0;
    }
    
    .user-actions {
        flex: 0 0 auto;
        order: 2;
        margin-left: 0;
        min-width: 0;
        height: 50px;
        justify-content: flex-end;
        margin-top: 0;
    }
    
    .header-center {
        position: relative;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin-top: 10px;
        order: 3;
        flex: 1 0 100%;
    }
    
    .header-search-container {
        width: 100%;
        max-width: 100%;
        margin-top: 0;
    }
    
    .header-search {
        width: 100%;
    }
    
    /* Menu dropdown et position */
    .profile-dropdown {
        position: fixed;
        top: 70px;
        right: 20px;
        max-width: 90%;
        z-index: 1070;
    }
    
    .profile-dropdown::before {
        display: none;
    }
    
    /* Grilles et layout pour tablettes */
    .categories {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Footer pour tablettes */
    .footer-container {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-areas: 
            "about about about"
            "nav categories social";
        column-gap: 70px;
    }
    
    .footer-about {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 30px;
    }
    
    .footer-nav {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
    }
    
    .footer-categories {
        grid-column: 2;
        grid-row: 2;
        justify-self: center;
    }
    
    .footer-social {
        grid-column: 3;
        grid-row: 2;
        justify-self: center;
    }
    
    /* Filtres de recherche pour tablettes */
    .header-advanced-filters {
        padding: 0;
        width: 90%;
        max-width: none;
        left: 50%;
        transform: translateX(-50%) translateY(-10px) scale(0.95);
    }
    
    .show-filters .header-advanced-filters {
        padding: 12px;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    
    .header-advanced-filters .filter-tag {
        padding: 6px 12px;
        font-size: 0.85rem;
        margin: 2px;
    }
}

/* ------------------------------------------- 
   Entre 768px et 481px (Tablettes moyennes et grands mobiles)
------------------------------------------- */
@media (max-width: 768px) and (min-width: 481px) {
    /* Réduction des marges pour mobiles moyens */
    .section-title-container {
        margin: 0px;
    }

    .logo img {
        width: 100px;
    }
    
    .container > .section-title-container:first-child {
        margin-top: 30px;
    }
    
    /* Header pour mobiles moyens */
    .main-header {
        height: 120px !important;
        padding-top: 5px !important;
    }
    
    .header-container {
        height: 120px;
        flex-wrap: wrap;
    }
    
    /* Structure pour mobiles moyens */
    .header-left {
        flex: 0 0 auto;
        order: 1;
        min-width: 0;
        margin-right: auto;
        height: 50px;
    }
    
    .user-actions {
        flex: 0 0 auto;
        order: 2;
        margin-left: 0;
        min-width: 0;
        height: 50px;
    }
    
    .header-center {
        position: relative;
        left: 0;
        right: 0;
        bottom: 5px;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin-top: 0px;
        order: 3;
        flex: 1 0 100%;
    }
    
    .header-search-container {
        width: 100%;
        max-width: 100%;
    }
    
    /* Barre de recherche mobile */
    .header-search {
        padding: 3px 3px 3px 12px;
        width: 100%;
        height: 42px;
    }
    
    .header-search .search-input {
        font-size: 14px; /* Taille réduite pour que le placeholder soit visible en entier */
        padding: 6px 8px;
        -webkit-appearance: none; /* Désactive l'apparence par défaut sur iOS */
        appearance: none;
    }
    
    .header-search .search-btn {
        left:3px;
    }
    
    /* Styles pour les icônes de section sur mobile */
    .section-icon {
        width: 32px;
        height: 32px;
        overflow: visible;
    }
    
    .section-icon svg {
        width: 100%;
        height: 100%;
        display: block;
        min-width: 22px;
        min-height: 22px;
        stroke: #ff6b6b !important;
    }
    
    /* Menu dropdown mobile */
    .profile-dropdown {
        position: fixed;
        top: 65px;
        max-width: 90%;
        z-index: 1070;
    }
    
    .profile-dropdown::before {
        display: none;
    }
    
    /* Grilles et layout pour mobiles moyens */
    .categories {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Footer pour mobiles moyens */
    .footer-container {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-areas: 
            "about about about"
            "nav categories social";
        column-gap: 40px;
    }
    
    .footer-about {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 30px;
    }
    
    .footer-nav {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
    }
    
    .footer-categories {
        grid-column: 2;
        grid-row: 2;
        justify-self: center;
    }
    
    .footer-social {
        grid-column: 3;
        grid-row: 2;
        justify-self: center;
    }
    
    .footer-social-links {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 25px;
    }
    
    .footer-social-link {
        width: auto;
        min-width: 140px;
        gap: 8px;
    }
    
    .social-icon {
        width: 44px;
        height: 44px;
    }
    
    .social-icon svg {
        width: 30px;
        height: 30px;
    }
}

/* ------------------------------------------- 
   Entre 480px et 321px (Petits mobiles)
------------------------------------------- */
@media (max-width: 480px) and (min-width: 321px) {
    /* Classe pour éviter les scintillements lors du défilement */
    .main-header.scrolling-active {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 1050 !important;
        transform: translateZ(0) !important;
        will-change: transform !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
    }
    
    .logo img {
        width: 100px;
    }
    
    /* Garder les éléments du header stables pendant le défilement */
    .main-header.scrolling-active .header-container,
    .main-header.scrolling-active .user-actions,
    .main-header.scrolling-active .header-left,
    .main-header.scrolling-active .search-icon-mobile,
    .main-header.scrolling-active .menu-button,
    .main-header.scrolling-active .menu-toggle {
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        display: flex !important;
    }
    
    /* S'assurer que le menu dropdown reste visible pendant le défilement s'il était déjà ouvert */
    .profile-dropdown.show {
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 2050 !important; /* Plus élevé que le header (2000) */
        transform: translateY(0) !important; /* S'assurer que la translation est bien réinitialisée */
    }
    
    /* Styles pour les icônes de section sur petits mobiles */
    .section-icon {
        width: 28px;
        height: 28px;
        overflow: visible;
    }
    
    .section-icon svg {
        width: 100%;
        height: 100%;
        display: block;
        min-width: 20px;
        min-height: 20px;
        stroke: #ff6b6b !important;
    }

    /* Header pour petits mobiles */
    .main-header {
        height: 60px !important;
        padding-top: 12px;
        display: flex;
        flex-direction: column;
    }
    
    /* Header en mode sombre */
    .dark-mode .main-header {
        background-color: var(--header-bg);
    }
    
    .header-container {
        height: 40px;
        flex-wrap: nowrap;
        padding: 0 12px;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Structure pour petits mobiles */
    .header-left {
        flex: 0 0 auto;
        order: 1;
        min-width: 0;
        margin-right: 0;
        height: 40px;
        position: relative;
        bottom: 3px;
    }
    
    .user-actions {
        flex: 0 0 auto;
        order: 3;
        margin-left: 0;
        min-width: 0;
        height: 40px;
        display: flex;
        align-items: center;
    }
    
    /* Repositionnement de la barre de recherche */
    .header-center {
        display: none; /* Cacher la barre de recherche centrale */
    }
    
    /* Ajouter un bouton de recherche dans le menu */
    .search-icon-mobile {
        width: 40px;
        height: 40px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
        position: relative;
        bottom: 3px;
        left: 5px;
        background-color: #f5f5f5;
        border: 1px solid #dddddd;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .search-icon-mobile:hover {
        box-shadow: 0 0 8px var(--primary-color);
        border-color: transparent;
        transform: translateY(-1px);
    }
    
    /* Apparence lorsque le champ de recherche est actif */
    .search-icon-mobile.active {
        background-color: var(--primary-color);
        border-color: transparent;
        box-shadow: 0 0 8px var(--primary-color);
    }
    
    .search-icon-mobile.active svg {
        stroke: white;
    }
    
    .search-icon-mobile svg {
        width: 24px;
        height: 24px;
        stroke: #333;
        stroke-width: 2.5;
    }
    
    /* Bouton de recherche en mode sombre */
    .dark-mode .search-icon-mobile {
        background-color: #3a4446;
        border-color: var(--border-color);
    }
    
    .dark-mode .search-icon-mobile svg {
        stroke: #e0e0e0;
    }
    
    .dark-mode .search-icon-mobile:hover {
        box-shadow: 0 0 8px var(--primary-color);
        border-color: transparent;
    }
    
    /* Menu hamburger en mode sombre */
    .dark-mode .menu-button {
        background-color: #3a4446;
        border-color: var(--border-color);
    }
    
    .dark-mode .menu-button .hamburger-icon,
    .dark-mode .menu-button .profile-icon {
        color: #e0e0e0;
    }
    
    /* Ajustement du menu dropdown pour la nouvelle hauteur */
    .profile-dropdown {
        top: 50px !important;
    }
    
    /* Profile dropdown en mode sombre */
    .dark-mode .profile-dropdown {
        background-color: #2a3334;
        box-shadow: 0 2px 16px rgba(0,0,0,0.3);
    }
    
    .dark-mode .profile-dropdown::before {
        background-color: #2a3334;
        border-color: var(--border-color);
    }
    
    .dark-mode .dropdown-item {
        color: #f0f0f0;
    }
    
    .dark-mode .dropdown-item:hover {
        background-color: #3a4446;
    }
    
    .dark-mode .dropdown-divider {
        background-color: var(--border-color);
    }
    
    /* Styles spécifiques pour le menu hamburger */
    .menu-button {
        display: flex;
        align-items: center;
    }
    
    .menu-toggle {
        display: flex;
        align-items: center;
    }
    
    /* Suppression de la marge pour le contenu principal */
    main {
        margin-top: 0;
    }

    .container {
        width: 100%;
        max-width: var(--container-width);
        margin: 0 auto;
        padding: 0 12px;
        position: relative;
    }

    /* Autres éléments en mode sombre */
    .dark-mode .section-title {
        color: #f0f0f0;
    }
    
    .dark-mode .section-line {
        box-shadow: 0 1px 0 rgba(255, 107, 107, 0.5);
    }
    
    /* Grilles et layout pour petits mobiles */
    .categories {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    /* Menu de recherche avancée pour petits mobiles */
    .search-dropdown {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        max-height: 60vh;
        overflow-y: auto;
        z-index: 2050;
    }
    
    .search-dropdown input::placeholder {
        color: #999;
        opacity: 1;
    }
    
    .search-dropdown .search-input-wrapper {
        height: 42px;
    }
    
    .search-dropdown .search-input {
        font-size: 14px; /* Taille réduite pour que le placeholder soit visible en entier */
    }

    
    .search-dropdown .filter-group {
        margin-bottom: 15px;
    }
    
    .search-dropdown .filter-tag {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    /* Ajustements pour les icônes du menu */
    .menu-toggle {
        width: 80px !important;
    }
    
    .menu-button {
        height: 38px !important;
        padding: 0 10px 0 4px !important;
    }
    
    .menu-button .profile-icon {
        width: 22px !important;
        height: 22px !important;
    }
    
    .menu-button .hamburger-icon {
        font-size: 1.8rem !important;
        margin-right: 8px !important;
        margin-left: 8px !important;
        width: 20px !important;
        height: 20px !important;
        line-height: 1 !important;
    }
    
    /* Style pour le conteneur de titre de section */
    .section-title-container {
        margin: 0px;
    }

    /* Premier titre de section avec marge supérieure réduite */
    .container > .section-title-container:first-child {
        margin-top: 20px;
    }

    /* Titres de sections pour petits mobiles */
    .section-title {
        font-size: 1.4rem;
        margin: 10px 0 5px;
        gap: 10px;
    }
    
    /* Ajustement pour les boutons d'action dans le titre */
    .section-title-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    /* Masquer le bouton d'action pour les catégories sur les petits écrans */
    .section-action-btn {
        display: none;
    }
    
    .section-icon {
        width: 32px;
        height: 32px;
        overflow: visible;
    }
    
    .section-icon svg {
        width: 100%;
        height: 100%;
        display: block;
        min-width: 22px;
        min-height: 22px;
    }
    
    footer {
        background-color: var(--dark-color);
        color: white;
        padding: 30px 0 20px;
        margin-top: 60px;
    }

    /* Footer pour petits mobiles */
    .footer-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "about about"
            "nav categories"
            "social social";
        gap: 20px;
    }
    
    .footer-about {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 0px;
    }
    
    .footer-nav {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
        padding-left: 15px;
    }
    
    .footer-categories {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
    }
    
    .footer-social {
        grid-column: 1 / -1;
        grid-row: 3;
        margin-top: 10px;
        padding-left: 15px;
    }
    
    .footer-heading {
        text-align: left;
    }
    
    .footer-social-links {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: flex-start;
    }
    
    .footer-social-link {
        justify-content: flex-start;
        min-width: 110px;
        display: flex;
        align-items: center;
        gap: 3px;
    }
    
    .social-icon {
        width: 30px;
        height: 30px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .social-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* ------------------------------------------- 
   320px et moins (Très petits mobiles)
------------------------------------------- */
@media (max-width: 320px) {
    /* Header pour très petits mobiles */
    .main-header {
        height: 100px !important;
        margin-bottom: 20px !important;
        padding-top: 5px !important;
    }
    
    .header-container {
        padding: 0 5px;
        height: 100px;
    }
    
    /* Styles pour les icônes de section sur mobile */
    .section-icon {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: visible;
    }
    
    .section-icon svg {
        width: 100%;
        height: 100%;
        display: block;
        min-width: 20px;
        min-height: 20px;
        stroke: #ff6b6b !important;
    }

    /* Ajustements menu hamburger pour très petits écrans */
    .menu-toggle {
        width: 70px !important;
    }
    
    .menu-button {
        height: 35px !important;
        padding: 0 8px 0 2px !important;
    }
    
    .menu-button .hamburger-icon {
        font-size: 1.2rem !important;
        margin-right: 5px !important;
        margin-left: 5px !important;
        width: 18px !important;
        height: 18px !important;
        line-height: 1 !important;
    }
    
    .menu-button .profile-icon {
        width: 20px !important;
        height: 20px !important;
    }
    
    /* Ajustements pour la barre de recherche */
    .header-search {
        padding: 2px 2px 2px 8px;
        width: 100%;
        height: 36px;
        box-sizing: border-box;
    }
    
    .header-search .search-input {
        font-size: 16px; /* Taille fixe 16px pour éviter le zoom automatique */
        padding: 5px 6px;
        height: 36px;
        box-sizing: border-box;
        -webkit-appearance: none; /* Désactive l'apparence par défaut sur iOS */
        appearance: none;
    }
    
    .header-search .search-btn {
        padding: 0 6px;
        font-size: 0.75rem;
        height: 36px;
    }
    
    /* Structure pour très petits mobiles */
    .header-left {
        flex: 0 0 auto;
        order: 1;
        min-width: 0;
        margin-right: auto;
        height: 50px;
    }
    
    .user-actions {
        flex: 0 0 auto;
        order: 2;
        margin-left: 0;
        min-width: 0;
        height: 50px;
    }
    
    .header-center {
        order: 3;
        flex: 1 0 100%;
        position: relative;
        left: 0;
        right: 0;
        width: 100%;
    }
    
    /* Grilles et layout pour très petits mobiles */
    .categories {
        grid-template-columns: repeat(1, 1fr);
    }
    
    /* Logo et titre pour très petits mobiles */
    .logo {
        font-size: 1.3rem;
    }
    
    .logo img {
        width: 50px;
        margin-right: 5px;
    }
    
    .logo span.infinity {
        font-size: 2rem;
    }
    
    /* Menu dropdown pour très petits mobiles */
    .profile-dropdown {
        position: fixed;
        top: 55px;
        right: 5px;
        width: 180px;
        max-width: 95%;
        z-index: 1070;
    }
    
    /* Titres de sections pour très petits mobiles */
    .section-title-container {
        margin: 0px;
    }
    
    .container > .section-title-container:first-child {
        margin-top: 15px;
    }
    
    .section-title {
        font-size: 1.3rem;
        margin: 8px 0 8px;
    }
    
    .section-icon {
        width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: visible;
    }
    
    .section-icon svg {
        width: 100%;
        height: 100%;
        display: block;
        min-width: 20px;
        min-height: 20px;
    }
    
    /* Footer pour très petits mobiles */
    .footer-container {
        gap: 20px;
    }
    
    .footer-heading {
        font-size: 1.1rem;
    }
    
    .footer-social-links {
        justify-content: center;
        gap: 15px;
    }
    
    .footer-social-link {
        min-width: 100px;
        font-size: 0.85rem;
    }
    
    .social-icon {
        width: 36px;
        height: 36px;
    }
    
    .social-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .footer-bottom {
        font-size: 0.8rem;
    }
}