/* =========================================================================
   BudgetPro — Feuille de style principale
   Design sobre et professionnel, ergonomique, adapté aux ordinateurs de
   bureau et aux tablettes ; l'affichage mobile est pris en charge en
   complément (breakpoint < 640px).
   ========================================================================= */

:root {
    /* Palette — sobre, professionnelle, inspirée des couleurs
       institutionnelles coopératives (bleu de confiance, vert finance) */
    --bp-bleu-950: #0f2436;
    --bp-bleu-900: #16324a;
    --bp-bleu-800: #1d3557;
    --bp-bleu-700: #274870;
    --bp-bleu-600: #335c8f;
    --bp-bleu-100: #e6edf5;
    --bp-bleu-50:  #f3f7fb;

    --bp-vert-700: #2a7f6f;
    --bp-vert-600: #34987f;
    --bp-vert-100: #e2f3ee;

    --bp-ambre-600: #b8860b;
    --bp-ambre-100: #fbf1dc;

    --bp-rouge-700: #a83232;
    --bp-rouge-100: #fbe9e9;

    --bp-gris-900: #1f2933;
    --bp-gris-700: #3e4c59;
    --bp-gris-500: #7b8794;
    --bp-gris-300: #cbd2d9;
    --bp-gris-200: #e4e7eb;
    --bp-gris-100: #f5f7fa;
    --bp-blanc:    #ffffff;

    --bp-rayon: 8px;
    --bp-rayon-petit: 5px;
    --bp-ombre: 0 1px 3px rgba(15, 36, 54, 0.10), 0 1px 2px rgba(15, 36, 54, 0.06);
    --bp-ombre-large: 0 8px 24px rgba(15, 36, 54, 0.12);

    --bp-police: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;

    --bp-largeur-nav: 248px;
    --bp-largeur-nav-reduite: 68px;
    --bp-hauteur-topbar: 60px;
}

/* -------------------------------------------------------------------- */
/* Réinitialisation de base                                             */
/* -------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: var(--bp-police);
    color: var(--bp-gris-900);
    background: var(--bp-gris-100);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0 0 0.5em; color: var(--bp-bleu-900); font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--bp-bleu-700); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--bp-gris-500); }

/* -------------------------------------------------------------------- */
/* Mise en page générale : barre latérale + contenu                     */
/* -------------------------------------------------------------------- */

.bp-structure {
    display: flex;
    min-height: 100vh;
}

.bp-nav {
    width: var(--bp-largeur-nav);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--bp-bleu-900), var(--bp-bleu-950));
    color: var(--bp-blanc);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.bp-nav__entete {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.bp-nav__logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bp-blanc);
    letter-spacing: 0.02em;
}

.bp-nav__organisme {
    display: block;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.65);
    margin-top: 2px;
}

.bp-nav__groupe-titre {
    padding: 14px 18px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.45);
}

.bp-nav__lien {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,0.85);
    font-size: 0.92rem;
    border-left: 3px solid transparent;
}

.bp-nav__lien:hover {
    background: rgba(255,255,255,0.06);
    text-decoration: none;
}

.bp-nav__lien--actif {
    background: rgba(255,255,255,0.10);
    border-left-color: var(--bp-vert-600);
    color: var(--bp-blanc);
    font-weight: 600;
}

.bp-nav__pied {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

.bp-contenu {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bp-topbar {
    height: var(--bp-hauteur-topbar);
    background: var(--bp-blanc);
    border-bottom: 1px solid var(--bp-gris-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bp-topbar__titre {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--bp-bleu-900);
}

.bp-topbar__utilisateur {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.88rem;
    color: var(--bp-gris-700);
}

.bp-badge-niveau {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bp-bleu-100);
    color: var(--bp-bleu-800);
    font-weight: 600;
}

.bp-btn-icone-menu {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--bp-bleu-900);
    cursor: pointer;
}

.bp-principal {
    padding: 24px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* -------------------------------------------------------------------- */
/* Cartes, sections                                                     */
/* -------------------------------------------------------------------- */

.bp-carte {
    background: var(--bp-blanc);
    border: 1px solid var(--bp-gris-200);
    border-radius: var(--bp-rayon);
    box-shadow: var(--bp-ombre);
    padding: 20px 22px;
    margin-bottom: 20px;
}

.bp-carte__entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--bp-gris-200);
}

.bp-grille {
    display: grid;
    gap: 18px;
}

