/**
 * assets/css/style.css
 * ---------------------------------------------------------------------
 * Feuille de style unique pour toute l'application (espace propriétaire
 * ET espace locataire). Les couleurs sont définies via des variables CSS
 * (voir :root et [data-theme="sombre"]) : changez-les ici pour modifier
 * la charte graphique partout d'un coup.
 *
 * Palette adaptée au logo Sugufy (vert). Pour changer de charte plus
 * tard, il suffit de modifier les valeurs ci-dessous : tout le reste de
 * la feuille de style utilise ces variables.
 * ---------------------------------------------------------------------
 */

:root {
    --couleur-fond: #f4f7f4;
    --couleur-carte: #ffffff;
    --couleur-texte: #1f2933;
    --couleur-texte-attenue: #64748b;
    --couleur-bordure: #e2e8e2;

    /* Vert de la marque Sugufy (repris du logo). */
    --couleur-primaire: #1b7a0c;
    --couleur-primaire-hover: #146006;
    --couleur-primaire-fond: #e6f4e1;

    /* Le "succès" utilise un vert légèrement différent du vert de marque
       pour rester lisible dans les badges à côté des boutons/liens. */
    --couleur-succes: #0d9488;
    --couleur-succes-fond: #ccfbf1;
    --couleur-attention: #d97706;
    --couleur-attention-fond: #fef3c7;
    --couleur-danger: #dc2626;
    --couleur-danger-fond: #fee2e2;

    --barre-laterale-fond: #0f2312;
    --barre-laterale-fond-clair: #163a1a;
    --barre-laterale-texte: #e6f4e1;
}

[data-theme="sombre"] {
    --couleur-fond: #0f172a;
    --couleur-carte: #1e293b;
    --couleur-texte: #e2e8f0;
    --couleur-texte-attenue: #94a3b8;
    --couleur-bordure: #334155;

    --couleur-primaire: #3fbf2b;
    --couleur-primaire-hover: #63d94f;
    --couleur-primaire-fond: #143d0f;

    --couleur-succes: #2dd4bf;
    --couleur-succes-fond: #134e4a;
    --couleur-attention: #f59e0b;
    --couleur-attention-fond: #78350f;
    --couleur-danger: #ef4444;
    --couleur-danger-fond: #7f1d1d;

    --barre-laterale-fond: #05130a;
    --barre-laterale-fond-clair: #0c1f0f;
    --barre-laterale-texte: #dcf7d6;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--couleur-fond);
    color: var(--couleur-texte);
}

