/* =========================================================
   Modern UX & Global Design Enhancements
   ========================================================= */

/* Typographie plus premium */
body, input, select, textarea {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    color: #333;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    color: #2c3e50;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Boutons globalement adoucis et modernisés */
.button, button, input[type="submit"], input[type="button"], .button.special {
    border-radius: 8px !important;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.3s ease-in-out !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.button:hover, button:hover, input[type="submit"]:hover, input[type="button"]:hover, .button.special:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

/* Header & Navigation */
#header {
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    padding: 1.5em 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

#header .logo strong {
    color: #e74c3c;
}

/* Barre de recherche globale (Header) */
.global-search-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    margin: 10px 20px;
    min-width: 250px;
}

.global-search-form {
    width: 100%;
    max-width: 500px;
    display: flex;
    position: relative;
}

.global-search-form input[type="text"] {
    width: 100%;
    border-radius: 20px !important;
    border: 1px solid #e0e0e0 !important;
    padding: 0 45px 0 20px !important;
    height: 44px !important;
    font-size: 0.95em !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02) !important;
    background: #fdfdfd;
    transition: all 0.3s ease !important;
}

.global-search-form input[type="text"]:focus {
    background: #fff;
    border-color: #e74c3c !important;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.1) !important;
    outline: none;
}

.global-search-form button {
    position: absolute;
    right: 5px;
    top: 5px;
    height: 34px !important;
    width: 34px !important;
    border-radius: 50% !important;
    border: none;
    background: #e74c3c !important;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    box-shadow: none !important;
}

.global-search-form button:hover {
    background: #c0392b !important;
    transform: scale(1.05);
}

/* Sidebar modernisée */
#sidebar {
    background-color: #fcfcfc;
    border-right: 1px solid #f0f0f0;
}

#sidebar .inner {
    padding-top: 2em;
}

/* Adoucissement des images */
.image img {
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Responsive adjustments for header */
@media screen and (max-width: 736px) {
    #header {
        flex-direction: column;
        text-align: center;
    }
    .global-search-container {
        margin: 15px 0;
        width: 100%;
    }
}

/* =========================================================
   Dark Mode (Automatique)
   ========================================================= */
@media (prefers-color-scheme: dark) {
    body, #wrapper, #main, #sidebar {
        background-color: #121212 !important;
        color: #e0e0e0 !important;
    }
    h1, h2, h3, h4, h5, h6 {
        color: #ffffff !important;
    }
    #header {
        background-color: #1e1e1e !important;
        border-bottom-color: #333 !important;
    }
    #sidebar {
        background-color: #181818 !important;
        border-right-color: #333 !important;
    }
    .button, button, input[type="submit"] {
        background-color: #2c3e50 !important;
        color: #fff !important;
    }
    .button.special {
        background-color: #e74c3c !important;
    }
    .hub-card {
        background-color: #1e1e1e !important;
        border-color: #333 !important;
    }
    .hub-card:hover {
        background-color: #2a2a2a !important;
    }
    input[type="text"], select, textarea {
        background-color: #2a2a2a !important;
        color: #fff !important;
        border-color: #444 !important;
    }
}

/* =========================================================
   Back to top Button
   ========================================================= */
#back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #e74c3c;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
}
#back-to-top.show {
    opacity: 1;
    visibility: visible;
}
#back-to-top:hover {
    background-color: #c0392b;
    transform: translateY(-3px);
}
#back-to-top svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* =========================================================
   AdSense Anti-CLS & Premium Styling
   ========================================================= */
.ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 2em auto;
    min-height: 280px; /* Réserve la place pour éviter les sauts (CLS) */
    background-color: rgba(0,0,0,0.02);
    border-radius: 8px;
    border: 1px dashed rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
    padding-top: 5px;
    text-align: center;
}
.ad-container::before {
    content: "— Publicité —";
    display: block;
    font-size: 0.70em;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
@media (prefers-color-scheme: dark) {
    .ad-container {
        background-color: rgba(255,255,255,0.02);
        border-color: rgba(255,255,255,0.08);
    }
    .ad-container::before {
        color: #555;
    }
}

/* =========================================================
   Table of Contents (Sommaire Automatique)
   ========================================================= */
html {
    scroll-behavior: smooth;
}
.udf-toc {
    background: #fdfdfd;
    border: 1px solid #eaeaea;
    border-left: 4px solid #e74c3c;
    border-radius: 8px;
    padding: 20px;
    margin: 2em 0 2.5em 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    display: inline-block;
    min-width: 50%;
    max-width: 100%;
}
.udf-toc .toc-title {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 15px;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.udf-toc .toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.udf-toc .toc-list li {
    margin-bottom: 8px;
    line-height: 1.5;
}
.udf-toc .toc-list li a {
    color: #444;
    text-decoration: none;
    transition: color 0.2s;
    border-bottom: none;
}
.udf-toc .toc-list li a:hover {
    color: #e74c3c;
}
.udf-toc .toc-h2 {
    font-weight: 600;
    padding-left: 0;
}
.udf-toc .toc-h3 {
    font-size: 0.95em;
    padding-left: 20px;
    position: relative;
}
.udf-toc .toc-h3::before {
    content: "—";
    position: absolute;
    left: 2px;
    color: #ccc;
}
@media (prefers-color-scheme: dark) {
    .udf-toc {
        background: #1a1a1a;
        border-color: #333;
    }
    .udf-toc .toc-title {
        color: #fff;
    }
    .udf-toc .toc-list li a {
        color: #ddd;
    }
    .udf-toc .toc-list li a:hover {
        color: #e74c3c;
    }
}
