/* ===================== SEARCH MODAL (NOUVEAU - VERSION NOIRE) ===================== */
.search-modal-overlay{
    position:fixed;
    inset:0;
    z-index:950;
    background:rgba(0,0,0,0.7);
    opacity:0;
    visibility:hidden;
    transition:opacity .3s var(--ease), visibility .3s;
    backdrop-filter:blur(6px);
}

.search-modal-overlay.open{
    opacity:1;
    visibility:visible;
}

.search-modal{
    position:fixed;
    top:20px;
    right:20px;
    z-index:951;
    width:500px;
    height:700px;
    background:#000000 !important; /* ✅ FOND NOIR FORCÉ */
    opacity:0;
    visibility:hidden;
    transform:translateX(20px);
    transition:opacity .3s var(--ease), transform .3s var(--ease), visibility .3s;
    display:flex;
    flex-direction:column;
    box-shadow:0 20px 60px rgba(0,0,0,.5);
    border-radius:12px;
    overflow:hidden;
    border:1px solid rgba(255,255,255,0.1);
}

.search-modal.open{
    opacity:1;
    visibility:visible;
    transform:translateX(0);
}

.search-modal-header{
    display:flex;
    align-items:center;
    gap:10px;
    padding:20px 24px;
    border-bottom:1px solid rgba(255,255,255,0.1); /* ✅ Bordure sombre */
    flex-shrink:0;
    background:#000000; /* ✅ Fond noir */
}

.search-modal-header .search-input-wrapper{
    flex:1;
    display:flex;
    align-items:center;
    background:rgba(255,255,255,0.08); /* ✅ Fond sombre */
    border-radius:8px;
    padding:0 14px;
    height:48px;
    transition:all .3s ease;
    border:1px solid rgba(255,255,255,0.1);
}

.search-modal-header .search-input-wrapper:focus-within{
    background:rgba(255,255,255,0.12);
    box-shadow:0 0 0 2px rgba(255,214,0,0.3);
    border-color:#FFD600;
}

.search-modal-header .search-input-wrapper svg{
    width:18px;
    height:18px;
    stroke:#999; /* ✅ Icône grise */
    flex-shrink:0;
    margin-right:10px;
}

.search-modal-header input{
    flex:1;
    border:none;
    background:transparent;
    font-family:'Poppins',sans-serif;
    font-size:15px;
    color:#ffffff; /* ✅ Texte blanc */
    outline:none;
    padding:0;
}

.search-modal-header input::placeholder{
    color:#777; /* ✅ Placeholder gris */
}

.search-modal-close{
    width:40px;
    height:40px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:50%;
    background:rgba(255,255,255,0.1); /* ✅ Fond sombre */
    color:#ffffff; /* ✅ Icône blanche */
    transition:all .3s ease;
    flex-shrink:0;
    cursor:pointer;
    border:none;
}

.search-modal-close:hover{
    background:rgba(255,255,255,0.2);
    transform:rotate(90deg);
}

.search-modal-close svg{
    width:18px;
    height:18px;
    stroke:currentColor;
}

.search-modal-body{
    flex:1;
    padding:24px;
    overflow-y:auto;
    min-height:0;
    background:#000000; /* ✅ Fond noir */
    scroll-behavior:smooth;
}

/* Historique de recherche */
.search-history-section{
    animation:fadeInResults 0.3s ease;
}

.search-history-title{
    font-family:'Poppins',sans-serif;
    font-size:12px;
    letter-spacing:.16em;
    color:#999; /* ✅ Texte gris */
    text-transform:uppercase;
    font-weight:600;
    margin-bottom:16px;
}

.search-history-list{
    display:flex;
    flex-direction:column;
    gap:4px;
}

.search-history-item{
    display:flex;
    align-items:center;
    gap:12px;
    padding:12px 14px;
    border-radius:8px;
    transition:all .3s ease;
    cursor:pointer;
    color:#ffffff; /* ✅ Texte blanc */
}

.search-history-item:hover{
    background:rgba(255,255,255,0.06); /* ✅ Hover sombre */
}

