/* ==========================================================================
   Nous — feuille de style unique
   Charte : bleu et blanc. Mobile-first.
   ========================================================================== */

:root {
    --bleu: #1D4ED8;
    --bleu-fonce: #1E3A8A;
    --bleu-clair: #EFF4FF;
    --bleu-bord: #C7D7FE;
    --encre: #0F172A;
    --texte: #1F2937;
    --texte-doux: #64748B;
    --fond: #F6F8FC;
    --blanc: #FFFFFF;
    --bord: #E2E8F0;
    --ok: #15803D;
    --ok-fond: #ECFDF3;
    --alerte: #B91C1C;
    --alerte-fond: #FEF2F2;
    --ombre: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
    --ombre-douce: 0 1px 2px rgba(15, 23, 42, .05);
    --rayon: 14px;
    --rayon-petit: 10px;
    --nav-h: 62px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --police: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--police);
    font-size: 15px;
    line-height: 1.55;
    color: var(--texte);
    background: var(--fond);
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}

img { max-width: 100%; display: block; }
a { color: var(--bleu); text-decoration: none; }
h1, h2, h3, h4 { color: var(--encre); margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 24px; letter-spacing: -.02em; }
h2 { font-size: 19px; letter-spacing: -.01em; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }

/* ---------------------------------------------------------------- En-tete */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bleu);
    color: #fff;
    padding-top: var(--safe-top);
    box-shadow: 0 2px 12px rgba(30, 58, 138, .22);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    max-width: 1080px;
    margin: 0 auto;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    min-width: 0;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .16);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.brand-text { min-width: 0; }
.brand-name {
    font-weight: 700;
    font-size: 16px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-sub {
    font-size: 11px;
    opacity: .82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 0;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}
.icon-btn:hover { background: rgba(255, 255, 255, .24); }

.badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #F97316;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------------------------------------------------------------- Layout */

.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px;
}

.page-narrow { max-width: 520px; }

.section { margin-bottom: 22px; }

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 10px;
}
.section-head h2 { margin: 0; }
.section-head .lien { font-size: 13px; font-weight: 600; }

.muted { color: var(--texte-doux); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; color: var(--encre); }
.center { text-align: center; }

/* ---------------------------------------------------------------- Cartes */

.card {
    background: var(--blanc);
    border: 1px solid var(--bord);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-douce);
    padding: 16px;
}

.card + .card { margin-top: 12px; }

.hero {
    position: relative;
    border-radius: var(--rayon);
    overflow: hidden;
    color: #fff;
    margin-bottom: 18px;
    background: var(--bleu-fonce);
}
.hero img { width: 100%; height: 210px; object-fit: cover; opacity: .5; }
.hero-body {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
    padding: 18px;
    background: linear-gradient(180deg, rgba(15, 23, 42, .1) 0%, rgba(15, 23, 42, .82) 100%);
}
.hero-body h1 { color: #fff; margin: 0; font-size: 22px; }
.hero-body p { color: rgba(255, 255, 255, .9); margin: 0; font-size: 13.5px; }

/* -------------------------------------------------------------- Grilles */

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }

@media (min-width: 560px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 820px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Statistiques : 2 colonnes en mobile, jamais 4 */
.stat-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 720px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Grille de chiffres volontairement limitee a 2 colonnes :
   utilisee dans les colonnes etroites (elements cote a cote, encarts). */
.stat-grid-2 {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, 1fr);
}

.stat {
    background: var(--blanc);
    border: 1px solid var(--bord);
    border-radius: var(--rayon-petit);
    padding: 14px;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--bleu);
    line-height: 1.1;
}
.stat-label { font-size: 12px; color: var(--texte-doux); margin-top: 2px; }

/* --------------------------------------------------------- Annonces */

