/* ========== CHAT WIDGET ========== */

.chat-widget {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    z-index: var(--z-toast);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: white;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(2, 132, 199, 0.32);
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), background var(--transition-smooth);
}

.chat-widget:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
}

.chat-widget:active {
    transform: translateY(0);
}

body:has(.panel-overlay.open) .chat-widget {
    display: none;
}

/* ========== APP LAYOUT ========== */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--app-shell-bg);
}

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

.app-content {
    flex: 1;
    overflow-y: auto;
    background: var(--content-bg);
    padding: 30px 34px;
    max-width: 1900px;
    display: flex;
    flex-direction: column;
}

/* Le Dashboard partage désormais la même gouttière que les autres pages. */
.app-content--dashboard {
    padding: 30px 34px;
}

/* Robot watermark */
.app-content::before {
    content: '';
    position: fixed;
    bottom: 0;
    right: 3%;
    width: 300px;
    height: 70vh;
    background-image: url('/robot.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom right;
    opacity: 0.03;
    pointer-events: none;
    z-index: -1;
}

.app-content > * {
    position: relative;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background-color: transparent;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: var(--z-sidebar);
}

.sidebar-header {
    padding: 1rem 1.375rem;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.sidebar-logo__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.sidebar-logo__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-logo__title {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.sidebar-logo__subtitle {
    font-size: 0.75rem;
    color: var(--color-sidebar);
    line-height: 1.3;
    font-weight: 400;
    opacity: 0.7;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar-nav__item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.75rem;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.875rem;
    font-weight: 400;
    border-radius: var(--radius-md);
    transition: background var(--transition-smooth), color var(--transition-smooth);
    text-decoration: none;
    position: relative;
}

    .sidebar-nav__item:hover {
        background-color: rgba(255, 255, 255, 0.06);
        color: #ffffff;
    }

    .sidebar-nav__item.active {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.09);
        font-weight: 500;
    }

        /* Barre d'accent latérale sur l'item actif : un trait plein bord à bord,
           sans halo — la maquette pose un repère, pas un effet. */
        .sidebar-nav__item.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 2px;
            background: var(--sidebar-active-bar);
        }

.sidebar-nav__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-nav__text {
    flex: 1;
}

/* Sidebar Section Labels */
.sidebar-nav__section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0.75rem;
    margin-top: 8px;
    margin-bottom: 2px;
}

.sidebar-nav__section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    white-space: nowrap;
}

.sidebar-nav__section::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Logout */
/* Pied de sidebar : poussé en bas en bloc (compte + préférences + déconnexion). */
.sidebar-nav__footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.45rem 0.75rem;
    margin: var(--space-sm);
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 450;
    border-radius: var(--radius-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: background var(--transition-smooth), color var(--transition-smooth);
    text-decoration: none;
}

    .sidebar-logout:hover {
        background-color: rgba(239, 68, 68, 0.15);
        color: #fca5a5;
    }

.sidebar-version {
    padding: 0 var(--space-md) var(--space-sm);
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
    text-align: center;
}

.page-body {
    flex: 1;
}

.user-role-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    color: var(--color-text-subtle);
}

.user-role-meta--superadmin {
    color: var(--color-accent);
}

.user-role-meta-icon {
    font-size: 0.8125rem;
    line-height: 1;
}

.user-role-meta-sep {
    opacity: 1;
    font-weight: 700;
}

.user-role-meta-scope {
    color: var(--color-text-secondary);
    font-weight: 500;
    letter-spacing: 0.04em;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(var(--sidebar-width) * -1);
        top: 0;
        height: 100vh;
        overflow-y: auto;
        z-index: 1000;
        transition: left var(--transition-slow);
        background: var(--app-shell-bg);
    }

        .sidebar.active {
            left: 0;
        }

    .app-content,
    .app-content--dashboard {
        padding: var(--space-lg);
    }
}
