/* 
* Styles personnalisés pour DataTables
* Adaptation pour le thème Savoor en clair et sombre
*/

/* Cache les éléments natifs de DataTables non désirés */
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length {
    display: none;
}

/* Style pour le conteneur principal DataTables */
.dataTables_wrapper {
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--body-font);
}

/* Cache le header de table et l'affichage de "processing" */
.dataTables_wrapper thead {
    display: none;
}

/* Classe pour cacher le header DataTables */
.datatable-hidden-header {
    display: none !important;
}

/* Cache la bordure de table et de cellules */
.dataTables_wrapper table,
.dataTables_wrapper table td {
    border: none !important;
    background: transparent !important;
}

/* Style pour la table DataTables et ses éléments */
#recettes-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100% !important;
    background: transparent;
}

/* Masquer les éléments de tableau standards */
#recettes-table td,
#recettes-table th {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* On arrange la table pour qu'elle ressemble à notre grid */
#recettes-table tbody {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
}

#recettes-table tr {
    display: flex;
    height: 100%;
    background: transparent;
    border: none;
}

#recettes-table tr td {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Uniformisation de la hauteur des cartes de recette */
#recettes-table .recipe-card {
    width: 100%;
    margin: 0;
    height: 405px; /* Hauteur fixe pour toutes les cartes - ajustée pour image 280px */
    display: flex;
    flex-direction: column;
}

/* La hauteur d'image est gérée par components/recipe-card.css (280px par défaut) */
#recettes-table .recipe-card .recipe-image {
    flex-shrink: 0; /* Empêche l'image de rétrécir */
}

/* Le contenu doit prendre le reste de l'espace */
#recettes-table .recipe-card .recipe-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* La section d'info reste en bas */
#recettes-table .recipe-card .recipe-info {
    margin-top: auto;
}

/* Conteneur des contrôles de pagination */
.pagination-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 30px;
    margin-bottom: 40px;
}

/* Contrôles de pagination standards */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3px;
    margin-bottom: 20px;
}

/* Pagination pour SEO cachée visuellement mais accessible pour les robots */
.pagination-links-seo {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    position: absolute;
    visibility: hidden;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
}

/* Style des boutons DataTables */
.dataTables_paginate .paginate_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    margin: 0 4px;
    border-radius: 5px;
    background-color: #f0f0f0;
    color: var(--text-color);
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-height: 40px;
    box-sizing: border-box;
    white-space: nowrap;
    vertical-align: middle;
}

.dataTables_paginate .paginate_button:hover {
    background-color: #e0e0e0;
    color: var(--primary-color);
}

.dataTables_paginate .paginate_button.current {
    background-color: var(--primary-color);
    color: white;
}

.dataTables_paginate .paginate_button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Masquer les flèches des boutons Précédent/Suivant */
.dataTables_paginate .paginate_button.previous,
.dataTables_paginate .paginate_button.next {
    font-size: 0;
}

.dataTables_paginate .paginate_button.previous::before {
    content: 'Précédent';
    font-size: 0.95rem;
}

.dataTables_paginate .paginate_button.next::after {
    content: 'Suivant';
    font-size: 0.95rem;
}

/* Centrer la pagination */
.dataTables_wrapper .dataTables_paginate {
    display: flex !important;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-top: 30px;
    width: 100%;
    flex-wrap: nowrap; /* Force la pagination sur une seule ligne */
    overflow-x: auto; /* Ajoute un scroll horizontal si nécessaire */
    overflow-y: hidden;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    margin: 0 3.5px;
    flex-shrink: 0; /* Empêche les boutons de rétrécir */
}

/* Mode sombre */
.dark-mode .dataTables_paginate .paginate_button {
    background-color: #333;
    color: #f0f0f0;
}

.dark-mode .dataTables_paginate .paginate_button:hover {
    background-color: #444;
    color: var(--primary-color);
}

.dark-mode .dataTables_paginate .paginate_button.current {
    background-color: var(--primary-color);
    color: white;
}

/* Animation de chargement personnalisée */
.dataTables_processing {
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    padding: 15px 20px !important;
    color: var(--text-color) !important;
    font-weight: 500 !important;
    z-index: 1000 !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: auto !important;
    margin-left: 0 !important;
    margin-top: 0 !important;
}

/* Chargeur personnalisé avec la couleur primaire */
.custom-loader {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 30px;
}

.custom-loader::before {
    content: "";
    position: absolute;
    left: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    border-top-color: transparent;
    animation: spinner 0.8s linear infinite;
}

.loader-text {
    margin-left: 10px;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Loader pour recipes-loader et themes-loader (utilisé dans AJAX) */
.recipes-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.recipes-loader .spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    border-top-color: transparent;
    animation: spinner 0.8s linear infinite;
    margin-bottom: 15px;
}

.recipes-loader p {
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

/* Mode sombre */
.dark-mode .dataTables_processing {
    background: rgba(30, 30, 30, 0.9) !important;
    color: #f0f0f0 !important;
}

/* Suppression des styles DataTables par défaut pour l'indicateur de chargement */
.dataTables_processing div:not(.custom-loader) {
    display: none !important;
}

/* Responsive - Tablettes */
@media (max-width: 768px) and (min-width: 481px) {
    #recettes-table tbody {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #recettes-table .recipe-card {
        height: 405px; /* Hauteur ajustée pour image 280px */
    }
    
    /* La hauteur d'image (280px) est gérée par components/recipe-card.css */
}

/* Responsive - Mobiles */
@media (max-width: 480px) {
    #recettes-table tbody {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    #recettes-table .recipe-card {
        height: 305px; /* Hauteur ajustée pour image 210px */
    }

    /* La hauteur d'image (210px) est gérée par components/recipe-card.css */

    .dataTables_paginate .paginate_button {
        padding: 6px 8px;
        font-size: 0.85rem;
        min-width: 32px;
        min-height: 32px;
        margin: 0 2px;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        margin: 0 2px;
    }
}

/* Très petits écrans */
@media (max-width: 320px) {
    #recettes-table tbody {
        grid-template-columns: repeat(1, 1fr);
    }
    
    #recettes-table .recipe-card {
        height: 305px; /* Hauteur ajustée pour image 210px */
    }
    
    /* La hauteur d'image (210px) est gérée par components/recipe-card.css */
}