/* ── Reset & base ─────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, 'Linux Libertine', Georgia, Times, serif;
    font-size: 14px;
    line-height: 1.6;
    color: #202122;
    background: #fff;
}

a { color: #3366cc; text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: #795cb2; }

/* ── Sidebar ──────────────────────────────────────────── */
#mw-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 200px;
    height: 100vh;
    background: #f6f6f6;
    border-right: 1px solid #a2a9b1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: #a2a9b1 transparent;
}

#mw-sidebar::-webkit-scrollbar { width: 4px; }
#mw-sidebar::-webkit-scrollbar-thumb { background: #c8ccd1; border-radius: 2px; }

/* Logo block */
#sidebar-logo {
    padding: 16px 12px 14px;
    text-align: center;
    flex-shrink: 0;
    border-bottom: 1px solid #a2a9b1;
}
#sidebar-logo a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}
#logo-globe {
    width: 50px; height: 50px;
}
#sidebar-logo a:hover #logo-globe circle,
#sidebar-logo a:hover #logo-globe ellipse,
#sidebar-logo a:hover #logo-globe line,
#sidebar-logo a:hover #logo-globe path {
    stroke: #3366cc;
}
#logo-title {
    font-family: 'Linux Libertine', Georgia, serif;
    font-size: 15px;
    font-weight: normal;
    color: #202122;
}
#logo-subtitle {
    font-size: 11px;
    color: #54595d;
    font-style: italic;
}

/* Divider */
.sidebar-divider {
    height: 1px;
    background: #a2a9b1;
    margin: 0;
    flex-shrink: 0;
}

/* Search */
.sidebar-search {
    padding: 10px 10px;
    flex-shrink: 0;
}
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 8px;
    width: 13px; height: 13px;
    color: #54595d;
    pointer-events: none;
    flex-shrink: 0;
}
#searchInput {
    width: 100%;
    padding: 5px 8px 5px 28px;
    background: #fff;
    border: 1px solid #a2a9b1;
    border-radius: 2px;
    color: #202122;
    font-size: 12px;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
#searchInput::placeholder { color: #72777d; }
#searchInput:focus {
    outline: none;
    border-color: #3366cc;
    box-shadow: 0 0 0 1px #3366cc;
}

/* Autocomplete */
#search-suggestions {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #a2a9b1;
    border-radius: 2px;
    z-index: 300;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
    overflow: hidden;
}
#search-suggestions a {
    display: block;
    padding: 6px 10px;
    font-size: 12px;
    color: #202122;
    border-bottom: 1px solid #eaecf0;
}
#search-suggestions a:last-child { border-bottom: none; }
#search-suggestions a:hover {
    background: #eaf3fb;
    color: #3366cc;
    text-decoration: none;
}

