:root {
    --primary: #009639;
    --primary-hover: #007c30;
    --primary-light: #e8f5ec;
    --secondary: #f7d618;
    --accent: #ce1126;
    --background: #f8fafc;
    --surface: #ffffff;
    --foreground: #0f172a;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --transition: 0.2s ease;
    --sidebar-width: 280px;
}

/* ============================================
   LAYOUT
   ============================================ */
.catalogue-page {
    display: flex;
    min-height: calc(100vh - 70px);
    background: var(--background);
}

/* ============================================
   SIDEBAR FILTRES
   ============================================ */
.filters-sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    min-height: calc(100vh - 70px);
    flex-shrink: 0;
    z-index: 100;
    /* Plus de sticky, plus de height fixe */
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
}

.sidebar-title i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.clear-filters-btn {
    font-size: 0.75rem;
    color: var(--muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.clear-filters-btn:hover {
    background: var(--border-light);
    color: var(--accent);
}

.sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--border-light);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--muted);
}

/* Filter Groups */
.filter-group {
    border-bottom: 1px solid var(--border-light);
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.filter-header:hover {
    background: var(--border-light);
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
}

.filter-label i {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.filter-count {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--surface);
    background: var(--primary);
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    min-width: 16px;
    text-align: center;
    margin-left: 0.5rem;
}

.filter-toggle {
    width: 18px;
    height: 18px;
    color: var(--muted-light);
    transition: transform var(--transition);
}

.filter-group.open .filter-toggle {
    transform: rotate(180deg);
}

.filter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.filter-group.open .filter-content {
    max-height: 350px;
    overflow-y: auto;
}

.filter-options {
    padding: 0 1.25rem 1rem;
}

/* Search in filter */
.filter-search {
    position: relative;
    margin-bottom: 0.625rem;
}

.filter-search input {
    width: 100%;
    padding: 0.4rem 0.625rem 0.4rem 1.75rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    transition: var(--transition);
}

.filter-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.filter-search i {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    color: var(--muted-light);
}

/* Checkboxes */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--foreground);
    transition: var(--transition);
}

.filter-checkbox:hover {
    color: var(--primary);
}

.filter-checkbox input {
    display: none;
}

.checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkbox-custom i {
    width: 10px;
    height: 10px;
    color: white;
    opacity: 0;
    transform: scale(0);
    transition: var(--transition);
}

.filter-checkbox input:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.filter-checkbox input:checked + .checkbox-custom i {
    opacity: 1;
    transform: scale(1);
}

.checkbox-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checkbox-count {
    font-size: 0.6875rem;
    color: var(--muted-light);
}

/* Select */
.filter-select {
    width: 100%;
    padding: 0.4rem 2rem 0.4rem 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.4rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Quick tags */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.quick-tag {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: var(--transition);
}

.quick-tag:hover,
.quick-tag.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Sidebar footer mobile */
.sidebar-footer {
    display: none;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    bottom: 0;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    /* Plus de sticky */
}


.mobile-filter-btn {
    display: none;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.mobile-filter-btn i {
    width: 16px;
    height: 16px;
}

.filter-badge {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--surface);
    background: var(--primary);
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
}

/* Search */
.search-bar-epreuve {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.search-bar-epreuve input {
    width: 100%;
    padding: 0.5rem 0.875rem 0.5rem 2.25rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--background);
}

.search-bar-epreuve input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.search-bar-epreuve > i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted-light);
}

/* Sort & View */
.view-options {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-left: auto;
}

