:root {
    --primary-color: #2c3e50;
    --bg-color: #f8f9fa;
    --text-color: #333;
    --sidebar-width: 250px;
    --header-height: 60px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, -apple-system, BlinkMacSystemFont, "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.4;
}

/* Style pour les task-lists si on utilise des inputs */
.task-list-item {
    list-style-type: none;
}
.task-list-item input {
    margin: 0 10px 0 -20px;
    vertical-align: middle;
}

header {
    background-color: #2c3e50;
    color: white;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    color: white !important;
    /* Force le texte en blanc */
}

.container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

#sidebar {
    width: var(--sidebar-width);
    background-color: white;
    border-right: 1px solid #ddd;
    padding: 1rem;
    position: fixed;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

#content {
    flex: 1;
    margin-left: calc( var(--sidebar-width) + 2rem );
    padding: 0 2rem;
    max-width: 900px;
}

#toc ul {
    list-style: none;
    padding-left: 0;
}

#toc li {
    margin-bottom: 0.5rem;
}

#toc a {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.95rem;
}

#toc a:hover {
    text-decoration: underline;
}

h1,
h2,
h3 {
    color: var(--primary-color);
}

h2 {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    #sidebar {
        display: none;
    }

    #content {
        margin-left: 0;
        padding: 1rem;
    }
}

/* Media Containers */
.video-container,
.iframe-container,
.geogebra-container {
    margin: 2rem 0;
    text-align: center;
}

.video-container iframe,
.video-container video {
    max-width: 100%;
    width: 800px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
}

.geogebra-container {
    background: #eee;
    min-height: 200px;
    display: flex;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

/* Print Styles */
@media print {

    html,
    body {
        height: auto !important;
        overflow: visible !important;
        background-color: white !important;
        color: black !important;
        font-size: 10pt !important;
    }

    p {
        margin: 0.3rem 0 !important;
    }

    h1 { font-size: 1.6rem !important; margin-top: 0 !important; }
    h2 { font-size: 1.4rem !important; margin-top: 1rem !important; }
    h3 { font-size: 1.2rem !important; margin-top: 0.8rem !important; }
    h4 { font-size: 1rem !important; margin-top: 0.5rem !important; }

    .no-print,
    header,
    #sidebar,
    #loading,
    #editor-pane,
    .toolbar {
        display: none !important;
    }

    .container {
        margin-top: 0 !important;
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    #content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        overflow: visible !important;
        display: block !important;
    }

    .pedagogical-block {
        background-color: white !important;
        border: 1px solid #ccc !important;
        border-left: 5px solid black !important;
        box-shadow: none !important;
        page-break-inside: auto;
        /* Permet la coupure du bloc */
    }

    .pedagogical-block h3,
    .pedagogical-block h4 {
        color: black !important;
        page-break-after: avoid;
        /* Empêche de laisser le titre seul en bas de page */
        break-after: avoid;
    }

    .pedagogical-block p:first-of-type {
        page-break-before: avoid;
        /* Aide à garder le premier paragraphe avec le titre */
        break-before: avoid;
    }

    iframe,
    video,
    .geogebra-container canvas {
        display: none !important;
    }

    /* Keep images together */
    img {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .qr-code {
        display: block !important;
        margin: 10px auto;
        text-align: center;
    }

    .qr-code img {
        width: 100px;
        /* Taille réduite */
    }

    .qr-url {
        display: none;
        /* Cache l'URL */
    }

    /* Icônes pour le print */
    .video-container::before {
        content: "📹 Vidéo ";
        display: block;
        font-weight: bold;
    }

    /* Supposons que les liens vers les exerciseurs aient une classe ou un motif */
    a[href*="exerciseur"]:after {
        content: " 📝 Exercice";
        font-weight: bold;
    }

    a {
        text-decoration: none;
        color: black !important;
    }
}

/* Hide QR codes by default on screen */
.qr-code {
    display: none;
}

#print-btn {
    margin-left: auto;
    background-color: #34495e;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

#print-btn:hover {
    background-color: #415b76;
}

/* Home Menu Styles */
#home-menu {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.grade-section {
    margin-bottom: 3rem;
}

.grade-title {
    font-size: 1.8rem;
    border-left: 8px solid;
    padding-left: 1rem;
    margin-bottom: 1.5rem;
}

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

.course-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border-top: 5px solid;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.course-card h4 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    flex-grow: 1;
}

.card-footer {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-weight: bold;
    text-align: right;
    margin-top: 1rem;
}

/* Specific Grade Colors */
.grade-6e .grade-title,
.grade-6e .course-card {
    border-color: #3498db;
}

.grade-5e .grade-title,
.grade-5e .course-card {
    border-color: #2ecc71;
}

.grade-4e .grade-title,
.grade-4e .course-card {
    border-color: #e67e22;
}

.grade-3e .grade-title,
.grade-3e .course-card {
    border-color: #e74c3c;
}

.btn-home {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    margin-right: 1rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-home:hover {
    background: rgba(255, 255, 255, 0.1);
}

#sidebar.hidden {
    display: none;
}

#content.full-width {
    margin-left: 0;
    max-width: none;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: white;
}

table th,
table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: center;
}

table tr:nth-child(even) {
    background-color: #f9f9f9;
}

table th {
    background-color: #2c3e50;
    color: white;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
}
