﻿:root {
    --accent: #8b5cf6;
    --accent-soft: rgba(139, 92, 246, 0.18);
    --bg: #070d19;
    --panel: #111827;
    --panel-2: #172033;
    --line: rgba(229, 231, 235, 0.12);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --danger: #ef4444;
    --warning: #f59e0b;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Verdana, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 16px auto 16px 16px;
    width: 270px;
    height: calc(100vh - 32px);
    padding: 18px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #8b5cf6 #0f172a;
    background: linear-gradient(180deg, rgba(13, 20, 34, 0.98), rgba(8, 14, 26, 0.98));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 999px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #8b5cf6, #ff4500);
    border: 2px solid #0f172a;
    border-radius: 999px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #a855f7, #ff6a2a);
}
.sidebar-logo { padding: 8px 12px 18px; border-bottom: 1px solid rgba(148, 163, 184, 0.12); }
.sidebar-logo img { display: block; width: 178px; max-width: 100%; height: auto; object-fit: contain; }
.sidebar-logo small { display: block; margin-top: 8px; color: #e5e7eb; font-size: 11px; font-weight: 800; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-weight: 800;
}
.brand strong { display: block; }
.brand small, .muted, .eyebrow { color: var(--muted); }
.sidebar-nav {
    display: grid;
    gap: 9px;
    margin-top: 18px;
}
.sidebar-link,
.sidebar-accordion-toggle,
.sidebar-sublink {
    width: 100%;
    border: 0;
    color: #dbe4f4;
    background: transparent;
    text-decoration: none;
    font-weight: 800;
    transition: background .22s ease, color .22s ease, box-shadow .22s ease, transform .22s ease;
}
.sidebar-link,
.sidebar-accordion-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 13px;
    border-radius: 13px;
    cursor: pointer;
}
.sidebar-link {
    justify-content: flex-start;
}
.sidebar-left {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}
.sidebar-icon,
.sidebar-sublink span {
    display: inline-grid;
    place-items: center;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    color: #d18eff;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
}
.sidebar-chevron {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: #94a3b8;
    transition: transform .24s ease, color .2s ease;
}
.sidebar-accordion {
    border-bottom: 1px solid rgba(148, 163, 184, 0.09);
    padding-bottom: 6px;
}
.sidebar-accordion.open .sidebar-chevron {
    color: #fff;
    transform: rotate(180deg);
}
.sidebar-submenu {
    display: grid;
    gap: 5px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-left: 9px;
    transition: max-height .3s ease, opacity .2s ease, margin .2s ease;
}
.sidebar-accordion.open .sidebar-submenu {
    max-height: 740px;
    margin-top: 5px;
    opacity: 1;
}
.sidebar-accordion.open .ai-sidebar-submenu {
    max-height: 980px;
}
.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 9px 11px 9px 17px;
    border-radius: 11px;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.25;
}
.sidebar-link:hover,
.sidebar-accordion-toggle:hover,
.sidebar-sublink:hover {
    color: #fff;
    background: rgba(139, 92, 246, .16);
}
.sidebar-link.active,
.sidebar-sublink.active {
    color: #fff;
    background: linear-gradient(135deg, #6d28d9, #8b5cf6);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 24px rgba(139, 92, 246, .24);
}
.sidebar-sublink.sidebar-disabled {
    cursor: default;
    opacity: .62;
}
.sidebar-sublink.sidebar-disabled:hover {
    color: #cbd5e1;
    background: transparent;
    box-shadow: none;
}
.location-nav-group .sidebar-accordion-toggle,
.location-nav-group .sidebar-sublink span {
    color: #ff8a3d;
}
.ai-nav-group .sidebar-accordion-toggle,
.ai-nav-group .sidebar-sublink span {
    color: #ff8a3d;
}
.ai-nav-group .sidebar-sublink.active,
.admin-crones-link.active {
    background: linear-gradient(100deg, rgba(255, 69, 0, .92), rgba(139, 92, 246, .86));
    box-shadow: 0 12px 28px rgba(255, 69, 0, .22);
}
.admin-nav-group .sidebar-accordion-toggle,
.admin-nav-group .sidebar-sublink span {
    color: #aab9d4;
}
.nav-list { display: grid; gap: 18px; margin-top: 22px; }
.nav-group { display: grid; gap: 7px; padding-bottom: 16px; border-bottom: 1px solid rgba(148, 163, 184, 0.11); }
.nav-group:last-child { border-bottom: 0; }
.nav-group-title {
    border: 0;
    padding: 0 8px 6px;
    color: #9aa7bd;
    background: transparent;
    text-align: left;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 900;
}
.location-nav-title {
    color: #fb6a28;
}
.ai-nav-title {
    color: #ff8a3d;
}
.admin-nav-title {
    color: #aab9d4;
}
.nav-link {
    padding: 12px 14px;
    border-radius: 11px;
    color: #dbe4f4;
    font-size: 14px;
    font-weight: 800;
    transition: background .2s ease, color .2s ease;
}
.nav-link-icon {
    display: flex;
    align-items: center;
    gap: 13px;
}
.nav-link-icon span {
    display: inline-grid;
    place-items: center;
    flex: 0 0 18px;
    color: #d18eff;
    font-size: 17px;
    line-height: 1;
}
.location-nav-group .nav-link:nth-of-type(1) span { color: #efb091; }
.location-nav-group .nav-link:nth-of-type(3) span { color: #69a3df; }
.location-nav-group .nav-link:nth-of-type(4) span { color: #d69573; }
.location-nav-group .nav-link:nth-of-type(5) span { color: #4ac7f7; }
.location-nav-group .nav-link:nth-of-type(6) span { color: #e6a546; }
.ai-nav-group .nav-link-icon span {
    color: #ff8a3d;
    font-size: 13px;
    font-weight: 900;
}
.ai-nav-group .nav-link.active {
    background: linear-gradient(100deg, rgba(255, 69, 0, .92), rgba(139, 92, 246, .86));
    box-shadow: 0 12px 28px rgba(255, 69, 0, .22);
}
.admin-nav-group .nav-link-icon span {
    color: #90a5cc;
    font-size: 13px;
    font-weight: 800;
}
.admin-nav-group .admin-crones-link span {
    color: #ff813b;
    font-size: 18px;
}
.admin-nav-disabled {
    cursor: default;
    opacity: .78;
}
.admin-nav-disabled:hover {
    background: transparent;
    box-shadow: none;
    color: #dbe4f4;
}
.admin-crones-link.active {
    background: linear-gradient(100deg, #ec5115, #ff7523);
    box-shadow: 0 12px 28px rgba(244, 85, 22, .32);
}
.nav-link:hover, .nav-link.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.54), rgba(109, 40, 217, 0.7));
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 12px 30px rgba(88, 28, 135, .22);
}
.main-area {
    margin-left: 286px;
    width: calc(100% - 286px);
    max-width: calc(100vw - 286px);
    min-width: 0;
    overflow-x: hidden;
    padding: 32px 28px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; }
.eyebrow { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.user-chip { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.user-chip span, .user-chip small { display: block; }
.icon-button, .button {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    padding: 10px 14px;
    cursor: pointer;
    transition: transform .2s ease, filter .2s ease;
}
.icon-button { padding: 8px 10px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button-secondary { background: var(--panel-2); border: 1px solid var(--line); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card, .panel, .auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(0,0,0,.18);
}
.stat-card { padding: 18px; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 12px; font-size: 32px; }
.stat-card.warning strong { color: var(--warning); }
.stat-card.danger strong { color: var(--danger); }
.panel { padding: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.empty-state { border: 1px dashed var(--line); border-radius: 8px; padding: 28px; background: rgba(255,255,255,.02); }
.auth-page { display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(430px, 100%); padding: 28px; }
.auth-brand { margin-bottom: 28px; }
.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: var(--muted); }
input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    color: var(--text);
    background: #0b1220;
    outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.alert { border-radius: 8px; background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .35); padding: 12px; margin: 18px 0; }

@media (max-width: 900px) {
    .sidebar { position: static; width: calc(100% - 24px); height: auto; max-height: none; margin: 12px; }
    .app-shell { display: block; }
    .main-area { margin-left: 0; width: 100%; max-width: 100%; padding: 18px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar, .panel-header { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .user-chip { width: 100%; justify-content: space-between; }
}

/* Clean accordion sidebar repair: scoped to the app sidebar to avoid page-level collisions. */
.app-shell > .sidebar {
    width: 270px;
    height: calc(100vh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #8b5cf6 #0b1220;
}

.app-shell > .sidebar::-webkit-scrollbar { width: 8px; }
.app-shell > .sidebar::-webkit-scrollbar-track {
    background: #0b1220;
    border-radius: 999px;
}
.app-shell > .sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #8b5cf6, #ff4500);
    border: 2px solid #0b1220;
    border-radius: 999px;
}
.app-shell > .sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #a855f7, #ff6a2a);
}

.office-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 18px;
}

.office-sidebar-link,
.office-sidebar-toggle,
.office-sidebar-sublink {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: #cbd5e1;
    text-decoration: none;
    box-sizing: border-box;
    font-family: Verdana, "Arial Rounded MT Bold", Arial, sans-serif;
    transition: background .2s ease, color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.office-sidebar-link,
.office-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 11px 12px;
    border-radius: 13px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 900;
    text-align: left;
}

.office-sidebar-link {
    justify-content: flex-start;
}

.office-sidebar-left {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.office-sidebar-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border-radius: 9px;
    color: #f6edff;
    background: linear-gradient(135deg, rgba(139, 92, 246, .95), rgba(76, 29, 149, .9));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 8px 18px rgba(139, 92, 246, .18);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
}

.office-sidebar-icon-orange {
    background: linear-gradient(135deg, rgba(255, 69, 0, .95), rgba(139, 92, 246, .88));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 8px 18px rgba(255, 69, 0, .18);
}

.office-sidebar-text,
.office-sidebar-title,
.office-sidebar-sublink span:last-child {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.25;
}

.office-sidebar-chevron {
    display: inline-grid;
    place-items: center;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    transition: transform .25s ease, color .2s ease;
}

.office-sidebar-section {
    display: block;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(148, 163, 184, .09);
}

.office-sidebar-section.open .office-sidebar-chevron {
    color: #fff;
    transform: rotate(180deg);
}

.office-sidebar-submenu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-left: 8px;
    transition: max-height .28s ease, opacity .2s ease, margin .2s ease;
}

.office-sidebar-section.open .office-sidebar-submenu {
    max-height: 760px;
    margin-top: 5px;
    opacity: 1;
}

.office-sidebar-section.open .office-sidebar-submenu-tall {
    max-height: 1100px;
}

.office-sidebar-sublink {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 36px;
    padding: 9px 10px 9px 16px;
    border-radius: 11px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}

.office-sidebar-dot {
    display: inline-block;
    flex: 0 0 7px;
    width: 7px;
    height: 7px;
    margin-top: 5px;
    border-radius: 999px;
    background: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, .13);
}

.office-sidebar-dot-orange {
    background: #ff7a2f;
    box-shadow: 0 0 0 4px rgba(255, 122, 47, .13);
}

.office-sidebar-link:hover,
.office-sidebar-toggle:hover,
.office-sidebar-sublink:hover {
    color: #fff;
    background: rgba(139, 92, 246, .16);
}

.office-sidebar-link.active,
.office-sidebar-sublink.active {
    color: #fff;
    background: linear-gradient(135deg, #6d28d9, #8b5cf6);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 24px rgba(139, 92, 246, .24);
}

.ai-nav-group .office-sidebar-sublink.active,
.admin-nav-group .office-sidebar-sublink.active {
    background: linear-gradient(100deg, rgba(255, 69, 0, .94), rgba(139, 92, 246, .88));
    box-shadow: 0 12px 28px rgba(255, 69, 0, .22);
}

.office-sidebar-disabled {
    cursor: default;
    opacity: .55;
}

.office-sidebar-disabled:hover {
    color: #cbd5e1;
    background: transparent;
    box-shadow: none;
}

@media (max-width: 900px) {
    .app-shell > .sidebar {
        position: static;
        width: calc(100% - 24px);
        height: auto;
        max-height: none;
        margin: 12px;
    }
}

/* Runtime branding from Administration > Paramètres généraux. */
body {
    --accent: var(--primary-color, #8b5cf6);
    --orange: var(--accent-color, #ff4500);
}

.sidebar::-webkit-scrollbar-thumb,
.app-shell > .sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color, #8b5cf6), var(--accent-color, #ff4500));
}

.office-sidebar-icon {
    background: linear-gradient(135deg, var(--primary-color, #8b5cf6), rgba(76, 29, 149, .9));
}

.office-sidebar-icon-orange {
    background: linear-gradient(135deg, var(--accent-color, #ff4500), var(--primary-color, #8b5cf6));
}

.office-sidebar-dot {
    background: var(--primary-color, #8b5cf6);
}

.office-sidebar-link.active,
.office-sidebar-sublink.active,
.sidebar-link.active,
.sidebar-sublink.active {
    background: linear-gradient(135deg, var(--primary-color, #8b5cf6), color-mix(in srgb, var(--primary-color, #8b5cf6) 72%, #000));
}

.ai-nav-group .office-sidebar-sublink.active,
.admin-nav-group .office-sidebar-sublink.active,
.ai-nav-group .sidebar-sublink.active,
.admin-crones-link.active {
    background: linear-gradient(100deg, var(--accent-color, #ff4500), var(--primary-color, #8b5cf6));
}