.sort-select {
    padding: 0.4rem 2rem 0.4rem 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.4rem center;
    background-repeat: no-repeat;
    background-size: 1.25em;
    cursor: pointer;
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.view-btn {
    padding: 0.4rem 0.5rem;
    background: var(--surface);
    border: none;
    cursor: pointer;
    color: var(--muted);
    transition: var(--transition);
}

.view-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.view-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.view-btn i {
    width: 16px;
    height: 16px;
}

/* Active Filters */
.active-filters {
    background: var(--surface);
    padding: 0.625rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.active-filters.has-filters {
    display: flex;
}

.active-filters-label {
    font-size: 0.75rem;
    color: var(--muted);
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.375rem 0.2rem 0.625rem;
    font-size: 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 9999px;
}

.active-filter-tag button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: none;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    border-radius: 50%;
}

.active-filter-tag button:hover {
    background: var(--primary);
    color: white;
}

.active-filter-tag button i {
    width: 10px;
    height: 10px;
}

/* Results info */
.results-info {
    padding: 0.75rem 1.25rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.results-count {
    font-size: 0.875rem;
    color: var(--muted);
}

.results-count strong {
    color: var(--foreground);
    font-weight: 600;
}

/* ============================================
   GRILLE DES ÉPREUVES
   ============================================ */
.epreuves-container {
    padding: 0.75rem 1.25rem 2rem;
    flex: 1;
}

.epreuves-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.epreuves-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* Card */
.epreuve-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.epreuve-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-preview {
    position: relative;
    aspect-ratio: 3/4;
    background: var(--border-light);
    overflow: hidden;
}

.card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.epreuve-card:hover .card-preview img {
    transform: scale(1.03);
}

.card-badges {
    position: absolute;
    top: 0.625rem;
    left: 0.625rem;
    right: 0.625rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-type {
    background: var(--primary);
    color: white;
}

.badge-correction {
    background: var(--secondary);
    color: var(--foreground);
}

.badge-premium {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.card-pages {
    position: absolute;
    bottom: 0.625rem;
    right: 0.625rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 500;
}

.card-pages i {
    width: 10px;
    height: 10px;
}

.card-body {
    padding: 0.875rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-category {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 0.25rem;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.card-title a {
    color: inherit;
    text-decoration: none;
}

.card-title a:hover {
    color: var(--primary);
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.625rem;
    border-top: 1px solid var(--border-light);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: var(--muted);
}

.meta-item i {
    width: 12px;
    height: 12px;
}

/* List view */
.epreuves-list .epreuve-card {
    flex-direction: row;
}

.epreuves-list .card-preview {
    width: 100px;
    aspect-ratio: auto;
    height: 130px;
    flex-shrink: 0;
}

.epreuves-list .card-body {
    padding: 0.75rem 1rem;
}

.epreuves-list .card-badges {
    position: static;
    margin-bottom: 0.375rem;
    justify-content: flex-start;
    gap: 0.375rem;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 1.5rem 1.25rem;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn i {
    width: 16px;
    height: 16px;
}

.page-ellipsis {
    padding: 0 0.375rem;
    color: var(--muted-light);
    font-size: 0.8125rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    color: var(--muted-light);
}

.empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.375rem;
}

.empty-text {
    font-size: 0.875rem;
    color: var(--muted);
    max-width: 360px;
    margin: 0 auto 1rem;
}

.empty-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

/* ============================================
   OVERLAY MOBILE
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .filters-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 300;
        box-shadow: var(--shadow-md);
    }

    .filters-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-footer {
        display: block;
    }

    .sidebar-close {
        display: flex;
    }

    .mobile-filter-btn {
        display: flex;
    }

    .clear-filters-btn {
        display: none;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-wrap: wrap;
        gap: 0.625rem;
        top: 60px;
    }

    .search-bar-epreuve {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }

    .view-options {
        margin-left: 0;
    }

    .sort-select {
        display: none;
    }

    .epreuves-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.625rem;
    }

    .card-body {
        padding: 0.625rem;
    }

    .card-title {
        font-size: 0.8125rem;
    }

    .card-meta {
        display: none;
    }

    .epreuves-list .epreuve-card {
        flex-direction: column;
    }

    .epreuves-list .card-preview {
        width: 100%;
        height: auto;
        aspect-ratio: 3/4;
    }

    .filters-sidebar {
        top: 0;
    }
}

@media (max-width: 480px) {
    .epreuves-grid {
        grid-template-columns: 1fr;
    }

    .view-toggle {
        display: none;
    }

    .results-info {
        padding: 0.625rem 1rem;
    }

    .epreuves-container {
        padding: 0.625rem 0.75rem 1.5rem;
    }
}

/* Button primary */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


.card-preview img {
    pointer-events: none;
    -webkit-user-drag: none;
    user-drag: none;
}

@media print {
    .epreuves-grid,
    .epreuves-list {
        display: none !important;
    }
}