:root {
    --primary-color: #1a4d8c;
    --hover-color: #2c6fc1;
    --bg-color: #f5f5f5;
    --text-color: #000000;
    --card-bg: #ffffff;
    --header-bg: var(--primary-color);
    --header-text: #ffffff;
    --aside-bg: #ffffff;
    --border-color: #dee2e6;
    --card-hover-bg: #e9ecef;
}

@font-face {
    font-family: 'Luciole';
    src: url('../polices/Luciole-Regular.ttf') format('truetype');
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Liberation';
    src: url('../polices/LiberationSans-Regular.ttf') format('truetype');
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../polices/Inter.ttf') format('truetype');
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Roboto';
    src: url('../polices/Roboto.ttf') format('truetype');
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'OpenDyslexic';
    src: url('../polices/OpenDyslexic-Regular.otf') format('opentype');
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'BelleAllure';
    src: url('../polices/BelleAllureCM-Fin.otf') format('opentype');
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Oswald';
    src: url('../polices/Oswald.ttf') format('truetype');
    font-style: normal;
    font-display: swap;
}

body {
    font-family: var(--font-family, Liberation, sans-serif) !important;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden; 
    width: 100%;
    box-sizing: border-box;
}

.footer {
    margin-top: 2px;
    text-align: center !important;
    padding: 20px;
    color: var(--text-color) !important;
    /*background-color: #f4f4f4;*/
    /*border-radius: 10px;*/
    font-size: clamp(10px, 12px, 12px);
    font-family: Liberation !important;
}

.footer a {
    color: blue;
    text-decoration: underline;
}

.license {
    font-size: 10px;
    /*margin-top: 10px;*/
    text-align: center !important;
    color: var(--text-color) !important;
}

.license a {
    color: blue;
    text-decoration: underline;
}

/* Styles pour le footer personnalisé */
.custom-footer {
    padding: 20px;
    text-align: center;
    line-height: 1.6;
    white-space: pre-line; /* Preserve line breaks from markdown */
    font-size: clamp(14px, 18px, 25px) !important;
}

.custom-footer p {
    margin: 10px 0;
}

