/* === Page publique réseau — /reseau/<id>/<slug> === */

#reseau-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    font-family: var(--ex-font);
    color: var(--ex-stone-800);
    -webkit-font-smoothing: antialiased;
}
@media (min-width: 1100px) {
    #reseau-page {
        width: 80%;
        max-width: none;
        padding: 1rem 1.5rem;
    }
}
#reseau-page section {
    margin: 0;
}
#reseau-page p,
#reseau-page div:not(.rp-popup-desc):not(.rp-item-desc) {
    padding-left: 0;
}
#reseau-page input[type="text"] {
    padding: .35rem .6rem;
    border-radius: 6px;
    border: 1px solid var(--ex-stone-200);
}

/* --- Breadcrumb --- */
.rp-breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .82rem;
    color: var(--ex-stone-500);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.rp-breadcrumb a {
    color: var(--ex-link);
    text-decoration: none;
}
.rp-breadcrumb a:hover {
    color: var(--ex-link-hover);
    text-decoration: underline;
}
.rp-breadcrumb .sep {
    color: var(--ex-stone-300);
    font-size: .7em;
}
.rp-breadcrumb span:last-child {
    color: var(--ex-stone-700);
    font-weight: 500;
}

/* --- Header compact --- */
.rp-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .3rem .8rem;
    height: 1em;
    padding: 1em;
    margin-bottom: .75rem;
    border: 1px solid var(--ex-stone-200);
    border-radius: 8px;
    background: var(--ex-amber-50);
    line-height: 1em;
    overflow: hidden;
}
.rp-header h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ex-stone-900);
    line-height: 1em;
}
.rp-count {
    font-size: .85em;
    font-weight: 500;
    color: var(--ex-stone-500);
}
.rp-description {
    font-weight: 500;
    color: var(--ex-stone-500);
    font-size: .85rem;
}
.rp-contacts {
    margin: 0 0 0 auto;
    font-size: .8rem;
    color: var(--ex-stone-500);
}
.rp-contact {
    color: var(--ex-link);
    text-decoration: none;
}
.rp-contact:hover {
    color: var(--ex-link-hover);
    text-decoration: underline;
}
.rp-desc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.3em;
    margin-left: .3rem;
    padding: 0;
    border: 1px solid var(--ex-stone-300);
    border-radius: 50%;
    background: var(--ex-surface);
    color: var(--ex-stone-600);
    font-size: .75rem;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
    line-height: 1;
}
.rp-desc-toggle:hover {
    background: var(--ex-stone-100);
    color: var(--ex-stone-800);
}

/* --- Carte --- */
.rp-map-wrap {
    position: relative;
    margin-bottom: 1.5rem;
}
.rp-map {
    width: calc(100vw - 3rem);
    max-width: calc(1200px - 3rem);
    height: 480px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--ex-stone-200);
    box-shadow: var(--ex-shadow-sm);
}
.rp-map .leaflet-control-zoom {
    margin: 12px;
}
@media (max-height: 600px) {
    .rp-map { height: 320px; }
}

/* --- Popup carte --- */
.rp-popup {
    font-family: var(--ex-font);
    line-height: 1.4;
}
.rp-popup-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .3rem;
}
.rp-popup-nom {
    font-weight: 700;
    font-size: .9rem;
    color: var(--ex-stone-900);
}
.rp-popup-type {
    font-size: .7rem;
    font-weight: 600;
    padding: 4px;
    border-radius: 4px;
    white-space: nowrap;
}
.rp-popup-adr {
    font-size: .8rem;
    color: var(--ex-stone-500);
    margin-bottom: .2rem;
}
.rp-popup-desc {
    font-size: .78rem;
    color: var(--ex-stone-600);
    margin-bottom: .35rem;
    line-height: 1.35;
    border-left: 2px solid var(--ex-stone-200);
    padding-left: 5px;
    margin-left: 7px;
}
.rp-popup-fiche {
    display: inline-block;
    padding: .2rem .5rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--ex-green-700);
    background: var(--ex-green-100);
    border: 1px solid var(--ex-green-200);
    border-radius: 5px;
    text-decoration: none;
}
.rp-popup-fiche:hover {
    background: var(--ex-green-200);
}
.rp-popup-Association .leaflet-popup-content-wrapper,
.rp-popup-Association .leaflet-popup-tip {
    border: 1px solid var(--ex-amber-300);
}
.rp-popup-Entreprise .leaflet-popup-content-wrapper,
.rp-popup-Entreprise .leaflet-popup-tip {
    border: 1px solid var(--ex-indigo-300);
}
.rp-popup-Collectivite .leaflet-popup-content-wrapper,
.rp-popup-Collectivite .leaflet-popup-tip {
    border: 1px solid var(--ex-red-300);
}

