/* ========================================
   DESIGN SYSTEM TLS
   ======================================== */
:root {
    /* Colors */
    --primary: #55A1B4;
    --primary-hover: #4A8FA1;
    --primary-dark: #3D7786;
    --primary-active: #4A8FA1; /* Couleur pour les items actifs */
    --secondary: #ED843A;
    --accent: #F8B044;
    --destructive: #d4183d;
    
    --neutral-50: #F5F8F8;
    --neutral-100: #EEF6F8;
    --neutral-200: #E0E8EA;
    --neutral-300: #C8D4D7;
    --neutral-500: #6B7D82;
    --neutral-900: #252B37;
    
    --background: #ffffff;
    --foreground: #252B37;
    --muted-foreground: #6b7280;
    --border: rgba(0, 0, 0, 0.1);
    
    /* Typography */
    --font-display: 'League Spartan', -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    
    /* Transitions */
    --duration-fast: 150ms;
    --duration-base: 200ms;
    --duration-slow: 300ms;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index */
    --z-sidebar: 1000;
    --z-dropdown: 1100;
}

/* ========================================
   SIDEBAR CONTAINER
   ======================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    background: transparent;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: width var(--duration-slow) var(--ease);
    width: 288px;
}

.sidebar.collapsed {
    width: 80px;
}

/* ========================================
   SIDEBAR HEADER
   ======================================== */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 96px;
    position: relative;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

.brand-logo {
    width: 56px;
    height: 56px;
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--duration-slow) var(--ease);
    background: transparent;
}

/* Quand la sidebar est expanded, le logo prend toute la largeur */
.sidebar:not(.collapsed) .brand-logo {
    width: 100%;
    min-width: 0;
    height: 56px;
    justify-content: flex-start;
}

/* Logo en mode réduit : demi-cercle */
.sidebar.collapsed .brand-logo {
    position: absolute;
    left: 12px;
    border-radius: 50%;
    width: 56px;
}

/* SVG Icon dans le logo */
.brand-logo svg {
    width: 100%;
    height: 100%;
    transition: transform var(--duration-slow) var(--ease);
}

/* Logo collapsed - visible uniquement quand sidebar est collapsed */
.brand-logo .logo-collapsed {
    display: block;
    max-width: 48px;
    max-height: 48px;
}

.brand-logo .logo-expanded {
    display: none;
    width: 100%;
    max-width: 100%;
    max-height: 48px;
    height: auto;
}

/* Logo expanded - visible uniquement quand sidebar est expanded */
.sidebar:not(.collapsed) .brand-logo .logo-collapsed {
    display: none;
}

.sidebar:not(.collapsed) .brand-logo .logo-expanded {
    display: block;
}

/* Logo collapsed - visible uniquement quand sidebar est collapsed */
.sidebar.collapsed .brand-logo .logo-collapsed {
    display: block;
}

.sidebar.collapsed .brand-logo .logo-expanded {
    display: none;
}

.sidebar.collapsed .brand-logo svg {
    transform: translateX(0);
}

.brand-text {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity var(--duration-base) var(--ease);
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    pointer-events: none;
}

/* Masquer le texte en mode expanded */
.sidebar:not(.collapsed) .brand-text {
    display: none;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toggle-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all var(--duration-base) var(--ease);
    opacity: 1;
    position: relative;
    z-index: 10;
}

.sidebar.collapsed .toggle-btn {
    position: absolute;
    right: -20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toggle-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.toggle-btn svg {
    width: 20px;
    height: 20px;
    transition: transform var(--duration-slow) var(--ease);
}

.sidebar.collapsed .toggle-btn svg {
    transform: rotate(180deg);
}

/* ========================================
   SIDEBAR NAV
   ======================================== */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed .sidebar-nav {
    padding: 16px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    margin-bottom: 6px;
    border-radius: 28px;
    text-decoration: none;
    color: var(--foreground);
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    transition: all var(--duration-base) var(--ease);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(85, 161, 180, 0.08);
}

.nav-item.active {
    background: linear-gradient(90deg, #4891A3 0%, #3D7786 100%);
    color: white;
    box-shadow: 0 2px 12px rgba(85, 161, 180, 0.3);
}

.nav-item.active:hover {
    background: linear-gradient(90deg, #4891A3 0%, #3D7786 100%);
    filter: brightness(0.95);
}

.nav-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.nav-label {
    opacity: 1;
    transition: opacity var(--duration-base) var(--ease);
}

.sidebar.collapsed .nav-label {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    width: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 14px;
    border-radius: 50%;
    width: 52px;
    height: 52px;
    margin: 0 auto 6px auto;
}

.sidebar.collapsed .nav-item .nav-icon {
    margin: 0;
}

/* ========================================
   SIDEBAR FOOTER (USER MENU)
   ======================================== */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    position: relative;
}

.sidebar.collapsed .sidebar-footer {
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    background: var(--neutral-50);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--duration-base) var(--ease);
    width: 100%;
}

.sidebar.collapsed .user-menu-trigger {
    padding: 10px;
    justify-content: center;
    gap: 0;
    background: transparent;
    transform: translateX(-10%);
}

.sidebar.collapsed .user-avatar {
    margin-left: 30px;
}

.user-menu-trigger:hover {
    border-color: none;
    background: rgba(85, 161, 180, 0.05);
}

.user-menu-trigger.active {
    border-color: var(--primary);
    background: rgba(85, 161, 180, 0.08);
}

.user-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    position: relative;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--background);
}

