/* ==========================================================================
   C.R.E.A.M. - Design System Section: B.D.D. View & Resources List
   ========================================================================== */

/* BDD Toolbar & Filters */
.bdd-toolbar {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.search-box-container {
    flex: 2;
    position: relative;
}

.search-box-container i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-input-premium {
    width: 100%;
    padding: 0.7rem 1rem 0.7rem 2.8rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s;
}

.search-input-premium:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent-gold);
    outline: none;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.1);
}

.filter-dropdown-container {
    flex: 1.5;
    position: relative;
}

.filter-trigger-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 1rem;
    height: 38px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    min-width: 180px;
    /* Élargissement pour éviter le vide */
    width: 100%;
}

.filter-trigger-btn.search-mode {
    cursor: text;
    min-width: 140px;
}

.kw-trigger-input {
    background: none;
    border: none;
    color: var(--ghost-slate);
    font-size: 0.85rem;
    font-family: inherit;
    width: 100%;
    outline: none;
    padding: 0;
}

.kw-trigger-input::placeholder {
    color: var(--ghost-slate);
    opacity: 0.8;
}

.filter-trigger-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.filter-trigger-btn.active {
    color: var(--text-primary);
    font-weight: 600;
}

.filter-trigger-mega {
    color: var(--accent-bridge) !important;
}

.filter-trigger-tags {
    color: var(--ghost-slate) !important;
}

.filter-menu-premium {
    display: none;
    position: absolute;
    top: 100%;
    /* Suppression du gap de 10% pour la stabilité */
    left: 0;
    width: 100%;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(25px);
    margin-top: 4px;
    /* Un petit décalage visuel géré proprement */
}

.kw-menu-width {
    width: 240px;
}

.kw-search-wrapper {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.kw-search-input {
    width: 100%;
    padding: 0.5rem 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
}

/* --- TOOLBARS & FILTERS --- */
.toolbar-premium-container {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.toolbar-label-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.toolbar-label-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.group-toggle-container {
    display: flex;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--border-color);
}

.group-toggle-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.group-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.group-toggle-btn.active {
    background: var(--accent-bridge);
    color: white;
    font-weight: 600;
}

.group-toggle-btn.active.gold {
    background: var(--accent-gold);
    color: var(--bg-color);
}

.filter-group-title {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--accent-bridge);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.8rem 0.8rem 0.4rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 0.2rem;
    opacity: 0.8;
}

.filter-item-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-item-label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.filter-checkbox {
    accent-color: var(--accent-gold);
    width: 16px;
    height: 16px;
}

.filter-checkbox.purple {
    accent-color: var(--accent-purple);
}

.btn-reset-filters {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.7rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset-filters:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Data Table */
.bdd-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.6rem;
}

.fixed-layout {
    table-layout: fixed;
}

.bdd-table th {
    padding: 0 1rem 0.5rem 1rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-align: left;
    /* Alignement par défaut */
}

/* Cellule de la sentinelle IntersectionObserver pour le défilement infini */
.bdd-sentinel-cell {
    height: 1px;
    border: none;
    background: transparent;
}

.theme-row {
    background: var(--card-bg);
    /* Note : backdrop-filter volontairement absent.
     * Sur fond sombre opaque (--card-bg), le flou n'a aucun effet visuel perceptible.
     * Sa présence créait un stacking context CSS qui confinait les tooltips ::after
     * à l'intérieur de leur ligne et les faisait passer derrière les lignes suivantes. */
    border-radius: 12px;
    transition: transform 0.2s;
}

.theme-row td {
    padding: 0.8rem 1rem;
    vertical-align: top;
}

.theme-row td.col-id {
    color: var(--ghost-slate);
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    vertical-align: top;
    padding: 0.8rem 0.8rem;
}

/* Optimisation des colonnes pour réduire le vide (Spécificité renforcée pour éviter !important) */
.bdd-table td.col-hierarchy,
.bdd-table td.col-theme,
.bdd-table td.col-source,
.bdd-table td.col-format,
.bdd-table td.col-pertinence,
.bdd-table td.col-axe,
.bdd-table td.col-mega,
.bdd-table td.col-desc {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.col-extract {
    padding-right: 0.5rem !important;
}

.id-flex-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
}