.custom-footer a {
    color: var(--primary-color, #1a4d8c);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.custom-footer a:hover {
    color: var(--hover-color, #1a4d8ccc);
    text-decoration: none;
}

.custom-footer a:visited {
    color: var(--primary-color, #1a4d8c);
}

/* Style pour le thème sombre */
.dark-theme .custom-footer {
    background-color: var(--card-bg, #2d2d2d);
    color: var(--text-color, #ffffff);
}

.dark-theme .custom-footer a {
    color: var(--primary-color, #6db4ff);
}

.dark-theme .custom-footer a:hover {
    color: var(--hover-color, #6db4ffcc);
}

.dark-theme .custom-footer a:visited {
    color: var(--primary-color, #6db4ff);
}

.header {
    background-color: var(--header-bg);
    font-family: var(--font-family, Liberation, sans-serif) !important;
    color: var(--header-text);
    padding: 15px;
    text-align: center;
    margin: 0 auto 30px auto;
    border-radius: 10px;
    width: 90%; 
    max-width: 1200px;
    box-sizing: border-box;
    }

#index-title {
    font-size: 40px;
    font-family: var(--font-family, Liberation, sans-serif) !important;
}

.subtitle-container {
    margin: 20px auto;
    padding: 15px 20px;
    background-color: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 1000px;
}

.subtitle-text {
    margin: 0;
    font-size: 1em;
    color: var(--text-color); 
    font-weight: 500;
    font-family: var(--font-family); 
}

.instructions {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    border-left: 4px solid #0d6efd;
    font-family: Liberation, sans-serif !important;
}

.category-section {
    background-color: var(--card-bg);
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    border-radius: 20px;
}


/*.category-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}*/

.category-title {
    font-family: var(--font-family, Liberation, sans-serif) !important;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 2em;
    text-align: center;
}

#ressources-container {
    font-family: var(--font-family, Liberation, sans-serif) !important;
    font-size: 13px;
    display: grid;
    gap: 20px;
    width: 100%;
    max-width: 1400px; 
    margin: 0 auto;
}

.ressource-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); 
    gap: 5px; 
    width: 100%;
    /*padding: 10px;*/
}

.ressource-card {
    background-color: var(--bg-color);
    border-color: var(--border-color);
    border-width: var(--resource-card-border-width, 1px);
    border-style: var(--resource-card-border-style, solid);
    border-radius: 10px;
    /*color: var(--text-color) !important;*/
    color: var(--text-color);
    padding: 10px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    height: var(--card-height, 160px) !important;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-family: var(--font-family, Liberation, sans-serif) !important;
    font-size: clamp(10px, var(--resource-card-text-size, 13px), var(--resource-card-text-size, 13px));
}

.ressource-card .image-container {
    width: 100%;
    height: 100%; 
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Empêche l'image de dépasser */
}

.ressource-card .image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Garde les proportions */
}


.ressource-card:hover {
    transform: translateY(-2px);
    background-color: var(--card-hover-bg);
    border-color: var(--primary-color);
}

.url-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.3;
    max-width: 300px;
    z-index: 9999;
    pointer-events: none;
    white-space: normal;          
    word-wrap: break-word;        
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
.url-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}


/* Styles pour les liens dans le subtitle */
.subtitle-text a {
    color: var(--primary-color, #1a4d8c);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.subtitle-text a:hover {
    color: var(--hover-color, #1a4d8ccc);
    text-decoration: none;
}

.subtitle-text a:visited {
    color: var(--primary-color, #1a4d8c);
}


.dark-theme .subtitle-text a {
    color: var(--primary-color, #6db4ff);
}

.dark-theme .subtitle-text a:hover {
    color: var(--hover-color, #6db4ffcc);
}

.dark-theme .subtitle-text a:visited {
    color: var(--primary-color, #6db4ff);
}

.ressource-card a {
    display: block;
    text-decoration: none;
    color: inherit !important;
}

.ressource-card h3 {
    color: var(--text-color);
    margin: 0;
    font-size: 0.8rem; 
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

a {
    text-decoration: none;
    color: var(--text-color);
}

.instructions a {
    color: blue;
    text-decoration: underline;
}

.image-card {
    height: 120px; 
    padding: 5px;
}

.image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-card img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.error-message {
    color: #dc3545;
    text-align: center;
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
    background-color: rgba(220, 53, 69, 0.1);
    display: none;
}

.help-toggle {
    position: absolute; 
    right: 20px;
    top: 20px;
    background-color: transparent;
    color: var(--text-color);
    border: none;
    width: 40px;
    height: 40px;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

aside {
    position: fixed;
    font-family: Liberation, sans-serif !important;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 1000px; 
    height: 100vh;
    background-color: var(--aside-bg);
    color: var(--text-color);
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}
aside a {
    color: blue;
    text-decoration: underline;
}

aside.open {
    right: 0;
}

.close-aside {
    float: right;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 1001;
    padding: 5px;
    color: var(--text-color);
    top: 5px;
}

.welcome-message {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-message p {
    margin: 10px 0;
    line-height: 1.6;
}

body.dark-theme {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --card-bg: #2d2d2d;
    --header-bg: #2d2d2d;
    --header-text: #ffffff;
    --aside-bg: #2d2d2d;
    --border-color: #404040;
    --card-hover-bg: #404040;
}

body.dark-theme .category-title {
    color: var(--text-color);
    border-bottom-color: var(--text-color);
}

body.dark-theme a {
    color: #ffffff !important;
}

body.dark-theme .help-toggle {
    color: #ff6b6b;
}

body.dark-theme .welcome-message h2 {
    color: var(--text-color);
}

.markdown-link-input-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    gap: 10px;
}

#markdown-link-input {
    flex-grow: 1;
    max-width: 500px;
    padding: 10px;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-family: var(--font-family, Liberation, sans-serif);
}

#markdown-link-input:focus {
    outline: none;
    border-color: var(--hover-color);
    box-shadow: 0 0 5px rgba(44, 111, 193, 0.3);
}

#load-markdown-btn {
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    font-family: var(--font-family, Liberation, sans-serif);
}

#load-markdown-btn:hover {
    background-color: var(--hover-color);
    transform: translateY(-2px);
}

#load-markdown-btn:active {
    transform: translateY(0);
}

/* Styles spécifiques au thème sombre */
body.dark-theme #markdown-link-input {
    background-color: #2d2d2d;
    color: white;
    border-color: var(--text-color);
}

body.dark-theme #markdown-link-input:focus {
    border-color: #66b3ff;
    box-shadow: 0 0 5px rgba(102, 179, 255, 0.3);
}

body.dark-theme #load-markdown-btn {
    background-color: #66b3ff;
}

body.dark-theme #load-markdown-btn:hover {
    background-color: #3d91ff;
}

/* Styles pour le titre avec images */
.title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: relative;
    min-height: 80px;
}

