:root {
    /* Couleurs principales avec variables sémantiques */
    --hue-primary: 200deg;
    --color-primary: hsl(var(--hue-primary), 100%, 33%);
    --color-primary-10: hsla(var(--hue-primary), 100%, 33%, 0.1);
    --color-primary-20: hsla(var(--hue-primary), 100%, 33%, 0.2);
    --color-primary-30: hsla(var(--hue-primary), 100%, 33%, 0.3);
    --color-red: red;
    --color-orange: orange;

    /* Couleurs neutres */
    --color-background: hsl(240deg, 100%, 98%);
    --color-text: #222;
    --color-white: #fff;

    /* Transparences standardisées */
    --opacity-10: rgba(0, 0, 0, 0.1);
    --opacity-30: rgba(0, 0, 0, 0.3);
    --opacity-50: rgba(0, 0, 0, 0.5);

    /* Espacements */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Bordures */
    --border-radius: 0.3rem;
    --border-width: 1px;

    /* Typographie */
    --font-size-base: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --line-height: 1.5;

    /* Animations */
    --transition-speed: 0.15s;
    --transition-timing: ease-in-out;
    --global-transition: all 0.3s ease;

    --ss-primary-color: var(--color-primary);
    --ss-bg-color: var(--color-white);
    --ss-font-color: var(--color-text);
}

/* Reset moderne et minimaliste */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
	min-height: 100%;
	font-size: 16px;
    scroll-behavior: smooth;
}

/* Font Awesome */
@font-face {
    font-family: "Font Awesome";
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url(fonts/fontawesome-webfont.woff2) format("woff2"),
        url(fonts/fontawesome-webfont.woff) format("woff"),
        url(fonts/fontawesome-webfont.ttf) format("truetype")
}

/* Icones Font Awesome */
.fa {
    display: inline-block;
    font: normal normal normal 14px/1 "Font Awesome";
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.fa-user::before { content: "\f007"; }
.fa-check::before { content: "\f00c"; }
.fa-times::before { content: "\f00d"; }
.fa-home::before { content: "\f015"; }
.fa-lock::before { content: "\f023"; }
.fa-book::before { content: "\f02d"; }
.fa-print::before { content: "\f02f"; }
.fa-edit::before { content: "\f044"; }
.fa-chevron-left::before { content: "\f053"; }
.fa-chevron-right::before { content: "\f054"; }
.fa-minus-circle::before { content: "\f056"; }
.fa-plus::before { content: "\f067"; }
.fa-eye::before { content: "\f06e" !important; }
.fa-eye-slash::before { content: "\f070"; }
.fa-calendar-alt::before { content: "\f073"; }
.fa-cart-shopping::before { content: "\f07a"; }
.fa-credit-card::before { content: "\f09d"; }
.fa-users::before { content: "\f0c0"; }
.fa-bars::before { content: "\f0c9"; }
.fa-power-off::before { content: "\f011"; }
.fa-money-bill::before { content: "\f0d6"; }
.fa-file-alt::before { content: "\f15c"; }
.fa-graduation-cap::before { content: "\f19d"; }
.fa-history::before { content: "\f1da"; }
.fa-trash::before { content: "\f1f8"; }
.fa-chart-line::before { content: "\f201"; }

body {
    font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--font-size-base);
    font-weight: 400;
    line-height: var(--line-height);
    background-color: var(--color-background);
    color: var(--color-text);
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Liens */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-speed) var(--transition-timing);
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    border-bottom: solid var(--border-width) var(--color-primary);
}

thead {
    background-color: var(--color-primary);
    color: var(--color-white);
}

th,
td {
    padding: var(--space-sm);
    text-align: left;
}

td a:hover {
    font-weight: 600;
}

tbody tr:nth-child(even) {
    background-color: var(--color-primary-10);
}

tfoot th {
    border-top: solid var(--border-width) var(--color-primary);
}