.user-info {
    flex: 1;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--duration-base) var(--ease);
}

.sidebar.collapsed .user-info {
    opacity: 0;
    pointer-events: none;
}

.user-name {
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    color: var(--foreground);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 400;
    color: var(--muted-foreground);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-arrow {
    width: 20px;
    height: 20px;
    min-width: 20px;
    opacity: 1;
    transition: all var(--duration-base) var(--ease);
}

.sidebar.collapsed .dropdown-arrow {
    opacity: 0;
}

.user-menu-trigger.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-arrow svg {
    width: 20px;
    height: 20px;
    stroke: var(--muted-foreground);
    stroke-width: 2;
    fill: none;
}

/* ========================================
   USER DROPDOWN MENU
   ======================================== */
.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    margin-bottom: 8px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.08);
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all var(--duration-slow) var(--ease);
    z-index: var(--z-dropdown);
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--foreground);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    transition: all var(--duration-base) var(--ease);
    cursor: pointer;
    position: relative;
}

.dropdown-item:hover {
    background: rgba(85, 161, 180, 0.08);
}

.dropdown-item.logout {
    color: var(--destructive);
}

.dropdown-item.logout:hover {
    background: rgba(212, 24, 61, 0.08);
}

.dropdown-icon {
    width: 22px;
    height: 22px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.dropdown-label {
    flex: 1;
}

.dropdown-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.dropdown-badge.notification {
    background: var(--secondary);
    color: white;
}

.dropdown-badge.version {
    background: var(--primary);
    color: white;
}

.dropdown-badge.pro {
    background: var(--secondary);
    color: white;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ========================================
   COLLAPSED STATE ADJUSTMENTS
   ======================================== */
.sidebar.collapsed .user-dropdown {
    left: calc(100% + 8px);
    right: auto;
    bottom: 16px;
    width: 280px;
}

/* ========================================
   SCROLLBAR
   ======================================== */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* ========================================
   MAIN CONTENT - ADJUSTMENT FOR SIDEBAR
   ======================================== */
.tls-main {
    flex: 1;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    margin-left: 288px;
    transition: margin-left var(--duration-slow) var(--ease);
}

.sidebar.collapsed ~ .tls-app-content .tls-main,
.tls-app-content:has(.sidebar.collapsed) .tls-main {
    margin-left: 80px;
}

@media (max-width: 1023px) {
    .tls-main {
        margin-left: 0;
        padding-bottom: 80px; /* Space for bottom nav */
    }
    
    /* Hide sidebar on mobile - use bottom nav instead */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
}

/* ========================================
   BOTTOM NAVIGATION MOBILE
   ======================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    display: none; /* Hidden by default, shown on mobile */
    justify-content: center;
    align-items: center;
    pointer-events: none; /* Allow clicks to pass through to container */
}

@media (max-width: 1023px) {
    .bottom-nav {
        display: flex;
    }
}

.bottom-nav__container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 32px;
    box-shadow: 
        0 -4px 20px rgba(0, 0, 0, 0.08),
        0 4px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    max-width: calc(100% - 2rem);
    pointer-events: all; /* Restore clicks on container */
    position: relative;
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    color: var(--muted-foreground, #6B7280);
    text-decoration: none;
    min-width: 60px;
}

.bottom-nav__item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.3);
}

.bottom-nav__item.active {
    color: var(--primary, #55A1B4);
    background: rgba(85, 161, 180, 0.15);
}

.bottom-nav__icon {
    position: relative;
    width: 24px;
    height: 24px;
}

.bottom-nav__icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.bottom-nav__badge {
    position: absolute;
    top: -4px;
    right: -8px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--secondary, #ED843A);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav__label {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
}

.bottom-nav__item.active .bottom-nav__label {
    font-weight: 700;
}

.bottom-nav__indicator {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 4px;
    border-radius: 2px;
    background: var(--primary, #55A1B4);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bottom-nav__item.active .bottom-nav__indicator {
    opacity: 1;
}
