/* Espace « Recherche » du débouché.
   Reprend les codes du portail : fond clair, cartes blanches, vert Greenr en accent. */

.sourcing-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.sourcing-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.sourcing-header h1 {
    margin: 0 0 6px;
    font-size: 1.6rem;
}

.sourcing-intro {
    margin: 0;
    color: #5a6b62;
    max-width: 62ch;
}

.sourcing-loading,
.sourcing-muted {
    color: #7a8b82;
}

.sourcing-empty,
.sourcing-empty-matches {
    background: #fff;
    border: 1px solid #e3eae6;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    color: #5a6b62;
}

.sourcing-empty h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

/* ---------------------------------------------------------------- recherches */

.sourcing-searches {
    margin-bottom: 32px;
}

.sourcing-searches h2 {
    font-size: 1.05rem;
    margin: 0 0 12px;
}

.sourcing-search {
    background: #fff;
    border: 1px solid #e3eae6;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 10px;
}

.sourcing-search-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.sourcing-search h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.sourcing-search-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    white-space: nowrap;
}

.sourcing-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sourcing-chip {
    display: inline-block;
    background: #f2f7f4;
    border: 1px solid #dbe8e1;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.8rem;
    color: #3f5a4d;
}

.sourcing-chip-muted {
    background: #f7f8f8;
    color: #8a9992;
}

.sourcing-count {
    font-weight: 600;
    color: #2e7d5b;
}

/* ---------------------------------------------------------------- tableau */

.sourcing-group {
    margin-bottom: 34px;
}

.sourcing-group h3 {
    font-size: 1.05rem;
    margin: 0 0 10px;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.sourcing-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e3eae6;
    border-radius: 10px;
    overflow: hidden;
}

.sourcing-table th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #8a9992;
    padding: 10px 14px;
    border-bottom: 1px solid #eef2f0;
}

.sourcing-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f2f5f3;
    vertical-align: middle;
}

.sourcing-table tr:last-child td {
    border-bottom: none;
}

.sourcing-matiere {
    font-weight: 600;
}

.sourcing-sub {
    font-size: 0.82rem;
    color: #8a9992;
}

.sourcing-img img,
.sourcing-img-vide {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
    background: #eef3f0;
}

.sourcing-tag {
    display: inline-block;
    background: #e8f5ee;
    color: #2e7d5b;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
}

/* Une donnée manquante se signale, elle ne se cache pas : le débouché doit savoir
   que la caractéristique n'a pas été vérifiée, pas croire qu'elle est absente. */
.sourcing-flag {
    display: inline-block;
    background: #fdf4e3;
    color: #8a6d1f;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
}

.sourcing-actions {
    text-align: right;
}

.sourcing-choice {
    font-size: 0.85rem;
    font-weight: 600;
}

.sourcing-choice-interested {
    color: #2e7d5b;
}

.sourcing-choice-not_interested {
    color: #97a39c;
}

/* ---------------------------------------------------------------- boutons */

.sourcing-btn {
    background: #fff;
    border: 1px solid #cddcd4;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.88rem;
    cursor: pointer;
    color: #2f4a3d;
}

.sourcing-btn:hover {
    border-color: #2e7d5b;
}

.sourcing-btn-primary {
    background: #2e7d5b;
    border-color: #2e7d5b;
    color: #fff;
}

.sourcing-btn-primary:hover {
    background: #266b4d;
}

.sourcing-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.sourcing-link {
    background: none;
    border: none;
    color: #2e7d5b;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-size: 0.85rem;
}

.sourcing-more {
    margin-top: 10px;
    background: none;
    border: 1px dashed #cddcd4;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    color: #3f5a4d;
    width: 100%;
}

/* ---------------------------------------------------------------- modale */

.sourcing-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 35, 28, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    z-index: 1000;
}

.sourcing-modal.hidden {
    display: none;
}

.sourcing-modal-box {
    background: #fff;
    border-radius: 14px;
    width: min(680px, 100%);
    padding: 22px 26px 26px;
}

.sourcing-modal-box header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sourcing-modal-box h2 {
    margin: 0;
    font-size: 1.2rem;
}

.sourcing-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #8a9992;
}

.sourcing-modal-box fieldset {
    border: 1px solid #e6ece9;
    border-radius: 10px;
    padding: 14px 16px;
    margin: 0 0 14px;
}

.sourcing-modal-box legend {
    font-size: 0.85rem;
    font-weight: 600;
    color: #3f5a4d;
    padding: 0 6px;
}