/* --- Spinner tuiles (3 points orbitants, esprit logo Assoce) --- */
.rp-tile-spinner {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 32px;
    height: 32px;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    animation: rp-orbit 1.2s linear infinite;
}
.rp-tile-spinner.active {
    opacity: 1;
}
.rp-tile-spinner::before,
.rp-tile-spinner::after,
.rp-tile-spinner span {
    content: '';
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ex-amber-500);
    box-shadow: 0 0 3px rgba(0, 0, 0, .25);
}
.rp-tile-spinner::before {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}
.rp-tile-spinner::after {
    bottom: 3px;
    left: 2px;
}
.rp-tile-spinner span {
    bottom: 3px;
    right: 2px;
}
@keyframes rp-orbit {
    to { transform: rotate(360deg); }
}

/* --- Filtres --- */
.rp-filters {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-bottom: .6rem;
}
.rp-filter-types {
    display: flex;
    gap: .3rem;
    width: 100%;
    box-sizing: border-box;
}
.rp-filter-type-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: .3rem .55rem;
    border: 2px solid var(--ex-stone-200);
    border-radius: 5px;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    background: var(--ex-surface);
    color: var(--ex-stone-600);
    text-align: center;
    transition: background .2s, border-color .2s, color .2s, opacity .2s;
}
.rp-filter-fade {
    animation: rp-fade-in .3s ease;
}
@keyframes rp-fade-in {
    0%   { opacity: .3; }
    100% { opacity: 1; }
}
.rp-filter-type-btn:hover {
    background: var(--ex-stone-50);
}
.rp-filter-input {
    width: 100%;
    box-sizing: border-box;
    padding: .35rem .6rem;
    border: 1px solid var(--ex-stone-200);
    border-radius: 6px;
    font-size: .82rem;
    color: var(--ex-stone-800);
    background: var(--ex-surface);
    outline: none;
}
.rp-filter-input:focus {
    border-color: var(--ex-amber-400);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .15);
}
.rp-filter-type-btn.active-Association {
    background: var(--ex-amber-100);
    border-color: var(--ex-amber-400);
    color: var(--ex-amber-800);
}
.rp-filter-type-btn.active-Entreprise {
    background: var(--ex-indigo-100);
    border-color: var(--ex-indigo-300);
    color: var(--ex-indigo-700);
}
.rp-filter-type-btn.active-Collectivite {
    background: var(--ex-rose-100);
    border-color: var(--ex-rose-300);
    color: var(--ex-rose-700);
}

/* --- Sidebar liste --- */
.rp-sidebar {
    margin-top: 1rem;
}
.rp-sidebar h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ex-stone-800);
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .6rem;
}
.rp-badge {
    background: var(--ex-stone-100);
    border: 1px solid var(--ex-stone-200);
    border-radius: 1rem;
    padding: .1rem .6rem;
    font-size: .72rem;
    color: var(--ex-stone-600);
    font-weight: 600;
}

.rp-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 460px;
    min-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--ex-stone-200);
    border-radius: 8px;
    background: var(--ex-surface);
}
.rp-list li {
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--ex-stone-100);
    cursor: pointer;
    transition: background .12s var(--ex-ease);
}
.rp-list li:last-child { border-bottom: none; }
.rp-list li:hover { background: var(--ex-stone-50); }
.rp-list li.rp-item-active {
    background: var(--ex-amber-50);
    border-left: 3px solid var(--ex-amber-400);
}