/* Nav sections */
.sidebar-nav {
    padding: 8px 0 4px;
    flex-shrink: 0;
}
.nav-section-title {
    font-size: 11px;
    font-weight: bold;
    color: #54595d;
    padding: 4px 12px 4px;
    border-bottom: 1px solid #a2a9b1;
    margin-bottom: 2px;
}
.sidebar-nav ul { list-style: none; }
.nav-link {
    display: block;
    padding: 4px 12px;
    color: #3366cc;
    font-size: 13px;
    transition: color .1s;
    text-decoration: none;
}
.nav-link:hover {
    text-decoration: underline;
    color: #3366cc;
    background: none;
}
.nav-link:visited { color: #795cb2; }
.nav-link:visited:hover { color: #795cb2; text-decoration: underline; }
.nav-link.active {
    color: #3366cc;
    font-weight: bold;
}

/* ── Main content area ────────────────────────────────── */
#content.mw-body {
    margin-left: 200px;
    padding: 28px 36px;
    background: #fff;
    min-height: 100vh;
}

/* ── Article typography ───────────────────────────────── */
.page-title {
    font-family: 'Linux Libertine', Georgia, serif;
    font-size: 28px;
    font-weight: normal;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 4px;
    margin-bottom: 16px;
    color: #000;
}

.article-layout { display: flex; gap: 24px; align-items: flex-start; }
.article-main { flex: 1; min-width: 0; }
.article-sidebar { width: 240px; flex-shrink: 0; }

.sidebar-sticky {
    position: sticky;
    top: 20px;
    /* Pas de scroll interne : le Sommaire et les "Articles liés" sont visibles d'un coup */
}

.infobox {
    background: #f8f9fa;
    border: 1px solid #a2a9b1;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    border-radius: 2px;
}
.infobox h3 {
    font-size: 13px;
    font-weight: bold;
    background: #cee0f2;
    margin: -10px -14px 10px;
    padding: 6px 14px;
    border-bottom: 1px solid #a2a9b1;
}
.infobox ul { list-style: none; }
.infobox li { padding: 4px 0; border-bottom: 1px solid #eaecf0; }
.infobox li:last-child { border-bottom: none; }
.infobox .visit-count { font-weight: bold; color: #3366cc; }

/* TOC dans le sidebar */
.toc-infobox .toc-list { list-style: decimal; padding-left: 18px; margin: 0; }
.toc-infobox .toc-list li { padding: 2px 0; font-size: 12px; }
.toc-infobox .toc-list li.toc-sub { list-style: none; padding-left: 10px; }
.toc-infobox .toc-list li.toc-sub::before { content: "– "; color: #a2a9b1; }
.toc-infobox .toc-list a { color: #3366cc; font-size: 12px; }

/* Notes et références */
.article-notes {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #a2a9b1;
}
.article-notes h2 {
    font-family: 'Linux Libertine', Georgia, serif;
    font-size: 20px;
    font-weight: normal;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 4px;
    margin-bottom: 12px;
}
.notes-content { font-size: 13px; color: #3a3a3a; }
.notes-content ol, .notes-content ul { padding-left: 24px; }
.notes-content li { margin-bottom: 4px; line-height: 1.5; }

.article-content h2 {
    font-family: 'Linux Libertine', Georgia, serif;
    font-size: 22px;
    font-weight: normal;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 4px;
    margin: 24px 0 10px;
}
.article-content h3 { font-size: 17px; font-weight: bold; margin: 16px 0 8px; }
.article-content p { margin-bottom: 12px; }
.article-content ul, .article-content ol { margin: 0 0 12px 24px; }
.article-content li { margin-bottom: 4px; }
.article-content img {
    max-width: 100%;
    height: auto;
    border: 1px solid #a2a9b1;
    padding: 2px;
}
.article-content blockquote {
    border-left: 3px solid #a2a9b1;
    margin: 12px 0 12px 24px;
    padding: 4px 12px;
    color: #54595d;
    font-style: italic;
}
.article-content table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.article-content th, .article-content td { border: 1px solid #a2a9b1; padding: 6px 10px; }
.article-content th { background: #eaecf0; font-weight: bold; }

.article-summary {
    background: #eaf3fb;
    border-left: 4px solid #3366cc;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-style: italic;
    color: #3a3a3a;
    font-size: 14px;
}

/* ── Homepage ─────────────────────────────────────────── */
.homepage-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 16px; }
.featured-article { border: 1px solid #a2a9b1; padding: 14px; background: #f8f9fa; border-radius: 2px; }
.featured-article h3 { font-size: 16px; margin-bottom: 8px; border-bottom: 1px solid #a2a9b1; padding-bottom: 6px; }
.recent-articles { font-size: 13px; }
.recent-articles h3 { font-size: 15px; margin-bottom: 10px; border-bottom: 1px solid #a2a9b1; padding-bottom: 6px; }
.recent-articles ul { list-style: none; }
.recent-articles li { padding: 5px 0; border-bottom: 1px solid #eaecf0; }
.recent-articles li:last-child { border-bottom: none; }
.recent-articles .date { color: #54595d; font-size: 11px; }

/* ── Search ───────────────────────────────────────────── */
.search-result { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #eaecf0; }
.search-result h3 { font-size: 18px; margin-bottom: 4px; }
.search-result .snippet { font-size: 13px; color: #54595d; }
.search-result .url { font-size: 12px; color: #3366cc; }
.search-no-results { color: #54595d; font-style: italic; }

/* ── Footer ───────────────────────────────────────────── */
#mw-footer {
    margin-left: 200px;
    background: #f8f9fa;
    border-top: 1px solid #a2a9b1;
    padding: 10px 36px;
    font-size: 12px;
    color: #54595d;
    display: flex;
    gap: 20px;
    align-items: center;
}
#footer-info, #footer-places { list-style: none; display: flex; gap: 16px; }

/* ── Admin ────────────────────────────────────────────── */
.admin-container { max-width: 1100px; margin: 30px auto; padding: 0 24px; }
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #3366cc;
}
.admin-header h1 { font-size: 22px; color: #3366cc; }
.admin-card { background: #fff; border: 1px solid #a2a9b1; border-radius: 4px; padding: 20px; margin-bottom: 20px; }
.admin-card h2 { font-size: 16px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid #eaecf0; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { background: #eaecf0; padding: 8px 12px; text-align: left; font-weight: bold; border: 1px solid #a2a9b1; }
.admin-table td { padding: 7px 12px; border: 1px solid #eaecf0; vertical-align: middle; }
.admin-table tr:hover { background: #f8f9fa; }
.badge-published { display: inline-block; padding: 2px 8px; background: #14866d; color: #fff; border-radius: 10px; font-size: 11px; }
.badge-draft { display: inline-block; padding: 2px 8px; background: #a2a9b1; color: #fff; border-radius: 10px; font-size: 11px; }

/* Buttons */
.btn { display: inline-block; padding: 6px 14px; border-radius: 4px; font-size: 13px; cursor: pointer; text-decoration: none; border: 1px solid transparent; transition: background .12s, border-color .12s; font-family: inherit; }
.btn-primary { background: #3366cc; color: #fff; border-color: #2a4b8d; }
.btn-primary:hover { background: #2a4b8d; text-decoration: none; color: #fff; }
.btn-secondary { background: #f8f9fa; color: #202122; border-color: #a2a9b1; }
.btn-secondary:hover { background: #e8eaed; text-decoration: none; color: #202122; }
.btn-danger { background: #cc3333; color: #fff; border-color: #a32424; }
.btn-danger:hover { background: #a32424; text-decoration: none; color: #fff; }
.btn-success { background: #14866d; color: #fff; border-color: #0d6655; }
.btn-success:hover { background: #0d6655; text-decoration: none; color: #fff; }
.btn-sm { padding: 3px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: bold; margin-bottom: 4px; color: #3a3a3a; }
.form-control { width: 100%; padding: 7px 10px; border: 1px solid #a2a9b1; border-radius: 4px; font-size: 14px; font-family: inherit; transition: border-color .12s, box-shadow .12s; }
.form-control:focus { outline: none; border-color: #3366cc; box-shadow: 0 0 0 2px rgba(51,102,204,.15); }
textarea.form-control { resize: vertical; font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: auto; }

/* Alert */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #d5fdf4; border: 1px solid #14866d; color: #0d4d3e; }
.alert-error { background: #fee7e6; border: 1px solid #cc3333; color: #6e2b2b; }

/* Login */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f0f2f5; }
.login-box { background: #fff; border: 1px solid #a2a9b1; border-radius: 8px; padding: 36px; width: 380px; box-shadow: 0 4px 20px rgba(0,0,0,.1); }
.login-box h1 { font-size: 22px; text-align: center; margin-bottom: 24px; color: #3366cc; }

/* ── Image modal ──────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 8px;
    width: 700px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,.25);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eaecf0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: #54595d; line-height: 1; padding: 0 4px;
}
.modal-close:hover { color: #cc3333; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* Upload zone */
.upload-zone {
    border: 2px dashed #a2a9b1;
    border-radius: 6px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: #3366cc;
    background: #f0f5ff;
}
.upload-zone p { color: #54595d; font-size: 13px; margin-top: 8px; }
.upload-zone .upload-icon { font-size: 32px; opacity: .5; }

/* Image gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}
.image-thumb {
    border: 2px solid #eaecf0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .12s, transform .12s;
    background: #f8f9fa;
}
.image-thumb:hover { border-color: #3366cc; transform: scale(1.03); }
.image-thumb img { width: 100%; height: 90px; object-fit: cover; display: block; }
.image-thumb .img-name {
    font-size: 10px;
    padding: 3px 5px;
    color: #54595d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #f8f9fa;
}
.image-thumb .img-actions {
    display: flex;
    gap: 4px;
    padding: 4px 5px;
    border-top: 1px solid #eaecf0;
}
.image-thumb .img-actions button {
    flex: 1;
    border: none;
    border-radius: 2px;
    padding: 3px;
    font-size: 10px;
    cursor: pointer;
}
.btn-insert { background: #3366cc; color: #fff; }
.btn-insert:hover { background: #2a4b8d; }
.btn-delete-img { background: #f8f9fa; color: #cc3333; border: 1px solid #eaecf0 !important; }
.btn-delete-img:hover { background: #fee7e6; }

/* ── Mobile top bar ───────────────────────────────────── */
#mw-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: #f6f6f6;
    border-bottom: 1px solid #a2a9b1;
    z-index: 150;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
}
#topbar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #202122;
}
#topbar-logo span {
    font-family: 'Linux Libertine', Georgia, serif;
    font-size: 15px;
}
#topbar-logo:hover { text-decoration: none; }

#sidebar-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}
#sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #54595d;
    border-radius: 2px;
    transition: transform .28s ease, opacity .28s ease;
}
#sidebar-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#sidebar-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#sidebar-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 149;
}
#sidebar-overlay.open { display: block; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    #mw-topbar { display: flex; }

    /* Sidebar : drawer glissant depuis la gauche */
    #mw-sidebar {
        position: fixed;
        top: 0; left: -220px;
        width: 220px;
        height: 100vh;
        flex-direction: column;
        transition: left .28s ease;
        z-index: 200;
        overflow-y: auto;
    }
    #mw-sidebar.open { left: 0; }

    #content.mw-body {
        margin-left: 0;
        padding: 16px;
        padding-top: 68px;
    }
    #mw-footer {
        margin-left: 0;
        flex-direction: column;
        gap: 8px;
        padding: 10px 16px;
    }
    #footer-info, #footer-places { flex-wrap: wrap; gap: 8px; }

    .homepage-grid { grid-template-columns: 1fr; }
    .article-layout { flex-direction: column; }
    .article-sidebar { width: 100%; }

    .sidebar-sticky {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .page-title { font-size: 22px; }
    .article-content h2 { font-size: 18px; }
    .article-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