.search-history-item svg{
    width:18px;
    height:18px;
    stroke:#999;
    flex-shrink:0;
}

.search-history-item .history-text{
    flex:1;
    font-size:14px;
    color:#f5f5f5; /* ✅ Texte clair */
    text-align:left;
}

.search-history-item .remove-history{
    width:28px;
    height:28px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:50%;
    color:#999;
    transition:all .3s ease;
    flex-shrink:0;
    cursor:pointer;
    background:none;
    border:none;
}

.search-history-item .remove-history:hover{
    background:rgba(255,255,255,0.1);
    color:#ffffff;
}

.search-history-item .remove-history svg{
    width:14px;
    height:14px;
    stroke:currentColor;
}

.search-empty{
    text-align:center;
    padding:40px 20px;
    color:#999;
    font-size:14px;
}

.search-empty svg{
    width:48px;
    height:48px;
    stroke:#555;
    margin-bottom:16px;
}

/* ===================== ÉTATS DE CHARGEMENT ===================== */
.search-loading {
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    padding:60px 20px;
    gap:16px;
    min-height:300px;
    animation:fadeInResults 0.3s ease;
}

.search-loading-spinner {
    width:48px;
    height:48px;
    border:4px solid rgba(255,255,255,0.1);
    border-top-color:#FFD600;
    border-radius:50%;
    animation:spin 0.8s linear infinite;
}

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

.search-loading-text {
    font-size:14px;
    color:#999;
    font-family:'Poppins',sans-serif;
}

/* ===================== RÉSULTATS DE RECHERCHE ===================== */
.search-results-header {
    display:flex;
    flex-direction:column;
    gap:8px;
    margin-bottom:20px;
    padding-bottom:16px;
    border-bottom:2px solid rgba(255,255,255,0.1);
    animation:fadeInResults 0.3s ease;
}

.search-results-title {
    font-family:'Poppins',sans-serif;
    font-size:16px;
    font-weight:600;
    color:#ffffff;
    text-align:left;
}

.search-back-btn {
    display:flex;
    align-items:center;
    gap:6px;
    padding:6px 0;
    background:none;
    border:none;
    color:#999;
    cursor:pointer;
    font-size:13px;
    font-family:'Poppins',sans-serif;
    transition:color 0.3s ease;
    align-self:flex-start;
}

.search-back-btn:hover {
    color:#FFD600;
}

.search-back-btn svg {
    width:14px;
    height:14px;
    stroke:currentColor;
}

/* ===================== CONTENU HTML RENDU (DOCUMENT) ===================== */
.search-html-content {
    font-family:'Poppins',sans-serif;
    line-height:1.8;
    color:#f5f5f5; /* ✅ Texte clair */
    text-align:justify;
    word-wrap:break-word;
    overflow-wrap:break-word;
    max-width:100%;
    padding:24px;
    background:#0a0a0a; /* ✅ Fond très sombre */
    border-radius:8px;
    border:1px solid rgba(255,255,255,0.1);
    animation:fadeInResults 0.3s ease;
}

@keyframes fadeInResults {
    from {
        opacity:0;
        transform:translateY(10px);
    }
    to {
        opacity:1;
        transform:translateY(0);
    }
}

/* Titres */
.search-html-content h1,
.search-html-content h2,
.search-html-content h3,
.search-html-content h4,
.search-html-content h5,
.search-html-content h6 {
    color:#ffffff;
    margin-bottom:16px;
    font-weight:600;
    text-align:left;
    line-height:1.4;
}

.search-html-content h1 {
    font-size:28px;
    margin-top:24px;
    padding-bottom:12px;
    border-bottom:2px solid rgba(255,255,255,0.1);
}

.search-html-content h2 {
    font-size:24px;
    margin-top:20px;
    padding-bottom:8px;
    border-bottom:1px solid rgba(255,255,255,0.1);
}

.search-html-content h3 {
    font-size:20px;
    margin-top:16px;
}

.search-html-content h4 {
    font-size:18px;
    margin-top:14px;
}

.search-html-content h5 {
    font-size:16px;
    margin-top:12px;
}

.search-html-content h6 {
    font-size:14px;
    margin-top:10px;
    text-transform:uppercase;
    letter-spacing:0.5px;
}

