/* =====================================================
   Intranet La Couvée — espace adhérents (mobile d'abord)
   ===================================================== */

:root {
    --topbar-height: 56px;
    --sidebar-width: 250px;
    --bottomnav-height: 62px;
    /* Palette La Couvée (identique au back-office) */
    --primary-color: #FFC931;
    --primary-hover: #e6b520;
    --primary-text:  #5C2E2A;
    --base-color:    #E85C3C;
    --base-hover:    #d44d2e;
    --brown:         #5C2E2A;
    --green-soft:    #99B48C;
    --bg-soft:       #faf8f5;
    --border-soft:   #e8e0d8;
    --bs-link-color: #c2462a;
    --bs-link-hover-color: #5C2E2A;
}

body.espace {
    background: var(--bg-soft);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a1a;
}

a { color: #c2462a; }
a:hover { color: var(--brown); }

/* ---------- Boutons ---------- */
.btn-primary {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-color: var(--primary-text);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-hover-color: var(--primary-text);
    --bs-btn-active-bg: var(--primary-hover);
    --bs-btn-active-border-color: var(--primary-hover);
    --bs-btn-active-color: var(--primary-text);
    --bs-btn-disabled-bg: var(--primary-color);
    --bs-btn-disabled-border-color: var(--primary-color);
    --bs-btn-disabled-color: var(--primary-text);
    font-weight: 600;
}
.btn-outline-primary {
    --bs-btn-color: var(--base-color);
    --bs-btn-border-color: var(--base-color);
    --bs-btn-hover-bg: var(--base-color);
    --bs-btn-hover-border-color: var(--base-color);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--base-hover);
    --bs-btn-active-border-color: var(--base-hover);
}
.text-primary { color: var(--base-color) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 .2rem rgba(255, 201, 49, .35);
}
.form-check-input:checked { background-color: var(--base-color); border-color: var(--base-color); }