/* Formulaires */
input,
select,
textarea {
    font: inherit;
    padding: var(--space-xs) var(--space-sm);
    border: var(--border-width) solid var(--opacity-30);
    border-radius: var(--border-radius);
    background-color: var(--color-white);
    color: var(--color-text);
    transition: border-color var(--transition-speed) var(--transition-timing),
                box-shadow var(--transition-speed) var(--transition-timing);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-20);
}

select {
    padding-right: var(--space-xl);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right var(--space-sm) center;
    background-size: 8px 10px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

textarea {
    min-height: 10em;
    resize: vertical;
}

form :where(div, p):has(> label + :where(input:not([type=checkbox]), select, textarea)) {
    display: flex;
    flex-direction: column;
}

label + :where(input:not([type=checkbox]), select),
textarea,
td input {
    width: 100%;
}

#gradetable input {
    width: 5em;
}

form p {
    margin: var(--space-sm) 0;
}

fieldset {
    padding: var(--space-md);
    border: var(--border-width) solid #ccc;
}
.grid2cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
.full-width {
    grid-column: 1 / -1;
}

/* Boutons */
button,
.button {
    display: inline-block;
    font: inherit;
    text-align: center;
    padding: var(--space-xs) var(--space-sm);
    border: var(--border-width) solid var(--color-primary-30);
    border-radius: var(--border-radius);
    background-color: var(--color-primary-20);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-speed) var(--transition-timing);
    user-select: none;
    vertical-align: middle;
}

button:hover,
button:focus,
.button:hover,
.button:focus {
    background-color: var(--color-primary-30);
    border-color: var(--color-primary-30);
}

/* Sidebar et navigation */
#nav-toggler {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: var(--space-sm);
    left: calc(250px - 1em);
    width: 2em;
    height: 2em;
    background-color: var(--color-white);
    border-radius: 1em;
    box-shadow: 0 0 5px var(--opacity-50);
    cursor: pointer;
    z-index: 4;
    transition: var(--global-transition);
}

#sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 250px;
    background: linear-gradient(0deg, hsl(80deg 48% 48%) -30%, var(--color-primary) 80%);
    color: var(--color-white);
    padding: var(--space-sm);
    text-shadow: 1px 1px var(--opacity-50);
    transition: var(--global-transition);
}

#sidebar header {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    white-space: nowrap;
}

#sidebar .brand,
#sidebar .user {
    position: relative;
    height: 3rem;
}

#sidebar .brand-logo,
#sidebar .user-photo {
    position: absolute;
    width: 3rem;
    height: 3rem;
    object-fit: cover;
    overflow: clip;
}

#sidebar .brand-name,
#sidebar .user-name {
    position: absolute;
    left: 3.25rem;
    right: 0;
    line-height: 3rem;
    overflow: clip;
    text-overflow: ellipsis;
}

#sidebar nav {
    flex-grow: 1;
    overflow: auto;
}

#sidebar ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

#sidebar li a {
    display: flex;
    align-items: center;
    height: 2.5em;
    width: 100%;
    color: var(--color-white);
    overflow: hidden;
    padding: var(--space-sm);
    border-radius: var(--border-radius);
}

#sidebar li a:hover,
#sidebar li a:focus {
    background-color: var(--opacity-10);
}

#sidebar li a.active {
    background-color: var(--opacity-50);
}

#sidebar li a > i,
#sidebar .fold-arrow {
    width: 2em;
    text-align: center;
    flex-shrink: 0;
}

#sidebar .nav-label {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar .fold-arrow {
    transition: var(--global-transition);
}

#sidebar li ul.submenu {
    opacity: 0;
    height: 0;
    visibility: hidden;
    background-color: var(--opacity-10);
    transition: var(--global-transition);
}

#sidebar li.show-menu ul.submenu {
    visibility: visible;
    height: 5.25rem;
    opacity: 1;
}

#sidebar li.show-menu .fold-arrow {
    transform: rotate(90deg);
}

#sidebar.shrink {
    width: 75px;
}

#sidebar.shrink .brand-name,
#sidebar.shrink .user-name,
#sidebar.shrink .nav-label,
#sidebar.shrink .fold-arrow {
    display: none;
}

