/* ========================================
   SIDEBAR LAYOUT SYSTEM — Dark Premium Theme
   ======================================== */

/* Sidebar color tokens */
:root {
    --sb-bg:          #0D1117;
    --sb-bg-hover:    rgba(255, 255, 255, 0.05);
    --sb-bg-active:   rgba(5, 150, 105, 0.12);
    --sb-border:      rgba(255, 255, 255, 0.07);
    --sb-text:        rgba(203, 213, 225, 0.85);
    --sb-text-muted:  rgba(148, 163, 184, 0.55);
    --sb-accent:      #34D399;
    --sb-accent-glow: rgba(52, 211, 153, 0.18);
    --sb-width:       272px;
}

/* Layout with sidebar */
.layout-with-sidebar {
    display: flex;
    min-height: 100vh;
}

/* Hide old header */
.layout-with-sidebar .header {
    display: none;
}

/* Main wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sb-width);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    background: var(--bg-secondary);
}

.layout-with-sidebar .container {
    max-width: 100%;
    padding: 0;
}

/* ========================================
   MOBILE HEADER
   ======================================== */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: var(--sb-bg);
    border-bottom: 1px solid var(--sb-border);
    z-index: 999;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.mobile-menu-toggle {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 0.475rem;
    cursor: pointer;
    color: var(--sb-text);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.mobile-menu-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--sb-accent);
    letter-spacing: 0.01em;
}

.mobile-header-spacer {
    width: 38px;
}

/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sb-width);
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 80% 40% at 50% 0%, rgba(5, 150, 105, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 30% at 50% 100%, rgba(217, 119, 6, 0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.sidebar > * {
    position: relative;
    z-index: 1;
}

/* ——————————————————————
   LOGO
   ——————————————————————*/

.sidebar-header {
    padding: 1.375rem 1.25rem;
    border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    text-decoration: none;
    border-radius: 10px;
    padding: 0.25rem;
    transition: opacity 0.2s;
}

.sidebar-logo:hover { opacity: 0.85; }

.sidebar-logo img {
    border-radius: 10px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 8px rgba(52, 211, 153, 0.25));
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.logo-title {
    font-size: 1.125rem;
    font-weight: 800;
    color: #FFFFFF;
    letter-spacing: -0.01em;
}

.logo-subtitle {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--sb-accent);
    letter-spacing: 0.04em;
}

/* ——————————————————————
   NAVIGATION
   ——————————————————————*/

.sidebar-nav {
    flex: 1;
    padding: 0.875rem 0.75rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 99px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.7rem 0.875rem;
    color: var(--sb-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.18s ease;
    border-radius: 9px;
    margin: 2px 0;
    position: relative;
}

.sidebar-link:hover {
    background: var(--sb-bg-hover);
    color: #FFFFFF;
}

.sidebar-link.active {
    background: var(--sb-bg-active);
    color: var(--sb-accent);
    font-weight: 600;
}

.sidebar-link.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--sb-accent);
    border-radius: 99px 0 0 99px;
    box-shadow: 0 0 8px var(--sb-accent-glow);
}

.sidebar-link svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.18s;
}

.sidebar-link:hover svg,
.sidebar-link.active svg {
    opacity: 1;
    color: var(--sb-accent);
}

.sidebar-link .material-symbols-outlined {
    flex-shrink: 0;
    font-size: 20px;
    opacity: 0.65;
    transition: opacity 0.18s, color 0.18s;
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

.sidebar-link:hover .material-symbols-outlined,
.sidebar-link.active .material-symbols-outlined {
    opacity: 1;
    color: var(--sb-accent);
}

/* ——————————————————————
   FOOTER
   ——————————————————————*/

.sidebar-footer {
    border-top: 1px solid var(--sb-border);
    padding: 1rem 0.75rem;
}

.sidebar-auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-sidebar {
    padding: 0.7rem 1rem;
    border-radius: 9px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    display: block;
}

.btn-sidebar-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 3px 12px rgba(5, 150, 105, 0.3);
}

.btn-sidebar-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #065F46 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.45);
    transform: translateY(-1px);
}

.btn-sidebar-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--sb-text);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-sidebar-secondary:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* User section */
.sidebar-user { position: relative; }

.sidebar-user-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-user-button:hover {
    background: rgba(255,255,255,0.09);
    border-color: rgba(52, 211, 153, 0.3);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    text-align: left;
}

.user-email {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #F1F5F9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 0.7rem;
    color: var(--sb-accent);
    font-weight: 500;
}

.dropdown-icon {
    flex-shrink: 0;
    color: var(--sb-text-muted);
    transition: transform 0.2s;
}

.sidebar-user-button:hover .dropdown-icon {
    color: var(--sb-text);
    transform: translateY(-1px);
}

.sidebar-user-dropdown {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #161B22;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    padding: 0.375rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sidebar-user-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 7px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-user-dropdown .dropdown-item:hover {
    background: rgba(255,255,255,0.07);
    color: #FFFFFF;
}

.sidebar-user-dropdown .dropdown-item svg {
    color: var(--sb-text-muted);
    flex-shrink: 0;
}

.sidebar-user-dropdown .dropdown-item:hover svg { color: var(--sb-accent); }

.sidebar-user-dropdown hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.07);
    margin: 0.375rem 0;
}

/* ========================================
   SIDEBAR OVERLAY (Mobile)
   ======================================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ========================================
   FOOTER IN SIDEBAR LAYOUT
   ======================================== */

.layout-with-sidebar .footer {
    margin-left: 0;
    margin-top: 0;
}

/* ========================================
   USER MENU DROPDOWN (Compatibility)
   ======================================== */

.user-menu { position: relative; }

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.user-menu-button:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 200px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-dropdown .dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
}

.user-menu-dropdown .dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.user-menu-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.5rem 0;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1024px) {
    .main-wrapper { margin-left: 0; }
    .mobile-header { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 4px 0 40px rgba(0, 0, 0, 0.6);
    }

    .sidebar-overlay { display: block; }
    .main-content { padding-top: calc(58px + 1.75rem); }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
        padding-top: calc(58px + 1rem);
    }

    .sidebar {
        width: 88%;
        max-width: 300px;
    }

    .sidebar-link { padding: 0.875rem 1rem; }
}

/* ========================================
   UTILITIES
   ======================================== */

* { -webkit-tap-highlight-color: transparent; }

.sidebar,
.sidebar-overlay,
.main-wrapper {
    will-change: transform, opacity;
}


/* === Accessibilité — Réduction des animations (WCAG 2.3.3) === */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .main-wrapper,
    .sidebar-overlay,
    .sidebar-link,
    .sidebar-user-dropdown,
    .mobile-menu-toggle {
        transition: none !important;
        animation: none !important;
    }
}
