:root {
    /* Leadnist theme (dark + yellow accent) */
    /* Sidebar: jaune */
    --sidebar-bg: #eab308; /* identique aux boutons jaunes (accent) */
    /* Conteneurs d'onglets (gris) */
    --sidebar-item-bg: #25252b; /* même gris que les cards à droite */
    --sidebar-item-border: rgba(255, 255, 255, .10);
    --sidebar-item-hover-bg: #2f2f36;
    --sidebar-item-text: #e5e7eb; /* gris clair (comme le contenu à droite) */
    --sidebar-item-text-hover: #fff;
    /* Onglet actif: gris (un peu différent) */
    --sidebar-active-bg: #34343b;
    --header-bg: #121318;
    --main-bg: #0f1115;
    --card-bg: #1a1c22;
    --accent: #eab308;
    --accent-hover: #ca9a06;
    --text: #f0f0f0;
    --text-muted: #c6c9d2;
    --border: #3f4450;
    --input-bg: rgba(255,255,255,.05);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 40px -15px rgba(0,0,0,.55);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--main-bg);
    min-height: 100vh;
}

/* Liens (évite le violet "visited") */
a:not(.btn) { color: var(--accent); text-decoration: none; }
a:not(.btn):visited { color: var(--accent); }
a:not(.btn):hover { color: var(--accent-hover); text-decoration: underline; }

.layout {
    display: flex;
    min-height: 100vh;
}

/* Hamburger: visible only on mobile */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1002;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--sidebar-bg);
    color: #111827;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: var(--shadow-lg);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-bar:nth-child(2) {
    opacity: 0;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}
.sidebar-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform .2s, opacity .2s;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
    opacity: 0;
    transition: opacity .2s;
}
.sidebar-overlay.is-open {
    opacity: 1;
}
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    padding: 0 0 1rem;
    flex-shrink: 0;
}
.sidebar-nav-label {
    display: block;
    padding: 12px 14px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(17, 24, 39, .65);
}

.sidebar-brand {
    padding: 0 0.75rem 0;
    border-bottom: none;
    margin-bottom: -0.8rem;
}

.sidebar-brand-link {
    display: block;
    width: 100%;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand-logo {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    vertical-align: middle;
    transform: translateY(-18px);
    clip-path: inset(0 0 10% 0);
}

.sidebar-brand-text {
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.sidebar-brand a {
    color: #111;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}
.sidebar-brand a:visited { color: #111; }
.sidebar-brand a:hover { color: #111; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 .75rem;
    margin-top: -1rem;
    overflow-y: auto;
    max-height: calc(100vh - 5rem);
}

.sidebar-group {
    margin: 4px 0;
}
.sidebar-group summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: var(--sidebar-item-text);
    border-radius: var(--radius-sm);
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    transition: background .2s, color .2s;
    background: var(--sidebar-item-bg);
    border: 1px solid var(--sidebar-item-border);
}
.sidebar-group summary::-webkit-details-marker { display: none; }
.sidebar-group summary:hover { background: var(--sidebar-item-hover-bg); color: var(--sidebar-item-text-hover); }
.sidebar-group[open] summary { background: var(--sidebar-active-bg); }
.sidebar-subnav { display: flex; flex-direction: column; gap: 10px; padding: 10px 0 6px; }
.sidebar-subnav a {
    /* Sous-onglets : plus légers, sans “carte” grise pour la lisibilité */
    background: transparent;
    border: none;
    padding: 8px 12px 8px 28px;
    font-size: 15px;
    font-weight: 800;
    opacity: 0.92;
}
.sidebar-subnav a:hover {
    background: rgba(0,0,0,.18);
    opacity: 1;
}
.sidebar-subnav a.active {
    background: rgba(0,0,0,.28);
    border: none;
    box-shadow: inset 4px 0 0 var(--accent);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: var(--sidebar-item-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 800;
    transition: background .2s, color .2s;
    background: var(--sidebar-item-bg);
    border: 1px solid var(--sidebar-item-border);
}
.sidebar-nav a:visited { color: var(--sidebar-item-text); }

.sidebar-nav a:hover {
    background: var(--sidebar-item-hover-bg);
    color: var(--sidebar-item-text-hover);
}

.sidebar-nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-item-text-hover);
    border-color: rgba(234, 179, 8, .55);
    box-shadow: inset 4px 0 0 var(--accent);
}

/* IMPORTANT: les sous-onglets ne doivent pas hériter des "cartes" */
.sidebar-nav .sidebar-subnav a,
.sidebar-nav .sidebar-subnav a:visited {
    background: transparent;
    border: none;
    box-shadow: none;
    color: #111827;
    font-weight: 800;
    font-size: 15px;
}
.sidebar-nav .sidebar-subnav a:hover {
    background: rgba(0,0,0,.14);
    color: #111827;
}
.sidebar-nav .sidebar-subnav a.active {
    background: rgba(0,0,0,.22);
    border: none;
    box-shadow: inset 4px 0 0 var(--accent);
    color: #111827;
}

.nav-icon { display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { display: block; }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    padding-left: 0;
}
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-user-email {
    font-size: 0.9rem;
    color: var(--text-muted, #888);
    font-weight: 400;
}

.header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1.25rem;
    transition: background .2s, color .2s;
}

.header-icon:hover {
    background: var(--border);
    color: var(--text);
}

.content {
    padding: 1.5rem;
    flex: 1;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card:last-child {
    margin-bottom: 0;
}

.card-title {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .05s;
}

.btn-primary {
    background: var(--accent);
    color: #111;
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(255,255,255,.08);
    color: var(--text);
}

.btn-secondary:hover {
    background: rgba(255,255,255,.12);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 14px 16px;
    background: var(--main-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.post-list li:last-child {
    margin-bottom: 0;
}

.post-list .post-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--border);
    color: var(--text-muted);
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--main-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.form-row {
    margin-bottom: 1.25rem;
}

.form-row label {
    display: block;
    margin-bottom: 6px;
    font-weight: 800;
    color: var(--text);
}

.form-row input,
.form-row textarea,
.form-row select {
    width: 100%;
    max-width: 480px;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text);
    transition: border-color .2s;
}

.form-row input:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234,179,8,.18);
}

/* Segmented controls (Nouveau post) */
.pool-selector,
.media-type-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.pool-option {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    cursor: pointer;
    user-select: none;
    min-width: 160px;
    justify-content: space-between;
    font-weight: 800;
}
.pool-option input { accent-color: var(--accent); }
.pool-option:hover { background: rgba(255,255,255,.06); }
.pool-option:has(input:checked) {
    border-color: rgba(234,179,8,.65);
    box-shadow: 0 0 0 3px rgba(234,179,8,.12);
}

.thumb-item {
    border: 2px solid rgba(255,255,255,.10);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255,255,255,.02);
}
.thumb-item.selected {
    border-color: rgba(234,179,8,.85);
    box-shadow: 0 0 0 3px rgba(234,179,8,.14);
}