.title-image-container {
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-image {
    max-height: 100px;
    max-width: 100px;
    border-radius: 8px;
}

.title-text {
    font-family: var(--titre-font-family, var(--font-family, Liberation, sans-serif)) !important;
    font-size: clamp(24px, var(--titre-font-size, 36px), var(--titre-font-size, 36px));
    margin: 0;
    text-align: center;
    flex: 1;
}

.image-sous-container {
    text-align: center;
    margin: 20px 0;
}

.image-sous {
    /*max-width: 200px;*/
    height: auto;
    border-radius: 8px;
}

.footer-image {
    max-width: 150px !important;
    height: auto !important;
    margin: 10px auto !important;
    display: block !important;
    border-radius: 8px;
}

/* responsive */

@media (max-width: 600px) {
    .markdown-link-input-container {
        flex-direction: column;
        gap: 15px;
    }

    #markdown-link-input, 
    #load-markdown-btn {
        width: 100%;
        max-width: none;
    }
    .title-image {
        display: none !important;
        visibility: hidden !important;
    }
    .title-text {
        margin: 0;
        text-align: center;
        flex: 1;
        font-size: clamp(20px, var(--titre-font-size, 36px), 30px) !important;
        margin: 0 auto;
    }
    .ressource-card {
        font-size: clamp(10px, var(--resource-card-text-size, 20px), 20px) !important;
    }

    .custom-footer {
        font-size: clamp(14px, 2vw, 24px) !important;
        padding: 15px;
    }
    
    .footer {
        font-size: clamp(14px, 2vw, 24px) !important;
        padding: 15px;
    }
    
    .image-sous {
        max-width: 200px;
    }
}


@media (max-width: 768px) {
    #ressources-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .header {
        width: 90%;
    }

    .title-text {
        margin: 0;
        text-align: center;
        flex: 1;
        font-size: clamp(20px, var(--titre-font-size, 36px), 30px) !important;
        margin: 0 auto;
    }
    
    .custom-footer {
        font-size: clamp(14px, 2vw, 24px) !important;
        padding: 15px;
    }
    
    .footer {
        font-size: clamp(14px, 2vw, 24px) !important;
        padding: 15px;
    }

    .ressource-card {
        font-size: clamp(10px, var(--resource-card-text-size, 20px), 20px) !important;
    }

    .title-image {
        max-height: 60px;
        max-width: 100px;
        border-radius: 8px;
    }

    .image-sous {
        max-width: 200px;
    }

}

@media (max-width: 480px) {
    #ressources-container {
        grid-template-columns: 1fr !important;
    }
    
    .header h1 {
        font-size: 1.5em;
    }

    .ressource-list {
        grid-template-columns: 1fr !important;
    }

    .title-container {
        /*flex-direction: row;*/
        justify-content: center;
    }

    .title-image {
        display: none !important;
        visibility: hidden !important;
    }

    .title-text {
        margin: 0;
        text-align: center;
        flex: 1;
        font-size: clamp(18px, var(--titre-font-size, 36px), 24px) !important;
        margin: 0 auto;
    }

    .ressource-card {
        font-size: clamp(9px, var(--resource-card-text-size, 20px), 20px) !important;
    }

    .custom-footer {
        font-size: clamp(14px, 2vw, 24px) !important;
        padding: 10px;
    }
    
    .footer {
        font-size: clamp(14px, 2vw, 24px) !important;
        padding: 10px;
    }

    .image-sous {
        max-width: 200px;
    }

}

@media (max-width: 1200px) {
    .ressource-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    title-text {
        margin: 0;
        text-align: center;
        flex: 1;
        font-size: 30px !important;
        margin: 0 auto;
    }
}

/* Loader */
.loader {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid var(--bg-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Message d'erreur */
.error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff5252;
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: none;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    max-width: 200px;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    font-family: Liberation, sans-serif !important;
}

body.dark-theme .tooltip {
    font-family: Liberation, sans-serif !important;
    background: rgba(255, 255, 255, 0.9);
    color: black;
}

body.dark-theme .loader {
    font-family: Liberation, sans-serif !important;
    border-color: var(--bg-color);
    border-top-color: var(--primary-color);
}