.bp-grille--2 { grid-template-columns: repeat(2, 1fr); }
.bp-grille--3 { grid-template-columns: repeat(3, 1fr); }
.bp-grille--4 { grid-template-columns: repeat(4, 1fr); }

.bp-stat {
    background: var(--bp-blanc);
    border: 1px solid var(--bp-gris-200);
    border-radius: var(--bp-rayon);
    padding: 16px 18px;
    box-shadow: var(--bp-ombre);
}

.bp-stat__valeur {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--bp-bleu-900);
}

.bp-stat__libelle {
    font-size: 0.82rem;
    color: var(--bp-gris-500);
    margin-top: 2px;
}

/* -------------------------------------------------------------------- */
/* Formulaires                                                          */
/* -------------------------------------------------------------------- */

.bp-champ { margin-bottom: 16px; }

.bp-champ label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--bp-gris-700);
    margin-bottom: 5px;
}

.bp-champ .bp-aide {
    display: block;
    font-size: 0.78rem;
    color: var(--bp-gris-500);
    margin-top: 4px;
}

.bp-champ input[type="text"],
.bp-champ input[type="email"],
.bp-champ input[type="password"],
.bp-champ input[type="number"],
.bp-champ input[type="date"],
.bp-champ input[type="tel"],
.bp-champ select,
.bp-champ textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.94rem;
    font-family: inherit;
    border: 1px solid var(--bp-gris-300);
    border-radius: var(--bp-rayon-petit);
    background: var(--bp-blanc);
    color: var(--bp-gris-900);
    transition: border-color .15s, box-shadow .15s;
}

.bp-champ input:focus,
.bp-champ select:focus,
.bp-champ textarea:focus {
    outline: none;
    border-color: var(--bp-bleu-600);
    box-shadow: 0 0 0 3px var(--bp-bleu-100);
}

.bp-champ textarea { resize: vertical; min-height: 90px; }

.bp-champ--erreur input,
.bp-champ--erreur select,
.bp-champ--erreur textarea {
    border-color: var(--bp-rouge-700);
}

.bp-champ__erreur { color: var(--bp-rouge-700); font-size: 0.8rem; margin-top: 4px; }

/* -------------------------------------------------------------------- */
/* Boutons                                                              */
/* -------------------------------------------------------------------- */

.bp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--bp-rayon-petit);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.bp-btn:hover { text-decoration: none; }

.bp-btn--principal { background: var(--bp-bleu-800); color: var(--bp-blanc); }
.bp-btn--principal:hover { background: var(--bp-bleu-700); }

.bp-btn--secondaire { background: var(--bp-blanc); color: var(--bp-bleu-800); border-color: var(--bp-gris-300); }
.bp-btn--secondaire:hover { background: var(--bp-bleu-50); }

.bp-btn--succes { background: var(--bp-vert-700); color: var(--bp-blanc); }
.bp-btn--succes:hover { background: var(--bp-vert-600); }

.bp-btn--danger { background: var(--bp-blanc); color: var(--bp-rouge-700); border-color: var(--bp-rouge-100); }
.bp-btn--danger:hover { background: var(--bp-rouge-100); }

.bp-btn--petit { padding: 6px 12px; font-size: 0.82rem; }
.bp-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* -------------------------------------------------------------------- */
/* Tableaux                                                             */
/* -------------------------------------------------------------------- */

.bp-tableau-conteneur { overflow-x: auto; }

table.bp-tableau {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.bp-tableau th {
    text-align: left;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--bp-gris-500);
    padding: 10px 12px;
    border-bottom: 2px solid var(--bp-gris-200);
    white-space: nowrap;
}

table.bp-tableau td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--bp-gris-200);
    vertical-align: middle;
}

table.bp-tableau tbody tr:hover { background: var(--bp-bleu-50); }

/* -------------------------------------------------------------------- */
/* Étiquettes de statut                                                 */
/* -------------------------------------------------------------------- */

.bp-etiquette {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}

.bp-etiquette--succes  { background: var(--bp-vert-100);  color: var(--bp-vert-700); }
.bp-etiquette--ambre   { background: var(--bp-ambre-100); color: var(--bp-ambre-600); }
.bp-etiquette--danger  { background: var(--bp-rouge-100); color: var(--bp-rouge-700); }
.bp-etiquette--neutre  { background: var(--bp-gris-200);  color: var(--bp-gris-700); }
.bp-etiquette--info    { background: var(--bp-bleu-100);  color: var(--bp-bleu-800); }