.theme-row td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.mega-badge {
    color: var(--mega-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
    /* Respiration avant la liste des ressources */
    display: inline-block;
}

.badge-orphan {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(100, 116, 139, 0.1);
    border: 1px solid var(--ghost-slate);
    border-radius: 4px;
    color: var(--ghost-slate);
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.badge-ghost-slate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: rgba(100, 116, 139, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px; /* Coins en pilule premium */
    color: var(--ghost-slate);
    font-size: 0.75rem;
    margin-right: 6px;
    margin-bottom: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.badge-ghost-slate:hover {
    background: rgba(100, 116, 139, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

/* --- RESOURCE SPECIFIC STYLES --- */
.pertinence-stars {
    color: var(--accent-gold);
    white-space: nowrap;
    font-size: 0.7rem;
    /* Taille réduite pour éviter tout débordement dans la grille */
    letter-spacing: 0.02em;
}

.secondary-megas-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.mega-theme-label {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.cell-center {
    text-align: center;
}

.cell-right {
    text-align: right;
    padding-right: 30px !important;
}

.resource-id-number {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.resource-id-tag {
    font-size: 0.55rem;
    color: var(--text-secondary);
    opacity: 0.6;
    margin-top: 4px;
}

.resource-extract-text {
    margin-top: 0;
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--text-primary);
    display: block;
    width: 100%;
    text-align: left;
}

.resource-format-cell {
    font-size: 0.85rem;
    text-transform: capitalize;
    color: var(--text-secondary);
}

.source-link-web {
    color: var(--accent-gold);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
    margin-right: 8px;
    margin-bottom: 4px;
}

.note-link {
    color: var(--accent-gold);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: all 0.2s;
}

.note-link:hover {
    color: var(--text-primary);
    text-decoration-color: var(--accent-gold);
}

.source-link-local {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-block;
    margin-right: 8px;
    margin-top: 4px;
}

.toolbar-icon-gold {
    color: var(--accent-gold);
    font-size: 0.9rem;
}

.table-header-small {
    font-size: 0.7rem;
}

.text-dimmed {
    opacity: 0.3;
}

.theme-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.7rem;
    margin-left: -0.7rem;
    width: calc(100% + 1.4rem);
    border-radius: 8px;
    transition: background-color 0.25s ease;
}

.theme-header:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.theme-title {
    display: flex;
    align-items: center;
    font-size: 1rem;
    font-weight: 700;
    border-left: 3px solid var(--accent-bridge);
    padding-left: 12px;
    line-height: 1.2;
    color: var(--text-primary);
}

.theme-chevron-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-right: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-header:hover .theme-chevron-container {
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.2);
    color: var(--accent-gold);
}

.theme-chevron-container.expanded {
    transform: rotate(90deg);
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.3);
    color: var(--accent-gold);
}

.theme-chevron-container i {
    font-size: 0.75rem;
    transition: transform 0.3s;
}

.theme-actions {
    display: flex;
    gap: 8px;
}

.theme-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    opacity: 0.5;
}

.theme-actions button:hover {
    opacity: 1;
    transform: scale(1.05);
}

.theme-actions button .fa-pencil-alt {
    color: #3b82f6;
}

.theme-actions button .fa-trash-alt {
    color: #ef4444;
}

.theme-keywords {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    opacity: 0.8;
}

.theme-title-list {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    border-left: 2px solid var(--accent-bridge);
    padding-left: 8px;
}

.theme-badge-resource {
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    display: block;
    /* Exploite toute la largeur */
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 4px;
    border-left: 3px solid var(--accent-bridge);
    transition: var(--premium-card-transition);
    cursor: pointer;
    color: var(--text-secondary);
}

/* 
   CLEAN CODE OPTIMIZATION : OPTICAL ALIGNMENT
   Cible uniquement les colonnes Hiérarchie (Thématiques) et Thématiques Associées (Ressources).
   On réduit le padding du TD pour laisser le badge "respirer" tout en s'alignant sur le texte global.
*/
.bdd-table td.col-hierarchy,
.bdd-table td.col-theme {
    padding-left: 0.3rem !important;
    padding-right: 0.3rem !important;
}

.col-hierarchy .theme-badge-resource,
.col-theme .theme-badge-resource {
    margin-left: -2px;
    /* Alignement optique uniquement */
    width: calc(100% + 4px);
    padding: 6px 10px;
    /* Retour aux standards */
    font-size: 0.75rem;
    /* Retour aux standards */
    border-radius: 6px;
    /* Retour aux standards */
}

.theme-badge-resource:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
    transform: translateX(4px);
    /* Retour au standard d'animation */
    border-color: rgba(255, 255, 255, 0.2);
}

.resource-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    margin-bottom: 0.6rem;
    transition: var(--premium-card-transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);

    display: grid;
    grid-template-columns: 65% 28% 7%;
    gap: 0.8rem;

    width: 100%;
    align-items: start;
}

.resource-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.card-actions-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 4px;
}

.resource-extract {
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 0;
    font-size: 0.85rem;
    color: #cbd5e1;
    border-left: 3px solid rgba(251, 191, 36, 0.4);
    padding-left: 15px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.resource-info-side {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 2px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    padding-left: 0.8rem;
}

.resource-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.attachment-link {
    color: var(--accent-gold);
    text-decoration: none;
    font-size: 0.75rem;
    display: block;
    margin-top: 4px;
    transition: color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.attachment-link:hover {
    color: var(--text-primary);
}

.no-resource-msg {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

/* ==========================================================================
   Tooltip CSS natif pour la description des thématiques
   100% CSS via ::after + attr(data-tooltip). Zéro JS, zéro requête réseau.
   ========================================================================== */

.theme-title[data-tooltip] {
    position: relative;
}

.theme-title[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 200;

    padding: 10px 14px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid #c0362c;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;

    width: max-content;
    max-width: 600px;
    min-width: 220px;

    /* Apparition douce avec délai pour éviter les flashs au survol rapide */
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    transform: translateY(-4px);
}

.theme-title[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(0);
}
