/* ========== 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 4px 16px rgba(2, 132, 199, 0.35);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.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: linear-gradient(8deg, #0ea5e9 0%, #04050e 80% );
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--color-bg-secondary) 0%, var(--color-bg) 80%);
    padding: 0.5rem 1.5rem;
    max-width: 1900px;
    display: flex;
    flex-direction: column;
}

/* Variante Dashboard avec moins de padding */
.app-content--dashboard {
    padding: 1rem;
}

/* 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;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    z-index: var(--z-sidebar);
}

.sidebar-header {
    padding: 0.75rem var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.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) 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.89rem 0.75rem;
    color: var(--color-sidebar);
    font-size: 0.875rem;
    font-weight: 400;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
    position: relative;
}

    .sidebar-nav__item:hover {
        background-color: rgba(255, 255, 255, 0.08);
        color: #ffffff;
    }

    .sidebar-nav__item.active {
        color: #ffffff;
        background: linear-gradient(90deg, rgba(2, 132, 199, 0.2) 0%, rgba(2, 132, 199, 0.05) 100%);
        font-weight: 500;
    }

        /* Barre d'accent latérale sur l'item actif */
        .sidebar-nav__item.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 20%;
            bottom: 20%;
            width: 3px;
            background: var(--color-primary);
            border-radius: 0 3px 3px 0;
            box-shadow: 0 0 8px rgba(2, 132, 199, 0.4);
        }

.sidebar-nav__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.sidebar-nav__item.active .sidebar-nav__icon {
    opacity: 1;
}

.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: var(--color-sidebar);
    font-size: 0.875rem;
    font-weight: 450;
    border-radius: var(--radius-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition-fast);
    text-decoration: none;
}

    .sidebar-logout:hover {
        background-color: rgba(239, 68, 68, 0.15);
        color: #fca5a5;
    }

/* ========== TOPBAR ========== */
.topbar {
    position: sticky;
    z-index: var(--z-topbar);
    height: var(--topbar-height);
    margin: 0;
    padding: 0.75rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.page-body {
    flex: 1;
    padding-top: 1rem;
}

.topbar-title {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.topbar-title h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.notif-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Notifications Bell */
.topbar-notifications {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--color-text-secondary);
}

    .topbar-notifications:hover {
        background: var(--color-bg-secondary);
        color: var(--color-text);
    }

    .topbar-notifications i {
        font-size: 1.1rem;
    }

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--color-danger);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* User Avatar */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: default;
}

.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;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-primary);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* Dropdown Overlay */
.dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 998;
}

/* Dropdown Menu Base */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 320px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 999;
    animation: dropdownSlide 0.15s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

.notification-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.dropdown-content {
    max-height: 360px;
    overflow-y: auto;
}

.dropdown-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
}

.dropdown-link {
    display: block;
    color: var(--color-primary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition-fast);
    text-align: center;
}

    .dropdown-link:hover {
        color: var(--color-primary-hover);
    }

.dropdown-empty {
    padding: 3rem 1.25rem;
    text-align: center;
    color: var(--color-text-muted);
}

    .dropdown-empty i {
        font-size: 2.5rem;
        margin-bottom: 0.5rem;
        opacity: 0.3;
    }

    .dropdown-empty p {
        margin: 0;
        font-size: 0.9375rem;
    }

/* Notifications Dropdown */
.notifications-dropdown {
    min-width: 360px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--color-border-light);
    transition: background-color var(--transition-fast);
    cursor: pointer;
}

    .notification-item:last-child {
        border-bottom: none;
    }

    .notification-item:hover {
        background: var(--color-bg-secondary);
    }

.notification-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

    .notification-icon.success {
        color: var(--color-accent);
    }

    .notification-icon.info {
        color: var(--color-info);
    }

    .notification-icon.warning {
        color: var(--color-warning);
    }

.notification-text {
    flex: 1;
}

.notification-title {
    font-size: 0.875rem;
    color: var(--color-text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.notification-time {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* User Dropdown */
.user-dropdown {
    min-width: 280px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.25rem;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: background-color var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

    .dropdown-item:hover {
        background: var(--color-bg-secondary);
    }

    .dropdown-item i {
        font-size: 1.125rem;
        color: var(--color-text-secondary);
        width: 20px;
        text-align: center;
    }

    .dropdown-item.logout {
        color: var(--color-danger);
    }

        .dropdown-item.logout:hover {
            background: var(--color-danger-light);
        }

        .dropdown-item.logout i {
            color: var(--color-danger);
        }

/* ========== 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: linear-gradient(135deg, #0ea5e9 0%, #04050e 80%);
    }

        .sidebar.active {
            left: 0;
        }

    .topbar {
        padding: 0 var(--space-lg);
    }

    .app-content {
        padding: var(--space-lg);
    }

    .app-content--dashboard {
        padding: 1rem;
    }
}
