/**
 * App Shell CSS - Microsoft 365 Copilot Style
 * Collapsed sidebar that expands on hover/click
 * Date: 2026-01-30
 *
 * Features:
 * - Collapsed by default (icon rail ~56px)
 * - Expands on hover to show labels
 * - Smooth animations
 * - Elegant, minimal design
 */

/* ========================================
   CSS RESET & BASE
   ======================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

.app-shell-body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
}


/* ========================================
   APP SHELL LAYOUT
   ======================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
}


/* ========================================
   SIDEBAR - COLLAPSED BY DEFAULT
   ======================================== */

.app-sidebar {
    width: 56px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Expanded state */
.app-sidebar:hover,
.app-sidebar.expanded {
    width: 280px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    background: #ffffff;
}

[data-theme="dark"] .app-sidebar {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .app-sidebar:hover,
[data-theme="dark"] .app-sidebar.expanded {
    background: #1e1e2d;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
}


/* ========================================
   SIDEBAR HEADER
   ======================================== */

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 12px;
    min-height: 56px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
}

.sidebar-logo-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--brand-navy);
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s ease 0.1s, transform 0.2s ease 0.1s;
}

.app-sidebar:hover .sidebar-logo-text,
.app-sidebar.expanded .sidebar-logo-text {
    opacity: 1;
    transform: translateX(0);
}

[data-theme="dark"] .sidebar-logo-text {
    color: #ffffff;
}

.sidebar-toggle {
    display: none;
}


/* ========================================
   NAVIGATION LIST
   ======================================== */

.sidebar-nav-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Hide scrollbar but keep functionality */
.sidebar-nav-list::-webkit-scrollbar {
    width: 4px;
}

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

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

.sidebar-nav-item {
    margin-bottom: 2px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #5f6368;
    text-decoration: none;
    transition: all 0.15s ease;
    font-weight: 450;
    font-size: 13px;
    white-space: nowrap;
    position: relative;
}

.sidebar-nav-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a1a;
}

[data-theme="dark"] .sidebar-nav-link {
    color: #9ca3af;
}

[data-theme="dark"] .sidebar-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

/* Focus styles */
.sidebar-nav-link:focus {
    outline: none;
}

.sidebar-nav-link:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: -2px;
}

/* Active State */
.sidebar-nav-link.active {
    background: linear-gradient(135deg, rgba(31, 111, 214, 0.12) 0%, rgba(35, 153, 212, 0.08) 100%);
    color: var(--primary-blue);
    font-weight: 500;
}

.sidebar-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary-blue);
    border-radius: 0 3px 3px 0;
}

[data-theme="dark"] .sidebar-nav-link.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(96, 165, 250, 0.1) 100%);
    color: #60a5fa;
}

[data-theme="dark"] .sidebar-nav-link.active::before {
    background: #60a5fa;
}


/* ========================================
   NAVIGATION ICONS
   ======================================== */

.sidebar-nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.sidebar-nav-link:hover .sidebar-nav-icon,
.sidebar-nav-link.active .sidebar-nav-icon {
    opacity: 1;
}

.sidebar-nav-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.75;
}

.sidebar-nav-label {
    flex: 1;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.2s ease 0.05s, transform 0.2s ease 0.05s;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar:hover .sidebar-nav-label,
.app-sidebar.expanded .sidebar-nav-label {
    opacity: 1;
    transform: translateX(0);
}


/* ========================================
   SIDEBAR FOOTER
   ======================================== */

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin-top: auto;
}

[data-theme="dark"] .sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sidebar-user-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .sidebar-user-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--primary-blue) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.2s ease 0.05s, transform 0.2s ease 0.05s;
}

.app-sidebar:hover .sidebar-user-info,
.app-sidebar.expanded .sidebar-user-info {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-user-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 11px;
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ========================================
   MAIN CONTENT AREA
   ======================================== */

.app-main {
    flex: 1;
    margin-left: 56px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ========================================
   APP HEADER
   ======================================== */

.app-header {
    display: none;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #1a1a1a;
}

.mobile-menu-toggle svg {
    width: 100%;
    height: 100%;
}

.app-header-title {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ========================================
   APP CONTENT
   ======================================== */

.app-content {
    flex: 1;
}


/* ========================================
   MOBILE OVERLAY
   ======================================== */

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s ease;
}


/* ========================================
   TOOLTIP FOR COLLAPSED STATE
   ======================================== */

.sidebar-nav-link::after {
    content: attr(title);
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: #1a1a1a;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-nav-link::before {
    z-index: 1;
}

/* Show tooltip only when sidebar is collapsed */
.app-sidebar:not(:hover):not(.expanded) .sidebar-nav-link:hover::after {
    opacity: 1;
    visibility: visible;
}


/* ========================================
   RESPONSIVE: MOBILE (<768px)
   ======================================== */

@media (max-width: 767px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: none;
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.2);
    }

    .app-sidebar .sidebar-logo-text,
    .app-sidebar .sidebar-nav-label,
    .app-sidebar .sidebar-user-info {
        opacity: 1;
        transform: translateX(0);
    }

    .sidebar-backdrop.visible {
        display: block;
        opacity: 1;
    }

    .app-main {
        margin-left: 0;
    }

    .app-header {
        display: flex;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    /* Hide tooltips on mobile */
    .sidebar-nav-link::after {
        display: none;
    }
}

/* RTL Support */
[dir="rtl"] .app-sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

[dir="rtl"] .app-sidebar:hover,
[dir="rtl"] .app-sidebar.expanded {
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
}

[dir="rtl"] .app-main {
    margin-left: 0;
    margin-right: 56px;
}

[dir="rtl"] .sidebar-nav-link.active::before {
    left: auto;
    right: 0;
    border-radius: 3px 0 0 3px;
}

[dir="rtl"] .sidebar-nav-link::after {
    left: auto;
    right: 60px;
}


/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .app-sidebar,
    .sidebar-backdrop,
    .mobile-menu-toggle,
    .app-header {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
    }
}

/* ========================================
   SCROLL LOCK SYSTEM

   Prevents background scrolling when modal/dropdown is open.
   Works with ScrollLock JavaScript module in home.html.twig.

   Class: .app-launcher-scroll-lock (added to body)

   @see /docs/SCROLL-LOCK-SYSTEM.md for full documentation
   ======================================== */

/* Base scroll lock - freeze body */
body.app-launcher-scroll-lock {
    overflow: hidden !important;
}

/* Freeze main content area */
body.app-launcher-scroll-lock .app-shell,
body.app-launcher-scroll-lock .app-main {
    overflow: hidden !important;
}

/* Prevent scroll chaining from dropdown */
.app-launcher-dropdown {
    overscroll-behavior: contain;
}

/* RTL support */
[dir="rtl"] body.app-launcher-scroll-lock .app-main {
    margin-left: 0 !important;
    margin-right: 56px !important;
}
