/* ==========================================================================
   VARIABLES GLOBALES (:root)
   ========================================================================== */
:root {
    --bg-primary: #f0f4f8;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --accent-primary: #2b6cb0;
    --accent-hover: #2c5282;
    --heart-color: #e53e3e;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.10);
    --transition-smooth: all 0.3s ease;
    --border-radius: 16px;
}

/* ==========================================================================
   RÉINITIALISATION ET TYPOGRAPHIE
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.glass-blur-bg {
    position: fixed;
    inset: 0; /* Correction : évite le défilement horizontal fantôme */
    background: radial-gradient(circle at 15% 50%, rgba(43, 108, 176, 0.08), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(43, 108, 176, 0.08), transparent 25%);
    z-index: -1;
}

/* ==========================================================================
   STRUCTURE PRINCIPALE
   ========================================================================== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.app-header {
    text-align: center;
    margin-bottom: 3rem;
}

.app-subtitle {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================================================
   PANNEAU DE CONTRÔLE (RECHERCHE & FILTRES)
   ========================================================================== */
.control-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    margin-bottom: 3rem;
}

.search-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
}

#searchInput {
    width: 100%;
    padding: 1.2rem 1.2rem 1.2rem 3.5rem;
    font-size: 1.1rem;
    font-family: inherit;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    background: white;
    color: var(--text-primary);
    transition: var(--transition-smooth);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

/* Correction : Supprime les coins arrondis du bas quand les suggestions sont ouvertes */
#searchInput.dropdown-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0 0 12px 12px;
    margin-top: -5px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    max-height: 250px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
}

.suggestion-item:hover {
    background: rgba(43, 108, 176, 0.05);
    color: var(--accent-primary);
}

.filters-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.select-custom {
    position: relative;
    background: white;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    display: flex;
    align-items: center;
    transition: var(--transition-smooth);
}

.select-custom:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

.select-icon {
    position: absolute;
    left: 1rem;
    color: var(--accent-primary);
}

select, input[type="date"], input[type="month"] {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
}

/* Correction : Espacement pour ne pas chevaucher l'icône calendrier native */
input[type="date"], input[type="month"] {
    padding-right: 2rem; 
}

/* Correction : Ajout de la flèche SVG personnalisée pour le menu déroulant */
select {
    appearance: none; 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%234a5568'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.5em;
    padding-right: 2.5rem;
}

input[type="month"]::-webkit-calendar-picker-indicator {
    filter: invert(0.5); 
    cursor: pointer;
}

/* ==========================================================================
   BOUTONS D'ACTION (Réinitialiser, Favoris, Imprimer)
   ========================================================================== */
.favorites-wrapper {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed rgba(0,0,0,0.1);
}

.btn-action {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1.2rem;
    transition: var(--transition-smooth);
    flex: 1;
    min-width: 200px;
}

.btn-reset:hover, .btn-clear-fav:hover {
    background: rgba(220, 53, 69, 0.08);
    color: #bd2130;
    border-color: rgba(220, 53, 69, 0.2);
}

.btn-reset:hover i {
    transform: rotate(-180deg);
}

.btn-fav-toggle:hover, .btn-print:hover {
    background: rgba(43, 108, 176, 0.08);
    color: var(--accent-primary);
    border-color: rgba(43, 108, 176, 0.2);
}

/* État actif pour le bouton "Voir mes favoris" */
.btn-fav-toggle.active {
    background: var(--heart-color);
    color: white;
    border-color: var(--heart-color);
}

.status-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

/* ==========================================================================
   GRILLE DE RÉSULTATS ET BADGES
   ========================================================================== */
.cards-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.02);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-header { margin-bottom: 1.5rem; }

.tag-categorie {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(43, 108, 176, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.card-body {
    flex-grow: 1;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.card-body p { margin-bottom: 0.8rem; }
.card-body strong { color: var(--text-primary); }

.card-body-desc {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-action { margin-top: 1.5rem; }

.btn-site {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.btn-site:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.card-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge-acces {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

.badge-gratuit { background-color: rgba(40, 167, 69, 0.15); color: #1e7e34; }
.badge-payant { background-color: rgba(220, 53, 69, 0.15); color: #bd2130; }
.badge-mixte { background-color: rgba(255, 193, 7, 0.2); color: #b38600; }
.badge-inconnu { background-color: rgba(108, 117, 125, 0.15); color: #545b62; }

/* ==========================================================================
   CHECKBOX FAVORIS
   ========================================================================== */
.favori-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    user-select: none;
}

/* Correction : Rendre l'input accessible au clavier sans être visible à l'écran */
.favori-label input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.favori-custom {
    display: flex;
    align-items: center;
    justify-content: center;
}

.favori-custom i {
    color: #cbd5e0;
    font-size: 1.3rem;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s;
}

.favori-label:hover .favori-custom i {
    color: #fc8181;
    transform: scale(1.1);
}

.favori-label input:checked + .favori-custom i {
    color: var(--heart-color);
    transform: scale(1.15);
}

.favori-label input:checked ~ span {
    color: var(--heart-color);
}

/* Correction : État de focus pour la navigation au clavier */
.favori-label input:focus + .favori-custom i {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 50%;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
.pulse-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    margin-right: 12px;
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(43, 108, 176, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(43, 108, 176, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(43, 108, 176, 0); }
}

/* ==========================================================================
   IMPRESSION (@media print)
   ========================================================================== */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .glass-blur-bg,
    .control-panel,
    .app-header p,
    .app-subtitle,
    .btn-site {
        display: none !important;
    }

    .main-container {
        padding: 0;
        max-width: 100%;
    }

    .app-header h1 {
        font-size: 24px;
        margin-bottom: 20px;
        color: black;
    }

    .cards-layout {
        display: block;
    }

    .card {
        page-break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd;
        margin-bottom: 20px;
        padding: 15px;
        transform: none !important;
    }

    .card-body-desc {
        -webkit-line-clamp: unset; 
        display: block;
    }

    .favori-label {
        display: none !important; 
    }
}