/* ---------- Barre supérieure ---------- */
.espace-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 3px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 1030;
}
.espace-brand {
    font-family: 'Lilita One', cursive;
    color: var(--base-color);
}
.espace-brand:hover { color: var(--base-hover); }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-text { font-size: 1.05rem; line-height: 1; }
.brand-sep { color: #98a0b3; margin: 0 .15em; }
@media (max-width: 400px) { .brand-text { display: none; } }

.espace-user { color: #3a3a3a; }
.espace-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--primary-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
}

/* ---------- Menu latéral ---------- */
.espace-sidebar { background: #fff; border-right: 1px solid var(--border-soft); }
@media (min-width: 992px) {
    .espace-sidebar {
        /* Largeur fixe : sans flex-shrink à 0, un contenu large (long texte, tableau) écrase le menu */
        flex: 0 0 var(--sidebar-width);
        width: var(--sidebar-width);
        min-height: calc(100vh - var(--topbar-height));
    }
    .espace-sidebar.offcanvas-lg {
        position: sticky !important;
        top: var(--topbar-height) !important;
        height: calc(100vh - var(--topbar-height)) !important;
        overflow-y: auto;
        transform: none !important;
        visibility: visible !important;
        z-index: auto !important;
    }
}
@media (max-width: 991.98px) {
    .espace-sidebar.offcanvas-start { width: min(85vw, 300px); overflow-y: auto; }
}
.espace-sidebar .nav-link {
    color: #4a4a4a;
    padding: .6rem 1rem;
    border-radius: .5rem;
    margin: .1rem .5rem;
    display: flex; align-items: center; gap: .6rem;
}
.espace-sidebar .nav-link:hover { background: var(--bg-soft); color: var(--base-color); }
.espace-sidebar .nav-link.active { background: var(--primary-color); color: var(--primary-text); font-weight: 600; }
.espace-sidebar .sidebar-section {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: #98a0b3; padding: .9rem 1.1rem .25rem; font-weight: 600;
}

/* ---------- Contenu ---------- */
.espace-main {
    flex: 1 1 0;
    min-width: 0;
    padding: 1rem .85rem calc(var(--bottomnav-height) + 1.25rem + env(safe-area-inset-bottom));
}
@media (min-width: 992px) {
    .espace-main { padding: 1.5rem 2rem 2rem; }
}
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 1.45rem; font-weight: 600; margin: 0; }
@media (min-width: 992px) { .page-header h1 { font-size: 1.65rem; } }

.card { border: 1px solid var(--border-soft); border-radius: .85rem; }
.card-header { background: #fff; border-bottom: 1px solid var(--border-soft); border-radius: .85rem .85rem 0 0 !important; }
.card-footer { background: #fff; border-top: 1px solid var(--border-soft); border-radius: 0 0 .85rem .85rem !important; }
.table > :not(caption) > * > * { padding: .6rem .6rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #7a7a7a; font-weight: 600; }

/* Tuiles de statistiques des widgets */
.stat-tile {
    background: var(--bg-soft);
    border-radius: .7rem;
    padding: .75rem .5rem;
    text-align: center;
    height: 100%;
    display: block;
    color: inherit;
    text-decoration: none;
}
a.stat-tile:hover { background: #f3eee7; color: inherit; }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-tile .stat-label { font-size: .78rem; color: #6b6b6b; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: #7a7a7a; }
.empty-state .bi { font-size: 2.5rem; color: #c9bfb4; }

/* ---------- Navigation mobile en bas d'écran ---------- */
.espace-bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--border-soft);
    display: flex;
    z-index: 1030;
    box-shadow: 0 -2px 10px rgba(92, 46, 42, .06);
}
.espace-bottomnav a, .espace-bottomnav button {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
    font-size: .7rem; color: #6b6b6b; text-decoration: none;
    background: none; border: 0;
}
.espace-bottomnav .bi { font-size: 1.3rem; }
.espace-bottomnav .active { color: var(--base-color); font-weight: 600; }

/* ---------- Connexion ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem 1rem;
}
.auth-card { width: 100%; max-width: 430px; overflow: hidden; box-shadow: 0 10px 30px rgba(92, 46, 42, .08); }
.auth-header {
    background: var(--primary-color);
    color: var(--primary-text);
    text-align: center;
    padding: 1.5rem 1rem 1.25rem;
}
.auth-header img { height: 64px; margin-bottom: .5rem; }
.auth-header h1 { font-family: 'Lilita One', cursive; font-weight: 400; font-size: 1.6rem; margin: 0; }
.auth-footer {
    font-size: .9rem;
    color: #4a4a4a;
    text-align: center;
    background: #fff4ec;
    border-top: 1px solid var(--border-soft);
}
.auth-footer-title { font-weight: 600; font-size: 1rem; color: var(--brown); }
/* Aide « Vous n'avez rien reçu ? » après la demande de lien */
.auth-help {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: .7rem;
    padding: 1rem 1rem 1rem .75rem;
}
.auth-help h3 { color: var(--brown); padding-left: .25rem; }
.auth-help ol { padding-left: 1.5rem; }
.auth-help li + li { margin-top: .5rem; }
/* Bouton « Adhérer » : distinct du bouton de connexion (jaune), contraste suffisant */
.btn-adherer {
    --bs-btn-bg: #c2462a;
    --bs-btn-border-color: #c2462a;
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--brown);
    --bs-btn-hover-border-color: var(--brown);
    --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--brown);
    --bs-btn-active-border-color: var(--brown);
    --bs-btn-active-color: #fff;
    font-weight: 600;
}

/* Pastilles de noms (membres, bénévoles) */
.name-chip {
    display: inline-flex; align-items: center; gap: .3rem;
    background: #fff; border: 1px solid var(--border-soft);
    border-radius: 999px; padding: .15rem .6rem; font-size: .82rem;
}
.name-chip.is-mine {
    background: var(--primary-color);
    border-color: var(--primary-hover);
    color: var(--primary-text);
    font-weight: 600;
}

/* ---------- Actualités ---------- */
.news-body { font-size: 1.02rem; line-height: 1.65; overflow-wrap: anywhere; }
.news-body h3 { font-size: 1.3rem; margin-top: 1.5rem; }
.news-body h4 { font-size: 1.12rem; margin-top: 1.25rem; }
.news-body h5 { font-size: 1rem; margin-top: 1rem; }
.news-body blockquote { border-left: 4px solid var(--primary-color); padding: .25rem 0 .25rem 1rem; color: #555; margin: 1rem 0; }
.news-body code { background: var(--bg-soft); padding: .1rem .3rem; border-radius: .25rem; color: var(--brown); }
.news-card:hover { box-shadow: 0 4px 16px rgba(92, 46, 42, .08); }

/* ---------- Agenda ---------- */
.agenda-date {
    width: 3.2rem; border-radius: .6rem; background: var(--bg-soft);
    border: 1px solid var(--border-soft); padding: .3rem 0;
}
.agenda-day { font-size: 1.35rem; font-weight: 700; line-height: 1.1; color: var(--base-color); }
.agenda-weekday { font-size: .72rem; color: #6b6b6b; text-transform: uppercase; }
.agenda-item.is-cancelled .fw-semibold { text-decoration: line-through; opacity: .7; }
.min-w-0 { min-width: 0; }

/* ---------- Permanences ---------- */
.planning-table td { vertical-align: top; border-color: var(--border-soft); }
.planning-table tr.shift-first > td { border-top: 2px solid #d9cfc4; }
.planning-date { background: #fff8e6; }
.seat-chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chip-remove {
    border: 0; background: transparent; color: inherit;
    padding: 0 0 0 .1rem; line-height: 1; font-size: 1.05rem;
}
.chip-remove:hover, .chip-remove:focus { color: var(--base-color); }
.seat-free, .seat-add {
    width: 2rem; height: 1.6rem;
    border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
}
.seat-free { border: 1px dashed #cdbfb2; }
.seat-add {
    border: 1px dashed var(--base-color);
    background: #fff; color: var(--base-color);
    padding: 0;
}
.seat-add:hover, .seat-add:focus { background: var(--base-color); color: #fff; border-style: solid; }
.slot-state-incomplet > .seat-cell, .planning-slot.slot-state-incomplet { background: #fff7e8; }
.slot-state-vide > .seat-cell, .planning-slot.slot-state-vide { background: #fdeeea; }
tr.is-past, tr.is-closed, .planning-slot.is-past, .planning-slot.is-closed, .planning-card.is-closed { opacity: .6; }
tr.is-past > .seat-cell, tr.is-closed > .seat-cell,
.planning-slot.is-past, .planning-slot.is-closed { background: transparent !important; }
.seat-line { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.seat-label { font-size: .78rem; color: #6b6b6b; min-width: 7.5rem; }
.slot-flash { box-shadow: inset 0 0 0 3px var(--primary-color); }

/* ---------- Avatars : photo de profil ou initiales ---------- */
.user-avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    border-radius: 50%; object-fit: cover; overflow: hidden;
    background: var(--primary-color); color: var(--primary-text);
    font-weight: 700; line-height: 1;
}
.avatar-24 { width: 24px; height: 24px; font-size: .6rem; }
.avatar-32 { width: 32px; height: 32px; font-size: .74rem; }
.avatar-40 { width: 40px; height: 40px; font-size: .88rem; }
.avatar-56 { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-96 { width: 96px; height: 96px; font-size: 1.9rem; }
.avatar-stack { display: inline-flex; flex-shrink: 0; }
.avatar-stack .user-avatar { border: 2px solid #fff; }
.avatar-stack .user-avatar + .user-avatar { margin-left: -.55rem; }

/* Badge coloré : bases de programmation, commissions */
.form-label-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .2rem .55rem; border-radius: .375rem;
    font-size: .8rem; font-weight: 500; white-space: nowrap; vertical-align: middle;
}

/* ---------- Commissions ---------- */
.commission-card { overflow: hidden; }
.commission-card:hover { box-shadow: 0 4px 16px rgba(92, 46, 42, .08); }
.commission-cover { width: 100%; height: 140px; object-fit: cover; display: block; }
.commission-cover-icon { display: flex; align-items: center; justify-content: center; font-size: 2.6rem; }
.commission-hero { width: 100%; height: 200px; object-fit: cover; display: block; }
@media (min-width: 992px) { .commission-hero { height: 280px; } }
.commission-hero-band { height: 8px; }
.commission-icon {
    width: 56px; height: 56px; border-radius: .8rem; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.7rem;
}
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list li { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; }
.member-results { z-index: 10; max-height: 320px; overflow-y: auto; }
.sticky-actions { top: calc(var(--topbar-height) + 1rem); z-index: 1; }

/* ---------- Actualités : image et pièces jointes ---------- */
.news-card { overflow: hidden; }
.news-cover { width: 100%; height: 180px; object-fit: cover; display: block; }
@media (min-width: 576px) { .news-cover { height: 100%; min-height: 150px; } }
.news-hero { width: 100%; max-height: 460px; object-fit: cover; border-radius: .6rem; display: block; }
.news-caption { font-size: .82rem; color: #6b6b6b; margin-top: .35rem; }
.news-edit-thumb { width: 200px; max-width: 100%; height: auto; }
.widget-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: .45rem; flex-shrink: 0; }
.attachment-icon { font-size: 1.4rem; color: var(--base-color); flex-shrink: 0; }

/* ---------- Événements adhérent·es ---------- */
.event-card:hover { box-shadow: 0 4px 16px rgba(92, 46, 42, .08); }
.event-card.is-cancelled h2 { text-decoration: line-through; opacity: .7; }
.presence-card { max-width: 580px; }
.presence-description { font-size: .95rem; max-height: 320px; overflow-y: auto; }

/* ---------- Fusion de comptes ---------- */
.merge-table tbody th { font-weight: 500; color: #6b6b6b; white-space: nowrap; font-size: .85rem; }
.merge-table td, .merge-table th { vertical-align: top; }
.merge-table thead th { min-width: 14rem; }

/* ---------- Aide ---------- */
.aide-sommaire { background: #fff; border: 1px solid var(--border-soft); border-radius: .85rem; padding: .75rem; }
.aide-sommaire-titre {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: #98a0b3; font-weight: 600; padding: 0 .35rem .5rem;
}
.aide-sommaire nav { display: flex; flex-wrap: wrap; gap: .4rem; }
.aide-sommaire nav a {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .35rem .7rem; border-radius: 99px; background: var(--bg-soft);
    color: #4a4a4a; text-decoration: none; font-size: .9rem;
}
.aide-sommaire nav a:hover { color: var(--base-color); }
.aide-sommaire nav a .bi { color: var(--base-color); }
@media (min-width: 992px) {
    .aide-sommaire { position: sticky; top: calc(var(--topbar-height) + 1.5rem); }
    .aide-sommaire nav { flex-direction: column; gap: .1rem; }
    .aide-sommaire nav a { background: none; border-radius: .5rem; padding: .45rem .6rem; }
    .aide-sommaire nav a:hover { background: var(--bg-soft); }
}
.aide-section { margin-bottom: 1rem; scroll-margin-top: calc(var(--topbar-height) + 1rem); }
.aide-section h2 {
    font-size: 1.2rem; font-weight: 600; color: var(--brown);
    display: flex; align-items: center; gap: .55rem; margin-bottom: .4rem;
}
.aide-section h2 .bi { color: var(--base-color); }
.aide-intro { color: #6b6b6b; margin-bottom: .75rem; }
.aide-note {
    background: #fff8e1; border: 1px solid #f7e2a3; border-radius: .6rem;
    padding: .5rem .75rem; margin-bottom: .75rem; font-size: .93rem;
}
.aide-item { border-top: 1px solid var(--border-soft); }
.aide-item > summary {
    list-style: none; cursor: pointer;
    display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem;
    padding: .7rem .25rem; font-weight: 600;
}
.aide-item > summary::-webkit-details-marker { display: none; }
.aide-item > summary::before {
    content: "\f285"; font-family: "bootstrap-icons"; font-weight: normal;
    color: var(--base-color); font-size: .8rem; transition: transform .15s;
}
.aide-item[open] > summary::before { transform: rotate(90deg); }
.aide-item > summary:hover .aide-item-titre { color: var(--base-color); }
.aide-item-titre { margin-right: auto; }
.aide-item-corps { padding: 0 .25rem .9rem 1.4rem; }
.aide-item-corps ul, .aide-item-corps ol { padding-left: 1.15rem; margin-bottom: .5rem; }
.aide-item-corps li + li { margin-top: .25rem; }
.aide-chemin { font-weight: 600; text-decoration: none; }
.aide-chemin .bi { font-size: .65em; margin: 0 .3em; vertical-align: .1em; }
.aide-public {
    display: inline-block; font-size: .74rem; font-weight: 600; line-height: 1.4;
    padding: .12rem .6rem; border-radius: 99px; white-space: nowrap;
}
.aide-public-adherent   { background: #dcfce7; color: #166534; }
.aide-public-commission { background: #ccfbf1; color: #115e59; }
.aide-public-responsable { background: #fef3c7; color: #92400e; }
.aide-public-bureau     { background: #dbeafe; color: #1e40af; }
.aide-public-admin      { background: var(--brown); color: #fff; }
.aide-guide { border-left: 4px solid var(--primary-color); }
.aide-guide-icone { font-size: 2.4rem; color: var(--base-color); line-height: 1; }

/* ---------- Permanences : première permanence ---------- */
.newcomer-card { border-left: 4px solid var(--primary-color); }
.newcomer-card-icon { font-size: 1.9rem; color: var(--base-color); line-height: 1; flex-shrink: 0; }
.newcomer-note { background: #fff8e1; border-top: 1px solid #f7e2a3; font-size: .9rem; }
#firstShiftModal h3 { font-size: 1.05rem; font-weight: 600; color: var(--brown); margin: 1.25rem 0 .5rem; }
#firstShiftModal .modal-body > h3:first-child { margin-top: 0; }
#firstShiftModal li + li { margin-top: .3rem; }
.first-shift-level { border: 1px solid var(--border-soft); border-radius: .75rem; padding: .85rem 1rem; height: 100%; }
.first-shift-level h4 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; display: flex; align-items: center; gap: .5rem; }
.first-shift-level ul { padding-left: 1.1rem; margin-bottom: 0; }
