/* Index de la documentation : mise en page a deux colonnes, barre de recherche
   fixe et densite. Charge apres documentation.css, dont il garde les couleurs
   (degrade bleu/vert) ; tout est limite a .doc-index pour ne pas toucher la
   fiche detaillee d'un document.

   --doc-nav-h et --doc-toolbar-h sont mesures par documentation.js. */

.doc-index {
    --doc-nav-h: 80px;
    --doc-toolbar-h: 72px;
}

.doc-index .doc-hero .container,
.doc-index .doc-search .container,
.doc-index .doc-layout {
    width: min(96vw, 1760px);
    max-width: 1760px;
}

/* ---------- Bandeau : meme degrade, moins de hauteur ---------- */

.doc-index .doc-hero {
    padding: 1.75rem 0;
    text-align: left;
}

.doc-index .hero-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem 2rem;
}

.doc-index .hero-content h1 {
    font-size: 2.4rem;
    margin-bottom: 0.4rem;
}

.doc-index .lead {
    margin: 0;
    font-size: 1.1rem;
    max-width: none;
}

.doc-index .hero-stats {
    margin-top: 0;
    gap: 0.75rem;
    justify-content: flex-start;
}

.doc-index .stat-item {
    min-width: 118px;
    padding: 0.7rem 1rem;
}

.doc-index .stat-number {
    font-size: 2rem;
    line-height: 1.1;
}

.doc-index .stat-label {
    display: block;
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

/* ---------- Recherche et filtres : fixes sous la barre du site ---------- */

.doc-index .doc-search {
    position: sticky;
    top: var(--doc-nav-h);
    z-index: 900;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--medium-gray);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.doc-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
}

.doc-index .search-container {
    flex: 1 1 300px;
    max-width: 520px;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.doc-index .search-input {
    padding: 0.6rem 1rem 0.6rem 2.7rem;
    font-size: 1rem;
}

.doc-index .search-input:focus {
    transform: none;
}

.doc-index .search-icon {
    top: 1.35rem;
    font-size: 1rem;
    color: var(--dark-gray);
}

.doc-index .search-results-info {
    flex-basis: 100%;
    margin-top: 0.4rem;
    padding: 0.2rem 0.9rem;
    font-size: 0.85rem;
}

.doc-index .filter-tags {
    margin-top: 0;
    gap: 0.45rem;
    justify-content: flex-start;
}

.doc-index .filter-tag {
    padding: 0.4rem 1.1rem;
    font-family: inherit;
    line-height: 1.4;
}

.doc-index .search-summary {
    margin: 0 0 0 auto;
    font-size: 0.9rem;
}

/* ---------- Deux colonnes ---------- */

.doc-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    padding-top: 1.25rem;
    padding-bottom: 1.5rem;
}

.doc-sidebar {
    position: sticky;
    top: calc(var(--doc-nav-h) + var(--doc-toolbar-h) + 1rem);
    max-height: calc(100vh - var(--doc-nav-h) - var(--doc-toolbar-h) - 2rem);
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--medium-gray);
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 0.9rem 0.6rem;
}

.doc-sidebar-title {
    margin: 0 0 0.6rem;
    padding: 0 0.6rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--dark-gray);
}

.doc-sidebar-title i {
    color: var(--primary-color);
}

.doc-side-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.doc-side-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.6rem;
    border-radius: 10px;
    border-left: 4px solid transparent;
    color: var(--dark-gray);
    text-decoration: none;
    transition: all 0.2s ease;
}

.doc-side-icon {
    flex: 0 0 1.4rem;
    text-align: center;
    font-size: 1.05rem;
    color: var(--primary-color);
}

.doc-side-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.doc-side-code {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--primary-color);
}

.doc-side-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.doc-side-count {
    flex: 0 0 auto;
    min-width: 1.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--light-gray);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
}

.doc-side-link:hover {
    background: rgba(0, 123, 255, 0.08);
    color: var(--dark-gray);
    text-decoration: none;
}

/* Work package en cours de lecture. */
.doc-side-link.active {
    background: linear-gradient(135deg, #007bff, #28a745);
    border-left-color: #ffc107;
    color: var(--white);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.doc-side-link.active .doc-side-icon,
.doc-side-link.active .doc-side-code {
    color: var(--white);
}

.doc-side-link.active .doc-side-count {
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
}

/* ---------- Work packages : memes cartes, plus denses ---------- */

.doc-index .work-package {
    margin: 0 0 1.25rem;
    border-radius: 15px;
    /* Toujours visible : pas de bloc vide en attendant le defilement. */
    opacity: 1;
    transform: none;
    scroll-margin-top: calc(var(--doc-nav-h) + var(--doc-toolbar-h) + 1rem);
}

.doc-index .work-package:last-child {
    margin-bottom: 0;
}

.doc-index .work-package.is-filtered-out {
    display: none;
}

.doc-index .wp-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    text-align: left;
}

.doc-index .wp-header > * {
    position: relative;
    z-index: 2;
}

.doc-index .wp-number {
    font-size: 2rem;
    line-height: 1;
    margin: 0;
}

.doc-index .wp-heading {
    flex: 1;
    min-width: 0;
}

.doc-index .wp-title {
    font-size: 1.35rem;
    margin: 0;
}

.doc-index .wp-description {
    font-size: 0.95rem;
    line-height: 1.4;
    max-width: none;
    margin: 0.2rem 0 0;
}

.wp-count {
    flex: 0 0 auto;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.doc-index .wp-content {
    padding: 1rem;
}

.doc-index .deliverables-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    margin-top: 0;
}

.doc-index .deliverable-category {
    padding: 1rem;
}

.doc-index .deliverable-category:hover {
    transform: none;
}

.doc-index .category-header {
    margin-bottom: 0.75rem;
}

.doc-index .category-icon {
    font-size: 1.2rem;
    margin-right: 0.65rem;
    padding: 0.4rem;
}

.doc-index .category-title {
    font-size: 1.15rem;
}

/* Les documents se rangent en colonnes des que la largeur le permet. */
.doc-index .deliverable-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 0.75rem;
}