/* Paragraphes */
.search-html-content p {
    margin-bottom:16px;
    text-align:justify;
    text-justify:inter-word;
    hyphens:auto;
    color:#e0e0e0;
}

/* Liens */
.search-html-content a {
    color:#FFD600;
    text-decoration:underline;
    cursor:pointer;
    transition:color 0.3s ease;
}

.search-html-content a:hover {
    color:#fff;
}

/* Images */
.search-html-content img {
    max-width:100%;
    height:auto;
    border-radius:8px;
    margin:20px auto;
    display:block;
    box-shadow:0 2px 8px rgba(0,0,0,0.3);
}

/* Listes */
.search-html-content ul,
.search-html-content ol {
    margin:16px 0;
    padding-left:24px;
    text-align:left;
    color:#e0e0e0;
}

.search-html-content ul {
    list-style-type:disc;
}

.search-html-content ol {
    list-style-type:decimal;
}

.search-html-content li {
    margin-bottom:8px;
    line-height:1.6;
    text-align:left;
    color:#e0e0e0;
}

/* Tableaux */
.search-html-content table {
    width:100%;
    border-collapse:collapse;
    margin:20px 0;
    text-align:left;
}

.search-html-content table th,
.search-html-content table td {
    padding:12px;
    border:1px solid rgba(255,255,255,0.15);
    color:#e0e0e0;
}

.search-html-content table th {
    background:rgba(255,255,255,0.08);
    font-weight:600;
    color:#ffffff;
}

.search-html-content table tr:nth-child(even) {
    background:rgba(255,255,255,0.03);
}

/* Citations */
.search-html-content blockquote {
    margin:20px 0;
    padding:16px 20px;
    border-left:4px solid #FFD600;
    background:rgba(255,214,0,0.05);
    font-style:italic;
    color:#ccc;
    border-radius:0 8px 8px 0;
}

/* Code */
.search-html-content code {
    background:rgba(255,255,255,0.08);
    padding:2px 6px;
    border-radius:3px;
    font-family:'Courier New',monospace;
    font-size:0.9em;
    color:#FFD600;
}

.search-html-content pre {
    background:rgba(255,255,255,0.05);
    padding:16px;
    border-radius:8px;
    overflow-x:auto;
    margin:20px 0;
}

.search-html-content pre code {
    background:none;
    padding:0;
    color:#e0e0e0;
}

/* Lignes horizontales */
.search-html-content hr {
    border:none;
    border-top:2px solid rgba(255,255,255,0.1);
    margin:24px 0;
}

/* Éléments en gras et italique */
.search-html-content strong {
    font-weight:600;
    color:#ffffff;
}

.search-html-content em {
    font-style:italic;
}

/* Marquer le texte */
.search-html-content mark {
    background:rgba(255,214,0,0.3);
    color:#fff;
    padding:2px 4px;
    border-radius:2px;
}

/* Petits textes */
.search-html-content small {
    font-size:0.85em;
    color:#999;
}

/* Boutons dans le contenu */
.search-html-content button,
.search-html-content .btn {
    display:inline-block;
    padding:10px 20px;
    background:#FFD600;
    color:#000;
    border:none;
    border-radius:6px;
    cursor:pointer;
    font-family:'Poppins',sans-serif;
    font-size:14px;
    font-weight:500;
    transition:all 0.3s ease;
    text-decoration:none;
    margin:8px 0;
}

.search-html-content button:hover,
.search-html-content .btn:hover {
    background:#e6c200;
    transform:translateY(-2px);
    box-shadow:0 4px 12px rgba(0,0,0,0.3);
}

/* Cartes et conteneurs */
.search-html-content .card {
    background:rgba(255,255,255,0.05);
    border:1px solid rgba(255,255,255,0.1);
    border-radius:8px;
    padding:20px;
    margin:16px 0;
    box-shadow:0 2px 4px rgba(0,0,0,0.2);
    transition:all 0.3s ease;
    color:#e0e0e0;
}

.search-html-content .card:hover {
    box-shadow:0 4px 12px rgba(0,0,0,0.3);
    transform:translateY(-2px);
}