.sourcing-modal-box label {
    display: block;
    font-size: 0.88rem;
    color: #3f5a4d;
    margin-bottom: 10px;
}

.sourcing-modal-box input,
.sourcing-modal-box select,
.sourcing-modal-box textarea {
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid #cddcd4;
    border-radius: 8px;
    font: inherit;
}

.sourcing-row {
    display: flex;
    gap: 14px;
}

.sourcing-row > label {
    flex: 1;
}

/* Capacité technique : le Oui/Non tient sur un tiers, le commentaire prend le reste.
   Le commentaire est la moitié utile de l'information — il ne doit pas ressembler à un
   champ optionnel relégué en bout de ligne. */
.sourcing-capacite {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.sourcing-capacite:last-of-type {
    border-bottom: none;
}

.sourcing-capacite > label {
    flex: 1;
}

.sourcing-capacite > .sourcing-capacite-note {
    flex: 2;
}

.sourcing-capacite textarea {
    width: 100%;
    resize: vertical;
    font: inherit;
}

@media (max-width: 640px) {
    .sourcing-capacite { flex-direction: column; gap: 6px; }
}

/* Date de dernière exécution : discrète, mais toujours présente. Un « 0 gisement » sans
   date ne se distingue pas d'un calcul jamais lancé. */
.sourcing-maj {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted, #6b7280);
}

.sourcing-maj-encours {
    color: var(--accent, #2563eb);
}

/* Spinner : il remplace le compteur, il ne s'y ajoute pas — afficher un nombre qu'on sait
   périmé à côté d'une animation de chargement serait contradictoire. */
.sourcing-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border, #e5e7eb);
    border-top-color: var(--accent, #2563eb);
    border-radius: 50%;
    animation: sourcing-spin 0.7s linear infinite;
}

@keyframes sourcing-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .sourcing-spinner { animation-duration: 2.5s; }
}

.sourcing-check {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.sourcing-check input {
    width: auto;
    margin: 0;
}

.sourcing-hint {
    color: #8a9992;
    font-size: 0.78rem;
    font-weight: 400;
}

.sourcing-modal-box footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

.sourcing-form-error {
    color: #b3261e;
    font-size: 0.85rem;
    margin-top: 10px;
}

.sourcing-form-error.hidden {
    display: none;
}

.sourcing-fiche dl {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px 16px;
    margin: 0 0 14px;
}

.sourcing-fiche dt {
    color: #8a9992;
    font-size: 0.85rem;
}

.sourcing-fiche dd {
    margin: 0;
}

.sourcing-note {
    background: #fdf4e3;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #8a6d1f;
}

.sourcing-choix {
    display: flex;
    gap: 10px;
    margin: 18px 0 6px;
}

@media (max-width: 720px) {
    .sourcing-header { flex-direction: column; }
    .sourcing-row { flex-direction: column; gap: 0; }
    .sourcing-table th:first-child,
    .sourcing-table td:first-child { display: none; }
}

/* Sélecteur d'entreprise : toujours présent, désactivé s'il n'y en a qu'une.
   Une recherche appartient à une entreprise — l'utilisateur doit voir laquelle. */
.sourcing-company {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 4px;
}

.sourcing-company label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8a9992;
}

.sourcing-company select {
    padding: 6px 10px;
    border: 1px solid #cddcd4;
    border-radius: 8px;
    font: inherit;
    background: #fff;
    min-width: 260px;
}

.sourcing-company select:disabled {
    background: #f4f7f5;
    color: #3f5a4d;
    cursor: default;
}

/* Explication d'un résultat : pourquoi ce nombre, et ce qui est actionnable. */
.sourcing-explication {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sourcing-explication li {
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 8px;
    background: #f7f9f8;
    color: #5a6b62;
}

/* Une contrainte établie : le gisement existe, l'unité ne peut pas le traiter. */
.sourcing-blocage-bloquant {
    background: #fdf0ee;
    color: #8a3a2f;
}

/* Une fiche muette : c'est réparable, et ça débloque des gisements réels. */
.sourcing-blocage-a_renseigner {
    background: #fdf4e3;
    color: #8a6d1f;
}

.sourcing-blocage .sourcing-link {
    margin-left: 8px;
}

.sourcing-motifs {
    color: #7a8b82;
}

/* ------------------------------------------------- liste cliquable des recherches */

/* Chaque recherche est un bouton : on l'ouvre pour voir ses gisements. */
button.sourcing-search {
    display: block;
    width: 100%;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

button.sourcing-search:hover {
    border-color: #2e7d5b;
    box-shadow: 0 1px 6px rgba(46, 125, 91, 0.12);
}

.sourcing-search-main {
    flex: 1;
    min-width: 0;
}

.sourcing-search-meta {
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
}

.sourcing-count-label {
    font-size: 0.75rem;
    color: #8a9992;
}

.sourcing-chevron {
    font-size: 1.5rem;
    color: #b7c6bf;
    line-height: 1;
    margin-top: 4px;
}

/* ------------------------------------------------- page d'une recherche */

.sourcing-back {
    background: none;
    border: none;
    color: #2e7d5b;
    cursor: pointer;
    padding: 0;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.sourcing-back:hover {
    text-decoration: underline;
}

.sourcing-header-actions {
    display: flex;
    gap: 10px;
}

.sourcing-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.sourcing-filtre {
    flex: 1;
    max-width: 380px;
    padding: 9px 12px;
    border: 1px solid #cddcd4;
    border-radius: 8px;
    font: inherit;
}

.sourcing-filtre:focus {
    outline: none;
    border-color: #2e7d5b;
}

/* ------------------------------------------------- formulaire en accordéons */

.sourcing-modal-large {
    width: min(760px, 100%);
}

.sourcing-nom {
    margin-bottom: 18px !important;
}

.sourcing-accordeon {
    border: 1px solid #e6ece9;
    border-radius: 10px;
    margin-bottom: 6px;
    overflow: hidden;
    transition: opacity 0.15s;
}

.sourcing-accordeon-tete {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "titre fleche" "sous fleche";
    gap: 2px 12px;
    width: 100%;
    text-align: left;
    background: #f7f9f8;
    border: none;
    padding: 14px 16px;
    cursor: pointer;
    font: inherit;
}

.sourcing-accordeon-tete:hover {
    background: #f1f6f3;
}

.sourcing-accordeon-titre {
    grid-area: titre;
    font-weight: 600;
    color: #2f4a3d;
}

.sourcing-accordeon-sous {
    grid-area: sous;
    font-size: 0.82rem;
    color: #8a9992;
}

.sourcing-accordeon-fleche {
    grid-area: fleche;
    align-self: center;
    color: #8a9992;
    transition: transform 0.15s;
}

.sourcing-accordeon-tete[aria-expanded="true"] .sourcing-accordeon-fleche {
    transform: rotate(180deg);
}

.sourcing-accordeon-corps {
    padding: 16px;
}

.sourcing-accordeon-corps.hidden {
    display: none;
}

/* Le bloc non retenu s'efface : on cherche par matière OU par profil, pas les deux. */
.sourcing-accordeon-inactif {
    opacity: 0.45;
    pointer-events: none;
}

.sourcing-ou {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
    color: #8a9992;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sourcing-ou::before,
.sourcing-ou::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e6ece9;
}

/* ------------------------------------------------- sélection des matières */

.sourcing-matieres {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #e6ece9;
    border-radius: 8px;
    margin-top: 10px;
}

.sourcing-matiere-item {
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    margin: 0 !important;
    border-bottom: 1px solid #f2f5f3;
    cursor: pointer;
}

.sourcing-matiere-item:last-child {
    border-bottom: none;
}

.sourcing-matiere-item:hover {
    background: #f7f9f8;
}

.sourcing-matiere-item.hidden {
    display: none !important;
}

.sourcing-matiere-item input {
    width: auto !important;
    margin: 0 !important;
}

.sourcing-matiere-nom {
    color: #2f4a3d;
}

/* Le nombre de gisements guide le choix : une matière sans gisement ne sert à rien. */
.sourcing-matiere-nb {
    font-size: 0.78rem;
    color: #8a9992;
    background: #f2f7f4;
    border-radius: 999px;
    padding: 1px 8px;
}

.sourcing-toujours {
    margin-top: 16px !important;
}

/* ------------------------------------------------- fiche gisement */

.sourcing-fiche h3 {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a9992;
    margin: 18px 0 8px;
}

.sourcing-fiche h3:first-of-type {
    margin-top: 0;
}

.sourcing-fiche-img {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 16px;
}

.sourcing-contraintes {
    background: #f7f9f8;
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0 0 8px;
}

.sourcing-contraintes dt {
    color: #5a6b62;
}