.form-row textarea {
    min-height: 120px;
    resize: vertical;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1.5rem;
}

.flash-messages {
    margin-bottom: 1rem;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* En mode dark, les alertes restent lisibles */
.alert-success { background: rgba(34,197,94,.15); color: #86efac; border-color: rgba(34,197,94,.35); }
.alert-warning { background: rgba(234,179,8,.15); color: #fde68a; border-color: rgba(234,179,8,.35); }
.alert-info { background: rgba(59,130,246,.15); color: #bfdbfe; border-color: rgba(59,130,246,.35); }

.text-muted { color: var(--text-muted); }

/* Profil Meta */
.meta-help { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.meta-form { margin-top: 1rem; }
.meta-form-grid { display: flex; flex-direction: column; gap: 0.75rem; max-width: 560px; }
.meta-label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.meta-input, .meta-textarea {
    width: 100%;
    max-width: 560px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.02);
    color: var(--text);
}
.meta-input { max-width: 320px; }
.meta-textarea { resize: vertical; }
.meta-input:focus, .meta-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234,179,8,.18);
}
.meta-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.meta-status-box {
    margin-top: 1.25rem;
    padding: 1rem;
    background: rgba(255,255,255,.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
}
.meta-status-list { margin: 0.5rem 0 0 1rem; color: var(--text-muted); }
.meta-status-list code {
    background: rgba(0,0,0,.25);
    border: 1px solid rgba(255,255,255,.08);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--text);
}

/* Couverture accueil */
.cover-preview { margin: 0.75rem 0 1rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cover-preview img { width: 100%; height: auto; display: block; }
.cover-upload-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cover-upload-form input[type="file"] {
    max-width: 420px;
    color: var(--text-muted);
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    background: var(--main-bg);
    transition: border-color .2s, background .2s;
}
.drop-zone.dragover { border-color: var(--accent); background: rgba(99,102,241,.05); }
.drop-zone-label { cursor: pointer; display: block; color: var(--text-muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.media-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.media-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.media-card-actions { padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.media-card-form { display: inline-flex; align-items: center; gap: 0.35rem; }
.media-card-form select { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border, #ccc); }

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    background: var(--main-bg);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
}

/* Hexa AI */
.card-alpha-ai { max-width: 980px; }
.alpha-ai-messages {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.03);
    padding: 14px;
    height: 55vh;
    overflow: auto;
}
.alpha-ai-msg { margin-bottom: 10px; }
.alpha-ai-msg:last-child { margin-bottom: 0; }
.alpha-ai-msg-content {
    display: inline-block;
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.04);
    color: var(--text);
    word-wrap: break-word;
}
.alpha-ai-msg-user .alpha-ai-msg-content {
    background: rgba(234,179,8,.12);
    border-color: rgba(234,179,8,.35);
}
.alpha-ai-input-wrap { margin-top: 12px; }
.alpha-ai-form textarea {
    width: 100%;
    max-width: 100%;
    min-height: 140px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255,255,255,.02);
    color: var(--text);
    resize: vertical;
}
.alpha-ai-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

/* Mobile: drawer sidebar */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,.15);
    }
    .sidebar.is-open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }
    .sidebar-overlay.is-open {
        pointer-events: auto;
    }
    .main {
        padding-left: 0;
    }
    .header h1 {
        padding-left: 56px;
        font-size: 1.15rem;
    }
    .content {
        padding: 1rem;
    }
}