.annonce {
    background: var(--blanc);
    border: 1px solid var(--bord);
    border-radius: var(--rayon);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--ombre-douce);
}
.annonce-img { position: relative; }
.annonce-img img { width: 100%; height: 168px; object-fit: cover; }
.annonce-corps { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.annonce-titre { font-weight: 600; color: var(--encre); font-size: 15px; }
.annonce-desc {
    font-size: 13px;
    color: var(--texte-doux);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.annonce-pied {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 8px;
}

.prix { font-weight: 700; color: var(--bleu); font-size: 15px; }

.tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bleu-clair);
    color: var(--bleu-fonce);
    border: 1px solid var(--bleu-bord);
}
.tag-neutre { background: #F1F5F9; color: var(--texte-doux); border-color: var(--bord); }
.tag-alerte { background: var(--alerte-fond); color: var(--alerte); border-color: #FECACA; }
.tag-ok { background: var(--ok-fond); color: var(--ok); border-color: #BBF7D0; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------- Fils forum */

.sujet {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--blanc);
    border: 1px solid var(--bord);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-douce);
    color: inherit;
}
.sujet + .sujet { margin-top: 10px; }
.sujet-vignette {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    object-fit: cover;
    flex: 0 0 auto;
}
.sujet-corps { min-width: 0; flex: 1; }
.sujet-titre { font-weight: 600; color: var(--encre); font-size: 15px; }

.meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--texte-doux);
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    background: var(--bleu-clair);
}
.avatar-initiales {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--bleu);
    font-size: 13px;
}
.avatar-sm { width: 28px; height: 28px; }
.avatar-lg { width: 64px; height: 64px; }

.personne { display: flex; align-items: center; gap: 10px; min-width: 0; }
.personne-nom { font-weight: 600; color: var(--encre); font-size: 14px; }

.point-online {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22C55E;
    display: inline-block;
    flex: 0 0 auto;
}

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

.field { margin-bottom: 14px; }
.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--encre);
    margin-bottom: 6px;
}
.aide { font-size: 12px; color: var(--texte-doux); margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="url"], input[type="search"], select, textarea {
    width: 100%;
    padding: 11px 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--texte);
    background: var(--blanc);
    border: 1px solid var(--bord);
    border-radius: var(--rayon-petit);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748B' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}
textarea { min-height: 110px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    border-color: var(--bleu);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, .14);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--rayon-petit);
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--bleu);
    color: #fff;
    text-align: center;
    transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--bleu-fonce); }