.rp-item-nom {
    font-weight: 600;
    color: var(--ex-stone-900);
}
.rp-item-type {
    font-size: .75rem;
    font-weight: 600;
    margin-left: .4rem;
    padding: .1rem .45rem;
    border-radius: 4px;
    vertical-align: middle;
}
.rp-item-type-Association {
    background: var(--ex-amber-100);
    color: var(--ex-amber-800);
}
.rp-item-type-Entreprise {
    background: var(--ex-indigo-100);
    color: var(--ex-indigo-700);
}
.rp-item-type-Collectivite {
    background: var(--ex-rose-100);
    color: var(--ex-rose-700);
}
.rp-item-adresse {
    color: var(--ex-stone-500);
    font-size: .85rem;
    margin-top: .15rem;
}
.rp-item-desc {
    color: var(--ex-stone-600);
    font-size: .82rem;
    margin-top: .2rem;
    line-height: 1.35;
    border-left: 2px solid var(--ex-stone-200);
    padding-left: 5px;
    margin-left: 7px;
}
.rp-item-fiche {
    display: inline-block;
    margin-top: .3rem;
    padding: .2rem .5rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--ex-green-700);
    background-color: var(--ex-green-100);
    border: 1px solid var(--ex-green-200);
    border-radius: 5px;
    text-decoration: none;
}
.rp-item-fiche:hover {
    background-color: var(--ex-green-200);
}

.rp-item-in-view {
    border-left: 3px solid var(--ex-amber-400);
}

.rp-empty {
    padding: 1rem;
    color: var(--ex-stone-500);
    text-align: center;
    font-style: italic;
}

/* --- Erreur --- */
.rp-error {
    padding: 1rem 1.25rem;
    background: var(--ex-red-50);
    border: 1px solid var(--ex-red-200);
    border-radius: 8px;
    color: var(--ex-red-900);
    font-size: .9rem;
}

/* --- Layout large : carte + sidebar côte à côte --- */
@media (min-width: 1100px) {
    #reseau-page {
        display: grid;
        grid-template-columns: 1fr 340px;
        column-gap: 1.5rem;
    }
    .rp-breadcrumb,
    .rp-header,
    .rp-error {
        grid-column: 1 / -1;
    }
    .rp-map-wrap {
        grid-column: 1;
        grid-row: 3;
        margin-bottom: 0;
    }
    .rp-map {
        width: 100%;
        height: 100%;
        min-height: 500px;
    }
    .rp-sidebar {
        grid-column: 2;
        grid-row: 3;
        margin-top: 0;
        display: flex;
        flex-direction: column;
        height: calc(100vh - 200px);
        /*max-height: calc(100vh - 120px);*/
    }
    .rp-sidebar .rp-list {
        flex: 1;
        max-height: none;
        overflow-y: auto;
    }
}

/* --- Dark mode --- */
@media (prefers-color-scheme: dark) {
    .rp-header {
        border-color: var(--ex-stone-300);
        background: rgba(255,255,255,.04);
    }
    .rp-badge {
        background: rgba(255,255,255,.08);
        border-color: var(--ex-stone-300);
    }
    .rp-filter-input {
        background: rgba(255,255,255,.06);
        border-color: var(--ex-stone-300);
        color: var(--ex-stone-100);
    }
    .rp-filter-type-btn {
        background: rgba(255,255,255,.06);
        border-color: var(--ex-stone-400);
        color: var(--ex-stone-200);
    }
    .rp-list {
        border-color: var(--ex-stone-300);
    }
    .rp-list li {
        border-bottom-color: rgba(255,255,255,.06);
    }
    .rp-list li:hover {
        background: rgba(255,255,255,.05);
    }
    .rp-list li.rp-item-active {
        background: rgba(255,187,9,.1);
    }
    .rp-map {
        border-color: var(--ex-stone-300);
    }
    .rp-map .leaflet-popup-content-wrapper {
        background: var(--ex-surface);
        color: var(--ex-text);
    }
    .rp-map .leaflet-popup-tip {
        background: var(--ex-surface);
    }
    .rp-map .leaflet-popup-close-button {
        color: var(--ex-stone-400) !important;
        margin: .2em;
    }
    #rp-map.leaflet-container a {
        color: var(--ex-green-700);
    }
    .rp-map .leaflet-control-zoom a {
        background: var(--ex-stone-800);
        color: var(--ex-stone-200);
        border-color: var(--ex-stone-600);
    }
    .rp-map .leaflet-control-zoom a:hover {
        background: var(--ex-stone-700);
    }
    .rp-map .leaflet-control-attribution {
        background: rgba(30, 30, 30, .7);
        color: var(--ex-stone-400);
    }
    .rp-map .leaflet-control-attribution a {
        color: var(--ex-stone-300);
    }
    #reseau-page .rp-item-desc {
        border-left-color: var(--ex-stone-500);
    }
    #reseau-page .rp-item-adresse {
        color: var(--ex-stone-400);
    }
    .rp-error {
        background: rgba(239,68,68,.1);
        border-color: rgba(239,68,68,.3);
    }
}
