/*
 * ================================================================
 * VARIABLES GLOBALES
 * ================================================================
 *
 * Toute l'identité graphique principale est centralisée ici.
 * Changer une couleur ici permettra de la changer dans toute l'app.
 */
:root {
    --color-primary: #173b5e;
    --color-primary-hover: #102d49;

    --color-background: #f3f6f9;
    --color-surface: #ffffff;

    --color-text: #1f2933;
    --color-text-muted: #667788;

    --color-border: #d8e0e7;

    --color-danger: #b42318;
    --color-danger-background: #fef3f2;

    --radius-small: 6px;
    --radius-medium: 12px;

    --shadow-card: 0 12px 35px rgba(0, 0, 0, 0.10);
}


/*
 * Reset minimal.
 */
* {
    box-sizing: border-box;
}

html {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    margin: 0;
    color: var(--color-text);
    background: var(--color-background);
}


/*
 * ================================================================
 * FORMULAIRES
 * ================================================================
 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    min-height: 46px;

    padding: 10px 12px;

    font: inherit;
    color: var(--color-text);

    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


/*
 * Le focus doit rester clairement visible,
 * notamment pour l'accessibilité clavier.
 */
.form-group input:focus {
    outline: none;

    border-color: var(--color-primary);

    box-shadow:
        0 0 0 3px rgba(23, 59, 94, 0.12);
}


/*
 * ================================================================
 * BOUTONS
 * ================================================================
 */
.button {
    min-height: 46px;

    padding: 10px 18px;

    font: inherit;
    font-weight: 600;

    border: 0;
    border-radius: var(--radius-small);

    cursor: pointer;

    transition:
        background-color 0.15s ease,
        transform 0.05s ease;

            /*
     * Permet d'utiliser la même classe aussi bien sur un
     * <button> que sur un lien <a>.
     */
    display: inline-flex;
    align-items: center;
    justify-content: center;

    box-sizing: border-box;

    color: inherit;
    text-decoration: none;


}

.button-primary {
    color: #ffffff;
    background: var(--color-primary);
}

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

.button-primary:active {
    transform: translateY(1px);
}


/*
 * ================================================================
 * ALERTES
 * ================================================================
 */
.alert {
    padding: 12px 14px;

    font-size: 0.9rem;

    border-radius: var(--radius-small);
}

.alert-error {
    color: var(--color-danger);
    background: var(--color-danger-background);
    border: 1px solid #fecdca;
}
/* ==========================================================
   EN-TÊTE DES PAGES
   ========================================================== */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 28px;
}

.page-header h1 {
    margin: 0 0 6px;

    font-size: 1.8rem;
    line-height: 1.2;
}

.page-header__subtitle {
    margin: 0;
    color: var(--color-muted);
}


/* ==========================================================
   TABLEAU DE BORD
   ========================================================== */

.dashboard-grid {
    display: grid;

    /*
     * Les cartes se répartissent automatiquement.
     * Elles passent sur plusieurs lignes lorsque l'écran rétrécit.
     */
    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 20px;
}

.dashboard-card {
    padding: 22px;

    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-sm);
}

.dashboard-card__title {
    color: var(--color-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.dashboard-card__value {
    margin: 12px 0;

    color: var(--color-primary);
    font-size: 2rem;
    font-weight: 700;
}

.dashboard-card__description {
    color: var(--color-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}


/* Deux colonnes sur tablette */
@media (max-width: 900px) {

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* Une seule colonne sur smartphone */
@media (max-width: 600px) {

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }
}
/* ==========================================================
   TABLEAUX D'ADMINISTRATION
   ========================================================== */

/*
 * Conteneur du tableau.
 * overflow-x permet de conserver un tableau utilisable
 * sur les écrans trop étroits sans casser toute la page.
 */
.users-table-container {
    width: 100%;
    overflow-x: auto;

    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.users-table th,
.users-table td {
    padding: 15px 18px;
    text-align: left;
    vertical-align: middle;

    border-bottom: 1px solid var(--color-border);
}

.users-table th {
    color: var(--color-muted);
    font-size: 0.78rem;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.04em;

    background: #f8fafc;
}

.users-table tbody tr:last-child td {
    border-bottom: 0;
}

.users-table tbody tr:hover {
    background: #f8fafc;
}


/* ==========================================================
   BADGES
   ========================================================== */

.role-badge {
    display: inline-block;

    margin: 2px 4px 2px 0;
    padding: 5px 9px;

    border-radius: 999px;

    background: #e8eef8;
    color: var(--color-primary);

    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge {
    display: inline-block;

    padding: 5px 9px;
    border-radius: 999px;

    font-size: 0.78rem;
    font-weight: 700;
}

.status-badge--active {
    background: #eaf7ef;
    color: #216e3a;
}

.status-badge--inactive {
    background: #fbecec;
    color: #a52a2a;
}

.text-muted {
    color: var(--color-muted);
}


/* ==========================================================
   PAGINATION
   ========================================================== */

.users-pagination {
    margin-top: 20px;
}

.users-table__empty {
    padding: 35px !important;

    color: var(--color-muted);
    text-align: center !important;
}


/* ==========================================================
   ADAPTATION SMARTPHONE
   ========================================================== */

@media (max-width: 700px) {

    .users-table th,
    .users-table td {
        padding: 12px 14px;
    }

    .users-table {
        font-size: 0.9rem;
    }
}


/*
 * Messages d'erreur de validation des formulaires.
 * Le bloc est volontairement très visible afin que
 * l'utilisateur comprenne immédiatement pourquoi
 * l'enregistrement a été refusé.
 */
.validation-errors {
    margin-bottom: 20px;
    padding: 12px 16px;

    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
    border-radius: var(--radius-small);
    font-weight: 600;
}

.validation-errors div + div {
    margin-top: 5px;
}


/*
 * ================================================================
 * ÉTAT DES COMPTES UTILISATEURS
 * ================================================================
 *
 * Vert : compte actif
 * Rouge : compte désactivé
 */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 5px 10px;
    border-radius: 999px;

    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Compte actif */
.status-active {
    color: #166534;
    background-color: #dcfce7;
    border: 1px solid #86efac;
}

/* Compte désactivé */
.status-inactive {
    color: #991b1b;
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
}


/*
 * ================================================================
 * MESSAGES D'ERREUR
 * ================================================================
 */

.alert-error {
    color: #991b1b;
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
}




/* =========================================================
   MODULE FORMATION
   ========================================================= */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 25px;
}

.page-header h1 {
    margin-top: 0;
    margin-bottom: 6px;
}

.page-header p {
    margin: 0;
    color: #64748b;
}

.form-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid #e2e8f0;
}

.form-section h2 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 1.15rem;
}

.form-help {
    margin-top: 0;
    margin-bottom: 15px;
    color: #64748b;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.checkbox-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    background: #ffffff;
}

.checkbox-card:hover {
    background: #f8fafc;
}

.checkbox-card input {
    width: auto;
    margin: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 30px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
}

.empty-state {
    padding: 45px 25px;
    text-align: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.pagination-wrapper {
    margin-top: 20px;
}

@media (max-width: 768px) {

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

    .form-grid,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .form-card {
        padding: 18px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
        text-align: center;
    }
}