.btn:active { transform: translateY(1px); }
.btn-secondaire { background: var(--blanc); color: var(--bleu); border-color: var(--bleu-bord); }
.btn-secondaire:hover { background: var(--bleu-clair); }
.btn-neutre { background: #F1F5F9; color: var(--texte); border-color: var(--bord); }
.btn-neutre:hover { background: #E2E8F0; }
.btn-danger { background: var(--blanc); color: var(--alerte); border-color: #FECACA; }
.btn-danger:hover { background: var(--alerte-fond); }
.btn-petit { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-large { width: 100%; padding: 13px 18px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > .btn { flex: 1 1 auto; }

.champ-image { display: flex; flex-direction: column; gap: 10px; }

/* --------------------------------------------------------- Formulaire auth */

.auth-wrap {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--bleu);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

/* --------------------------------------------------------- Messagerie */

.chat-liste { display: flex; flex-direction: column; gap: 8px; }

.thread {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    background: var(--blanc);
    border: 1px solid var(--bord);
    border-radius: var(--rayon);
    color: inherit;
    box-shadow: var(--ombre-douce);
}
.thread-corps { min-width: 0; flex: 1; }
.thread-nom { font-weight: 600; color: var(--encre); font-size: 14px; }
.thread-msg {
    font-size: 13px;
    color: var(--texte-doux);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-fenetre {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    min-height: 300px;
    max-height: 58vh;
    overflow-y: auto;
    background: var(--fond);
    border: 1px solid var(--bord);
    border-radius: var(--rayon);
}

.bulle {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 14.5px;
    background: var(--blanc);
    border: 1px solid var(--bord);
    align-self: flex-start;
    word-wrap: break-word;
}
.bulle-moi {
    background: var(--bleu);
    color: #fff;
    border-color: var(--bleu);
    align-self: flex-end;
}
.bulle-heure { font-size: 10.5px; opacity: .7; margin-top: 3px; text-align: right; }

.chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 10px;
}
.chat-form textarea { min-height: 46px; height: 46px; padding: 12px; }

/* --------------------------------------------------------- Etats vides */

.vide {
    text-align: center;
    padding: 30px 18px;
    color: var(--texte-doux);
    background: var(--blanc);
    border: 1px dashed var(--bord);
    border-radius: var(--rayon);
}
.vide svg { margin-bottom: 10px; opacity: .5; }

.squelette {
    height: 84px;
    border-radius: var(--rayon);
    background: linear-gradient(90deg, #EEF2F7 25%, #E2E8F0 37%, #EEF2F7 63%);
    background-size: 400% 100%;
    animation: brille 1.3s ease infinite;
}
@keyframes brille {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ------------------------------------------------------------ Alertes */

.toasts {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
    z-index: 90;
    width: calc(100% - 32px);
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--encre);
    color: #fff;
    border-radius: var(--rayon-petit);
    padding: 11px 14px;
    font-size: 13.5px;
    box-shadow: var(--ombre);
}
.toast-ok { background: #14532D; }
.toast-erreur { background: #7F1D1D; }

/* --------------------------------------------------------- Modale */

.modale-fond {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 0;
}
.modale {
    background: var(--blanc);
    width: 100%;
    max-width: 560px;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(18px + var(--safe-bottom));
    max-height: 88vh;
    overflow-y: auto;
}
@media (min-width: 620px) {
    .modale-fond { align-items: center; padding: 20px; }
    .modale { border-radius: 18px; }
}
.modale-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.modale-head h2 { margin: 0; }
.fermer {
    background: #F1F5F9;
    border: 1px solid var(--bord);
    color: var(--texte);
}
.fermer:hover { background: #E2E8F0; }

/* ------------------------------------------------------ Barre du bas */

.navbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--blanc);
    border-top: 1px solid var(--bord);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -2px 14px rgba(15, 23, 42, .08);
}
.navbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--nav-h);
}
.navbar-admin .navbar-inner { grid-template-columns: repeat(5, 1fr); }
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--texte-doux);
    border: 0;
    background: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    position: relative;
}
.nav-item.actif { color: var(--bleu); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item .badge-count { top: 4px; right: 22%; }

.admin-theme .navbar { background: #0F172A; border-top-color: #1E293B; }
.admin-theme .nav-item { color: #94A3B8; }
.admin-theme .nav-item.actif { color: #93C5FD; }

/* --------------------------------------------------------------- Admin */

.admin-theme { background: #F1F5F9; }
.admin-theme .topbar { background: #0F172A; box-shadow: 0 2px 12px rgba(15, 23, 42, .3); }
.admin-theme .admin-entete { background: #0F172A; color: #fff; }
.admin-theme h1, .admin-theme h2, .admin-theme h3 { color: var(--encre); }
.admin-theme .btn { background: #1D4ED8; }
.admin-theme .btn:hover { background: #1E40AF; }
.admin-theme .btn-secondaire { background: #fff; color: #1D4ED8; border-color: #C7D7FE; }
.admin-theme .btn-neutre { background: #F1F5F9; color: var(--texte); }
.admin-theme .stat-value { color: #1D4ED8; }

.admin-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--bord);
    background: var(--blanc);
    color: var(--texte-doux);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.admin-tab.actif { background: var(--bleu); border-color: var(--bleu); color: #fff; }

.ligne {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 0;
    border-bottom: 1px solid var(--bord);
}
.ligne:last-child { border-bottom: 0; }
.ligne-corps { min-width: 0; flex: 1; }
.ligne-titre { font-weight: 600; color: var(--encre); font-size: 14px; word-wrap: break-word; }
.ligne-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.barre-recherche { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.barre-recherche input { flex: 1 1 200px; }
.barre-recherche select { flex: 0 1 auto; }

.barre-jour {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 130px;
    padding: 8px 0;
}
.barre-jour .colonnes { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.barre-jour .barre { width: 8px; border-radius: 4px 4px 0 0; background: var(--bleu); min-height: 3px; }
.barre-jour .barre-2 { background: #93C5FD; }
.barre-jour .barre-3 { background: #C7D7FE; }
.legende { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--texte-doux); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.puce { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.axe-jours { display: flex; }
.axe-jours span { flex: 1; text-align: center; font-size: 10.5px; color: var(--texte-doux); }

/* ------------------------------------------------------------ Divers */

.pastille {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--bleu);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
}

.installation {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.installation-logos { display: flex; gap: 10px; align-items: center; }

.separateur { height: 1px; background: var(--bord); margin: 16px 0; }

.footer {
    text-align: center;
    font-size: 12px;
    color: var(--texte-doux);
    padding: 22px 16px 10px;
}
.footer a { font-weight: 600; }

.filtres {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.filtres::-webkit-scrollbar { display: none; }
.filtre {
    flex: 0 0 auto;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--bord);
    background: var(--blanc);
    color: var(--texte-doux);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.filtre.actif { background: var(--bleu); border-color: var(--bleu); color: #fff; }

.deux-colonnes { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 820px) {
    .deux-colonnes { flex-direction: row; align-items: flex-start; }
    .deux-colonnes > .principal { flex: 1 1 auto; min-width: 0; }
    .deux-colonnes > .laterale { flex: 0 0 320px; }
}

.etapes-install { display: flex; flex-direction: column; gap: 10px; }
.etape { display: flex; gap: 10px; align-items: flex-start; }
.etape-num {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bleu-clair);
    color: var(--bleu);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