#sidebar.shrink~#nav-toggler {
    left: calc(75px - 1em);
    transform: rotate(180deg);
}

/* Contenu principal */
#content {
    left: 250px;
}

#sidebar.shrink~#content {
    left: 75px;
}

/* Pages et modals */
.page {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    padding: var(--space-md);
    background-color: var(--color-background);
    box-shadow: -5px 0 10px var(--opacity-30);
    transition: var(--global-transition);
    z-index: 1;
}

#page1 {
    left: 350px;
    display: none;
}

#sidebar.shrink~#page1 {
    left: 175px;
}

#page2 {
    left: 450px;
    display: none;
}

#sidebar.shrink~#page2 {
    left: 275px;
}

.page-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    position: sticky;
    top: 0;
    padding-bottom: var(--space-sm);
    background-color: var(--color-background);
    border-bottom: var(--border-width) solid var(--color-primary);
    z-index: 2;
}

.page-header > * {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
}

.page-header > div:first-child {
    margin-right: 1.5rem;
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: 500;
    flex-grow: 1;
}

.page-close-btn {
    position: absolute;
    top: 1.4rem;
    right: 1rem;
    z-index: 3;
}

.opt-btn-zone {
    display: flex;
    overflow-x: auto;
    gap: var(--space-xs);
}

.opt-btn-zone a,
.opt-btn-zone label {
    padding: var(--space-xs);
    white-space: nowrap;
    transition: var(--global-transition);
}

.opt-btn-zone a:hover,
.opt-btn-zone label:hover {
    background-color: var(--color-primary-20);
    border-radius: var(--border-radius);
}

.opt-btn-zone label {
    color: var(--color-primary);
    cursor: pointer;
}

.tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    background-color: var(--color-primary-20);
}

.tabs a {
    padding: var(--space-xs) var(--space-sm);
    white-space: nowrap;
}

.tabs a.active {
    background-color: var(--color-primary-30);
}

.page-body {
    overflow: auto;
}

/* Layouts spécifiques */
#filter {
    flex-grow: 1;
    min-width: 10em;
}

.remainder-info {
    background: #e8ff75;
    padding: var(--space-md);
    border: var(--border-width) solid #999;
    border-radius: var(--border-radius);
}

.remainder-info ul {
    margin-left: var(--space-md);
}

.info-photo-cols {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.info-col {
    flex-grow: 1;
    min-width: 16rem;
}

.photo-col {
    width: 9.25rem;
    flex-shrink: 0;
    align-items: center;
    text-align: center;
}

.photo-col img {
    border: solid 1px #eee;
    width: 8rem;
    height: 8rem;
    object-fit: cover;
}

.red,
.fa-trash::before {
    color: var(--color-red);
}

.orange {
    color: var(--color-orange);
}

/* Modals et dialogues */
.modal,
#modal-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--opacity-50);
    display: none;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.modal {
    align-items: flex-start;
    padding: var(--space-md);
    z-index: 5;
}

#modal-loader {
    z-index: 7;
}

.dialog {
    width: min(40em, 100%);
    margin: var(--space-xl) auto;
    padding: var(--space-md);
    background-color: var(--color-white);
    border: var(--border-width) solid var(--opacity-30);
    border-radius: calc(var(--border-radius) * 2);
    box-shadow: 0 4px 12px var(--opacity-30);
    z-index: 6;
}

.dialog-title {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-md);
}

.btn-container {
    text-align: right;
    margin-top: var(--space-md);
}

/* Style barre de défilement */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Responsive Design */
@media (max-width: 820px) {
    #sidebar {
        width: 75px;
    }

    #sidebar .brand-name,
    #sidebar .user-name,
    #sidebar .nav-label,
    #sidebar .fold-arrow {
        display: none;
    }

    #content,
    #page1,
    #page2 {
        left: 75px !important;
    }

    #nav-toggler {
        left: calc(75px - 1em) !important;
    }

    /* État fermé */
    #sidebar.shrink {
        width: 0;
        padding-left: 0;
        padding-right: 0;
    }

    #sidebar.shrink~#content,
    #sidebar.shrink~#page1,
    #sidebar.shrink~#page2 {
        left: 0 !important;
    }

    #sidebar.shrink~#nav-toggler {
        left: -1rem !important;
    }
}

