/* ===== VARIABLES CSS ===== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
    --header-height: 48px;
    --header-padding-x: 1.5rem;
}

/* ===== RESET ET BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.is-hidden {
    display: none !important;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
    color: var(--text-primary);
    background-color: var(--bg-color);
    padding-top: 0;
}

/* ===== HEADER ET NAVIGATION ===== */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    padding: 0;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1002;
    box-shadow: var(--shadow-md);
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: border-box;
}

.header-content {
    padding: 0 var(--header-padding-x);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: var(--header-height);
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0;
    line-height: 1.2;
}

.site-title {
    margin: 0;
}

.home-button {
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    line-height: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.home-button:hover {
    opacity: 0.95;
}

.home-button:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.65);
    outline-offset: 4px;
    border-radius: 8px;
}

.header-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    line-height: 1.4;
    padding-top: 0.1rem;
}

/* ===== NAVIGATION RAPIDE ===== */
.quick-nav {
    background: white;
    padding: 0.4rem 0;
    position: sticky;
    top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    left: 0;
    right: 0;
    z-index: 1001;
    box-shadow: var(--shadow-sm);
    border-bottom: 2px solid var(--border-color);
}

.nav-container {
    padding: 0 2rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.nav-btn {
    padding: 0.28rem 0.8rem;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 18px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

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

/* ===== BARRE DE RECHERCHE ===== */
.search-container {
    flex: 0 1 380px;
    max-width: 420px;
    min-width: 220px;
    position: relative;
}

.search-box {
    width: 100%;
    padding: 0.38rem 0.9rem 0.38rem 2.2rem;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.78rem;
    transition: var(--transition);
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* ===== CONTAINER PRINCIPAL ===== */
.container {
    max-width: 1600px;
    margin: 0.5rem auto;
    padding: 0 2rem 3rem 2rem;
}

/* ===== SECTIONS DE CONTENU ===== */
.section {
    margin-bottom: 1.2rem;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--primary-color);
}

.section-number {
    background: var(--primary-color);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 0.5rem;
    font-size: 0.9rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== GRILLE DE RESSOURCES ===== */
.resources-grid {
    display: grid;
    gap: 0.6rem;
}

/* ===== CARTES DE RESSOURCES ===== */
.resource-card {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 0.6rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.resource-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: var(--transition);
}

.resource-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.resource-card:hover::before {
    transform: scaleY(1);
}

.resource-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.4rem;
    gap: 0.4rem;
}

.resource-title {
    flex: 1;
}

.resource-title a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

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

.resource-icon {
    font-size: 1rem;
}

.resource-description {
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.35;
    font-size: 0.8rem;
}

/* ===== BADGES ===== */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.4rem;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 15px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-cours {
    background: #dbeafe;
    color: #1e40af;
}

.badge-td {
    background: #d1fae5;
    color: #065f46;
}

.badge-exercice {
    background: #fef3c7;
    color: #92400e;
}

.badge-correction {
    background: #ddd6fe;
    color: #5b21b6;
}

/* ===== FICHIERS ASSOCIES ===== */
.resource-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border-color);
}

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-color);
    border-radius: 5px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.7rem;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.file-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.file-icon {
    font-size: 0.9rem;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.contact-email {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

.contact-email:hover {
    text-decoration: underline;
}

/* ===== BOUTON RETOUR EN HAUT ===== */
.back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--primary-color);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    border: none;
    font-size: 1.1rem;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-5px);
}

/* ===== MESSAGE AUCUN RESULTAT ===== */
.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    display: none;
}

.no-results.visible {
    display: block;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    :root {
        --header-height: 62px;
        --header-padding-x: 1rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .quick-nav {
        top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    }

    .nav-container {
        justify-content: center;
    }

    .search-container {
        width: 100%;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .resource-header {
        flex-direction: column;
    }

    .container {
        padding: 0 1rem;
    }
}

/* ===== TOOLTIPS ===== */
.tooltip {
    position: relative;
}

.tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-md);
}

.tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-primary);
    margin-bottom: -6px;
}