/* -------------------------------------------------------------------- */
/* Messages système (alertes, confirmations)                            */
/* -------------------------------------------------------------------- */

.bp-alerte {
    padding: 12px 16px;
    border-radius: var(--bp-rayon-petit);
    border: 1px solid transparent;
    margin-bottom: 18px;
    font-size: 0.9rem;
}

.bp-alerte--succes { background: var(--bp-vert-100); border-color: #bfe3d8; color: var(--bp-vert-700); }
.bp-alerte--erreur  { background: var(--bp-rouge-100); border-color: #f0c3c3; color: var(--bp-rouge-700); }
.bp-alerte--info    { background: var(--bp-bleu-100); border-color: #cfdcee; color: var(--bp-bleu-800); }
.bp-alerte--avertissement { background: var(--bp-ambre-100); border-color: #eddcae; color: var(--bp-ambre-600); }

/* -------------------------------------------------------------------- */
/* Page de connexion                                                    */
/* -------------------------------------------------------------------- */

.bp-page-connexion {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--bp-bleu-950), var(--bp-bleu-800) 60%, var(--bp-vert-700));
    padding: 20px;
}

.bp-connexion-carte {
    background: var(--bp-blanc);
    border-radius: 12px;
    box-shadow: var(--bp-ombre-large);
    width: 100%;
    max-width: 400px;
    padding: 36px 34px 30px;
}

.bp-connexion-carte__logo {
    text-align: center;
    margin-bottom: 6px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--bp-bleu-900);
}

.bp-connexion-carte__sous-titre {
    text-align: center;
    color: var(--bp-gris-500);
    font-size: 0.86rem;
    margin-bottom: 26px;
}

.bp-connexion-carte .bp-btn { width: 100%; justify-content: center; margin-top: 6px; }

.bp-connexion-pied {
    text-align: center;
    margin-top: 22px;
    font-size: 0.76rem;
    color: rgba(255,255,255,0.75);
}

/* -------------------------------------------------------------------- */
/* Infobulles                                                           */
/* -------------------------------------------------------------------- */

.bp-infobulle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bp-gris-300);
    color: var(--bp-blanc);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
    margin-left: 6px;
}

.bp-infobulle:hover::after {
    content: attr(data-texte);
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bp-gris-900);
    color: var(--bp-blanc);
    padding: 8px 10px;
    border-radius: var(--bp-rayon-petit);
    font-size: 0.76rem;
    font-weight: 400;
    white-space: normal;
    width: 220px;
    z-index: 20;
    box-shadow: var(--bp-ombre-large);
}

/* -------------------------------------------------------------------- */
/* Utilitaires                                                          */
/* -------------------------------------------------------------------- */

.bp-flex { display: flex; align-items: center; }
.bp-flex--entre { display: flex; align-items: center; justify-content: space-between; }
.bp-gap-8 { gap: 8px; }
.bp-gap-12 { gap: 12px; }
.bp-mt-0 { margin-top: 0; }
.bp-mb-0 { margin-bottom: 0; }
.bp-texte-discret { color: var(--bp-gris-500); font-size: 0.85rem; }
.bp-texte-centre { text-align: center; }

/* -------------------------------------------------------------------- */
/* Adaptation tablette (< 1024px)                                       */
/* -------------------------------------------------------------------- */

@media (max-width: 1024px) {
    .bp-grille--4 { grid-template-columns: repeat(2, 1fr); }
    .bp-grille--3 { grid-template-columns: repeat(2, 1fr); }
    .bp-principal { padding: 18px; }
}

/* -------------------------------------------------------------------- */
/* Adaptation mobile (< 640px) — optionnelle mais prise en charge       */
/* -------------------------------------------------------------------- */

@media (max-width: 640px) {
    .bp-btn-icone-menu { display: block; }

    .bp-nav {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        width: 78vw;
        max-width: 280px;
        z-index: 100;
        transition: transform .2s ease;
        box-shadow: var(--bp-ombre-large);
    }

    .bp-nav--ouverte { transform: translateX(0); }

    .bp-grille--2, .bp-grille--3, .bp-grille--4 { grid-template-columns: 1fr; }

    .bp-topbar { padding: 0 14px; }
    .bp-principal { padding: 14px; }
    .bp-connexion-carte { padding: 28px 22px; }
}
