/* ============================================
   796Helper - Layout Styles
   ============================================ */

/* --- App Container --- */
.app {
    display: flex;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base), min-width var(--transition-base), transform var(--transition-base);
    z-index: var(--z-sidebar);
    position: relative;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
}

/* Sidebar Brand */
.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    gap: var(--space-sm);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.sidebar-brand .brand-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.sidebar-brand .brand-text {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: var(--space-md) var(--space-sm);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.nav-section-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-sm) var(--space-sm);
    margin-bottom: var(--space-xs);
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--primary-light);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--gradient-primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item .nav-icon svg {
    width: 20px;
    height: 20px;
}

.nav-item .nav-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: var(--font-weight-semibold);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-badge {
    opacity: 0;
    width: 0;
    padding: 0;
    margin: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-sm);
    border-top: 1px solid var(--border-default);
    flex-shrink: 0;
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-primary);
}

.sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
}

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

/* --- Mobile Overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    transition: opacity var(--transition-base);
    visibility: hidden;
    pointer-events: none;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

/* --- Header --- */
.header {
    height: var(--header-height);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: var(--z-header);
    flex-shrink: 0;
    position: sticky;
    top: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 0;
}

.header-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-primary);
}

.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
}

.header-icon-btn:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-primary);
}

.header-icon-btn svg {
    width: 20px;
    height: 20px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: #fff;
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}

.user-avatar:hover {
    box-shadow: var(--shadow-glow);
}

/* --- Page Container --- */
.page-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.page-content {
    min-height: 100%;
    animation: fadeIn 0.3s ease;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        width: min(82vw, var(--sidebar-width));
        min-width: min(82vw, var(--sidebar-width));
        box-shadow: var(--shadow-lg);
        padding-left: env(safe-area-inset-left, 0px);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: min(82vw, var(--sidebar-width));
        min-width: min(82vw, var(--sidebar-width));
    }

    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .nav-badge,
    .sidebar.collapsed .nav-section-title {
        opacity: 1;
        width: auto;
        height: auto;
        padding: revert;
        margin: revert;
    }

    .sidebar-overlay {
        display: block;
    }

    .main-content {
        width: 100%;
    }

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

    .sidebar-footer {
        display: none;
    }

    .header {
        padding: 0 var(--space-md);
    }

    .page-container {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .header-title {
        font-size: var(--font-size-md);
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: var(--font-size-xs);
    }

    .nav-item {
        padding: 12px 12px;
        min-height: 44px;
    }
}

/* --- Responsive: Small Mobile --- */
@media (max-width: 480px) {
    .header {
        padding: 0 var(--space-sm);
        gap: var(--space-xs);
    }

    .header-left {
        gap: var(--space-sm);
    }

    .header-title {
        font-size: var(--font-size-base);
    }

    .header-right {
        gap: var(--space-xs);
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
    }

    .mobile-menu-btn svg {
        width: 20px;
        height: 20px;
    }
}