@media (max-width: 640px) {
    :root {
        --font-size-base: 0.9rem;
    }

    body {
        padding: 0 var(--space-xs);
    }

    .dialog {
        padding: var(--space-sm);
        margin: var(--space-md) var(--space-xs);
    }

    .info-photo-cols {
        flex-direction: column;
    }

    .photo-col {
        text-align: center;
    }
}

@media (max-width: 500px) {
    thead {
        display: none;
    }

    .flex_table thead th:first-child {
        width: 100%;
    }

    .flex_table thead th:first-child~th {
        display: none;
    }

    .flex_table td,
    .flex_table th {
        position: relative;
        display: block !important;
        width: auto !important;
        overflow: hidden;
        border: 0;
        padding: var(--space-xs);
    }

    .flex_table td:first-child~td:not(:empty),
    .flex_table th:first-child~th:not(:empty) {
        padding: 3px 8px 3px 35%;
    }

    .flex_table td:first-child~td:empty,
    .flex_table th:first-child~th:empty {
        padding: 0;
        height: 0;
    }

    .flex_table td:first-child~td:not(:empty)::before,
    .flex_table th:first-child~th:not(:empty)::before {
        position: absolute;
        left: 5px;
        display: block;
        overflow: hidden;
        width: 32%;
        content: attr(data-label);
        white-space: nowrap;
        text-overflow: ellipsis;
        text-align: left;
        font-weight: bold;
    }

    textarea {
        height: 6rem;
    }

    .dialog {
        width: 100%;
    }
}

/* Styles d'impression */
@media print {
    #nav-toggler,
    #sidebar,
    .tabs a:not(.active),
    button,
    .button,
    .opt-btn-zone {
        display: none;
    }

    #content,
    #page1,
    #page2 {
        left: 0 !important;
        position: relative;
        padding: 0;
        box-shadow: none;
    }

    .page-title {
        page-break-before: always;
    }

    select,
    input {
        border: 0;
        background: transparent;
    }

    table {
        border: var(--border-width) solid #000;
    }

    td,
    th {
        border: solid var(--border-width) #000;
    }

    a {
        color: #000;
        text-decoration: underline;
    }
}

/* Accessibilité - réduit les animations pour ceux qui les préfèrent réduites */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-primary-10: hsla(var(--hue-primary), 100%, 77%, 0.1);
        --color-red: hsla(0, 100%, 35%);

        --color-background: hsl(230deg, 10%, 15%);
        --color-text: #ddd;

        --ss-primary-color: var(--color-primary);
        --ss-bg-color: hsl(230deg, 10%, 16%);
        --ss-font-color: var(--color-text);
        --ss-font-placeholder-color: #888888;
        --ss-disabled-color: #555b60;
        --ss-border-color: hsl(230deg, 10%, 25%);
        --ss-highlight-color: #d8d149;
        --ss-success-color: #00a15c;
        --ss-error-color: #c62828;
    }

    a,
    .opt-btn-zone label {
        color: hsl(var(--hue-primary), 100%, 50%);
    }

    thead {
        color: black;
    }

    input,
    select,
    textarea {
        border-color: hsl(230deg, 10%, 25%);
        background-color: hsl(230deg, 10%, 16%);
    }

    #sidebar {
        background: linear-gradient(0deg, hsl(80deg 48% 48%) -30%, hsl(var(--hue-primary), 100%, 33%) 80%);
    }

    .remainder-info {
        background: #3a3a00;
        border-color: #666;
    }

    #nav-toggler,
    .dialog {
        border-color: hsl(230deg, 10%, 10%);
        background-color: hsl(230deg, 10%, 15%);
    }
}