.doc-index .deliverable-item {
    align-items: flex-start;
    margin-bottom: 0;
    padding: 0.9rem 1rem;
}

.doc-index .deliverable-item:hover {
    transform: none;
}

.doc-index .deliverable-name {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.doc-index .deliverable-meta {
    gap: 0.35rem;
    font-size: 0.8rem;
}

.doc-index .deliverable-meta + .deliverable-meta {
    margin-top: 0.35rem;
}

.doc-index .deliverable-meta span {
    padding: 0.15rem 0.45rem;
}

.doc-index .deliverable-actions {
    flex-wrap: nowrap;
    margin-left: 0.75rem;
}

.doc-index .icon-only-action {
    width: 36px;
    min-width: 36px;
    height: 36px;
    border-radius: 10px;
}

.doc-index .empty-work-package {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    text-align: left;
    box-shadow: none;
    border-radius: 12px;
    background: var(--light-gray);
}

.doc-index .empty-work-package i {
    font-size: 1.6rem;
    margin: 0;
}

.doc-index .empty-work-package h3 {
    font-size: 1.05rem;
    margin: 0 0 0.15rem;
}

.doc-index .empty-work-package p {
    margin: 0;
    font-size: 0.9rem;
}

.doc-index .doc-no-results {
    margin-bottom: 1.25rem;
    background: var(--white);
}

.doc-index .doc-no-results[hidden] {
    display: none;
}

/* ---------- Ecrans etroits ---------- */

@media (max-width: 991.98px) {
    .doc-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.9rem;
        padding-top: 0.9rem;
    }

    /* Le sommaire devient une bande defilante, elle aussi fixe. */
    .doc-sidebar {
        top: calc(var(--doc-nav-h) + var(--doc-toolbar-h));
        z-index: 890;
        max-height: none;
        padding: 0.45rem;
        border-radius: 12px;
    }

    .doc-sidebar-title {
        display: none;
    }

    .doc-side-list {
        flex-direction: row;
        overflow-x: auto;
        gap: 0.4rem;
    }

    .doc-side-link {
        flex: 0 0 auto;
        padding: 0.35rem 0.7rem;
        border-left-width: 0;
    }

    .doc-side-icon,
    .doc-side-name {
        display: none;
    }

    .doc-side-code {
        font-size: 0.85rem;
    }

    .doc-index .work-package {
        scroll-margin-top: calc(var(--doc-nav-h) + var(--doc-toolbar-h) + 4.5rem);
    }

    .doc-index .search-summary {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .doc-index .doc-hero {
        padding: 1.25rem 0;
    }

    .doc-index .hero-content h1 {
        font-size: 1.8rem;
    }

    .doc-index .hero-stats {
        flex-direction: row;
        gap: 0.5rem;
    }

    .doc-index .stat-item {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
        padding: 0.5rem 0.75rem;
    }

    .doc-index .stat-number {
        font-size: 1.5rem;
    }

    .doc-index .wp-header {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
        padding: 0.8rem 1rem;
    }

    .doc-index .wp-number {
        font-size: 1.5rem;
    }

    .doc-index .wp-title {
        font-size: 1.15rem;
    }

    .doc-index .wp-content {
        padding: 0.6rem;
    }

    .doc-index .deliverable-category {
        padding: 0.75rem;
    }

    .doc-index .deliverable-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .doc-index .deliverable-item {
        gap: 0.6rem;
    }

    .doc-index .deliverable-actions {
        margin-left: 0;
    }

    .doc-index .btn-action {
        flex: 0 0 auto;
    }
}

/* Work package sans resultat pendant une recherche ou un filtrage. */
.doc-side-link.is-muted {
    opacity: 0.45;
}

/* La barre du site est moins haute que la marge reservee par base.css. */
.doc-index {
    margin-top: calc(var(--doc-nav-h) - 80px);
}

@media (max-width: 767.98px) {
    /* Les filtres tiennent sur une ligne defilante pour limiter la hauteur fixe. */
    .doc-index .filter-tags {
        flex-wrap: nowrap;
        overflow-x: auto;
        max-width: 100%;
        padding-bottom: 2px;
    }

    .doc-index .filter-tag {
        flex: 0 0 auto;
    }

    .doc-index .filter-tag:hover,
    .doc-index .filter-tag.active {
        transform: none;
    }

    /* Code et compteur sur la premiere ligne, titre et description dessous. */
    .doc-index .wp-heading {
        order: 3;
        flex: 1 1 100%;
    }

    .doc-index .wp-count {
        margin-left: auto;
    }
}