.search-html-content .alert {
    padding:12px 16px;
    border-radius:6px;
    margin:16px 0;
    text-align:left;
    color:#e0e0e0;
}

.search-html-content .alert-info {
    background:rgba(33,150,243,0.1);
    border:1px solid rgba(33,150,243,0.3);
    color:#90CAF9;
}

.search-html-content .alert-success {
    background:rgba(76,175,80,0.1);
    border:1px solid rgba(76,175,80,0.3);
    color:#A5D6A7;
}

.search-html-content .alert-warning {
    background:rgba(255,152,0,0.1);
    border:1px solid rgba(255,152,0,0.3);
    color:#FFCC80;
}

.search-html-content .alert-error {
    background:rgba(244,67,54,0.1);
    border:1px solid rgba(244,67,54,0.3);
    color:#EF9A9A;
}

/* ===================== MESSAGE D'ERREUR ===================== */
.search-error {
    text-align:center;
    padding:60px 20px;
    color:#e74c3c;
    animation:fadeInResults 0.3s ease;
}

.search-error svg {
    width:48px;
    height:48px;
    margin-bottom:16px;
    stroke:#e74c3c;
}

.search-error p {
    margin-bottom:16px;
    font-size:14px;
    color:#e0e0e0;
}

/* ===================== SIDEBAR SEARCH RESULTS (NOIR) ===================== */
.sidebar-search-results {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    animation: fadeInResults 0.3s ease;
    background:#000000;
}

.sidebar-search-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.sidebar-search-results .search-html-content {
    padding: 16px;
    background:#0a0a0a;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

.sidebar-search-results .search-loading {
    padding: 40px 20px;
    min-height: 200px;
}

.sidebar-search-results .search-error {
    padding: 40px 20px;
}

/* Ajustements pour le sidebar en mode recherche */
.sidebar.searching .sidebar-nav {
    display: none;
}

.sidebar.searching .sidebar-search-results {
    display: block;
}

/* ===================== MOBILE RESPONSIVE ===================== */
@media (max-width:680px){
    .search-modal{
        top:0;
        right:0;
        bottom:0;
        left:0;
        width:100vw;
        height:100vh;
        height:100dvh;
        transform:translateY(100%);
        border-radius:0;
        opacity:0;
        visibility:hidden;
        transition:opacity .3s var(--ease), transform .3s var(--ease), visibility .3s;
    }
    
    .search-modal.open{
        transform:translateY(0);
        opacity:1;
        visibility:visible;
    }
    
    .search-modal-header{
        padding:16px 20px;
    }
    
    .search-modal-body{
        padding:16px;
    }
    
    .search-html-content {
        padding:16px;
        font-size:14px;
    }
    
    .search-html-content h1 {
        font-size:24px;
    }
    
    .search-html-content h2 {
        font-size:20px;
    }
    
    .search-html-content h3 {
        font-size:18px;
    }
    
    .search-html-content h4 {
        font-size:16px;
    }
    
    .search-html-content h5 {
        font-size:14px;
    }
    
    .search-html-content h6 {
        font-size:13px;
    }
}

/* ===================== BOUTON SUPPRIMER TOUT L'HISTORIQUE ===================== */
/* Placé désormais dans .search-modal-header (barre de recherche),
   entre le champ de recherche et le bouton de fermeture.
   Même gabarit que .search-modal-close (40x40) pour un alignement propre. */
.clear-all-history {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(255, 82, 82, 0.1);
    border: 1px solid rgba(255, 82, 82, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.clear-all-history:hover {
    background: rgba(255, 82, 82, 0.2);
    border-color: rgba(255, 82, 82, 0.5);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.3);
}

.clear-all-history:active {
    transform: scale(0.95);
    box-shadow: none;
}

.clear-all-history svg {
    width: 18px;
    height: 18px;
    stroke: #ff5252;
    flex-shrink: 0;
}

/* Animation pour la suppression d'un item d'historique */
@keyframes fadeOutItem {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

.search-history-item.removing {
    animation: fadeOutItem 0.3s ease forwards;
}