a { color: var(--couleur-primaire); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Logo de la marque ----
   Le fichier logo (assets/img/logo-sugufy.png) a un fond blanc. On
   l'affiche donc dans une petite "pastille" blanche arrondie quand il
   est posé sur un fond sombre (barre latérale), et directement sur les
   pages à fond clair (connexion, espace locataire). */
.logo-marque {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border-radius: 8px;
    padding: 4px 8px;
    line-height: 0;
}
.logo-marque img { display: block; height: 28px; width: auto; }
.logo-marque.logo-grand img { height: 42px; }

.mention-powered-by {
    text-align: center;
    color: var(--couleur-texte-attenue);
    font-size: 0.8rem;
    padding: 18px 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.mention-powered-by img { height: 16px; width: auto; vertical-align: middle; }

/* ---- Mise en page générale (espace propriétaire) ---- */
.app-layout { display: flex; min-height: 100vh; }

.barre-laterale {
    width: 230px;
    flex-shrink: 0;
    background: var(--barre-laterale-fond);
    color: var(--barre-laterale-texte);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}
.barre-laterale .logo {
    font-weight: bold;
    font-size: 1rem;
    padding: 0 20px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.barre-laterale nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.barre-laterale nav a {
    color: var(--barre-laterale-texte);
    padding: 10px 20px;
    opacity: 0.85;
}
.barre-laterale nav a:hover { background: var(--barre-laterale-fond-clair); text-decoration: none; opacity: 1; }
.barre-laterale nav a.actif { background: var(--couleur-primaire); color: #fff; opacity: 1; }
.bas-barre-laterale { padding: 10px 20px; display: flex; flex-direction: column; gap: 8px; }
.bas-barre-laterale button {
    background: var(--barre-laterale-fond-clair);
    border: none;
    color: var(--barre-laterale-texte);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
}
.deconnexion { color: #fca5a5 !important; }

.contenu-principal { flex: 1; padding: 30px 40px; max-width: 1100px; width: 100%; }

h1 { margin-top: 0; }

/* ---- Cartes / statistiques ---- */
.grille-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 20px 0 30px; }
.carte-stat {
    background: var(--couleur-carte);
    border: 1px solid var(--couleur-bordure);
    border-radius: 10px;
    padding: 18px;
}
.carte-stat .valeur { font-size: 1.6rem; font-weight: 700; }
.carte-stat .libelle { color: var(--couleur-texte-attenue); font-size: 0.9rem; }

.carte {
    background: var(--couleur-carte);
    border: 1px solid var(--couleur-bordure);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 24px;
}

/* ---- Tableaux ---- */
/* Sur petit écran, on autorise un défilement horizontal du tableau
   plutôt que de casser la mise en page. */
.carte { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
/* Pour les tableaux à nombreuses colonnes (listes), on impose une largeur
   minimale et on laisse le conteneur .carte défiler horizontalement sur
   petit écran plutôt que de tasser les colonnes. Les tableaux "clé/valeur"
   à 2 colonnes (fiche d'informations) n'ont pas cette classe et s'adaptent
   naturellement à la largeur de l'écran. */
table.tableau-large { min-width: 480px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--couleur-bordure); }
th { color: var(--couleur-texte-attenue); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }

/* ---- Badges de statut ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge-succes { background: var(--couleur-succes-fond); color: var(--couleur-succes); }
.badge-attention { background: var(--couleur-attention-fond); color: var(--couleur-attention); }
.badge-danger { background: var(--couleur-danger-fond); color: var(--couleur-danger); }

/* ---- Formulaires ---- */
.champ-formulaire { margin-bottom: 16px; }
.champ-formulaire label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; }
.champ-formulaire input,
.champ-formulaire select,
.champ-formulaire textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--couleur-bordure);
    border-radius: 6px;
    background: var(--couleur-fond);
    color: var(--couleur-texte);
    font-size: 1rem;
}
.champ-formulaire input:focus,
.champ-formulaire select:focus,
.champ-formulaire textarea:focus {
    outline: none;
    border-color: var(--couleur-primaire);
    box-shadow: 0 0 0 3px var(--couleur-primaire-fond);
}
.ligne-formulaire { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .ligne-formulaire { grid-template-columns: 1fr; } }

/* ---- Boutons ---- */
.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primaire { background: var(--couleur-primaire); color: #fff; }
.btn-primaire:hover { background: var(--couleur-primaire-hover); }
.btn-secondaire { background: transparent; color: var(--couleur-texte); border: 1px solid var(--couleur-bordure); }
.btn-danger { background: var(--couleur-danger); color: #fff; }
.btn-petit { padding: 5px 10px; font-size: 0.85rem; }

.barre-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }

/* ---- Alertes ---- */
.alerte { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.alerte-succes { background: var(--couleur-succes-fond); color: var(--couleur-succes); }
.alerte-erreur { background: var(--couleur-danger-fond); color: var(--couleur-danger); }

/* ---- Pages publiques (connexion propriétaire + espace locataire) ---- */
.page-centree {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.boite-connexion {
    background: var(--couleur-carte);
    border: 1px solid var(--couleur-bordure);
    border-radius: 12px;
    padding: 36px;
    width: 100%;
    max-width: 380px;
}
.boite-connexion h1 { font-size: 1.4rem; text-align: center; }
.boite-connexion .sous-titre { text-align: center; color: var(--couleur-texte-attenue); margin-bottom: 24px; }
.boite-connexion .logo-marque { display: flex; margin: 0 auto 18px; width: fit-content; }

.texte-attenue { color: var(--couleur-texte-attenue); }
.texte-centre { text-align: center; }
.espace-haut { margin-top: 20px; }

/* =======================================================================
   RESPONSIVE — écrans de tablette et mobile
   ======================================================================= */
@media (max-width: 768px) {
    /* La barre latérale devient une barre horizontale en haut de l'écran. */
    .app-layout { flex-direction: column; }
    .barre-laterale {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 10px 16px;
        gap: 8px;
    }
    .barre-laterale .logo { padding: 4px 0; margin-right: auto; }
    .barre-laterale nav {
        flex-direction: row;
        flex-wrap: wrap;
        flex: 1 1 100%;
        gap: 4px;
        order: 3;
    }
    .barre-laterale nav a { padding: 8px 12px; border-radius: 6px; }
    .bas-barre-laterale {
        flex-direction: row;
        padding: 0;
        gap: 8px;
        order: 2;
        margin-left: auto;
    }

    .contenu-principal { padding: 18px; }

    .grille-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
    .carte-stat { padding: 14px; }
    .carte-stat .valeur { font-size: 1.25rem; }

    .carte { padding: 16px; }

    .barre-actions { align-items: stretch; }
    .barre-actions .btn { text-align: center; }
}

@media (max-width: 480px) {
    .boite-connexion { padding: 24px 20px; }
    h1 { font-size: 1.35rem; }
}
