/* ============================================
   LegalYes Layout System
   Sidebar + Header + Content
   ============================================ */

/* APP CONTAINER */
.app {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    z-index: 100;
    transition: width var(--transition-normal), min-width var(--transition-normal);
    overflow: hidden;
}

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

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-lg);
    height: var(--header-height);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .brand-icon {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-toggle {
    width: 28px; height: 28px;
    background: none; border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.sidebar-toggle:hover { color: #fff; background: var(--bg-sidebar-hover); }

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .menu-label,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-badge { display: none; }

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-sm) 0;
    scrollbar-width: none;
}
.sidebar-menu::-webkit-scrollbar { display: none; }

.menu-section { margin-bottom: var(--space-sm); }

.menu-label {
    padding: var(--space-md) var(--space-lg) var(--space-xs);
    font-size: 0.65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
}

.menu-item {
    display: flex; align-items: center; gap: var(--space-md);
    padding: 9px var(--space-lg);
    color: rgba(255,255,255,0.65);
    cursor: pointer; transition: all var(--transition-fast);
    white-space: nowrap; text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 0.875rem;
}
.menu-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff; text-decoration: none;
}
.menu-item.active {
    background: var(--bg-sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}
.menu-item .menu-icon {
    width: 20px; text-align: center; flex-shrink: 0; font-size: 0.9rem;
}
.menu-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem; font-weight: 700;
    padding: 2px 7px; border-radius: var(--radius-full);
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: var(--space-md) var(--space-lg);
    flex-shrink: 0;
}

/* ============================================
   MAIN AREA
   ============================================ */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
    min-width: 0;
}
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-collapsed); }

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-white);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-btn {
    background: none; border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8); padding: 6px 14px;
    border-radius: var(--radius-md); font-size: 0.82rem;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: all var(--transition-fast);
}
.header-btn:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.3); }

.header-user {
    display: flex; align-items: center; gap: var(--space-sm);
    cursor: pointer; padding: 4px 8px; border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}
.header-user:hover { background: rgba(255,255,255,0.08); }
.header-user .avatar {
    width: 32px; height: 32px; border-radius: var(--radius-full);
    background: var(--primary); color: #fff; display: flex;
    align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
}
.header-user .user-name { font-size: 0.82rem; color: rgba(255,255,255,0.8); }

.status-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #10b981;
    display: inline-block; margin: 0 4px;
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

/* ============================================
   MOBILE HAMBURGER TOGGLE
   ============================================ */
.sidebar-mobile-toggle {
    display: none;
    width: 36px; height: 36px;
    background: none; border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.sidebar-mobile-toggle:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

/* ============================================
   RESPONSIVE
   ============================================ */
/* Scoped to .app shell only: tenant MVC uses .app-container + _TenantLayout (768px breakpoint).
   A global .sidebar rule here hid the sidebar up to 991px while the tenant hamburger is hidden above 767px. */
@media (max-width: 991px) {
    .app .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }
    .app .sidebar.mobile-open { transform: translateX(0); }
    .app .main { margin-left: 0; }
    .app .sidebar.collapsed ~ .main { margin-left: 0; }

    .app .sidebar-mobile-toggle { display: inline-flex; }

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

/* Mobile overlay when sidebar is open */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}
.sidebar.mobile-open ~ .sidebar-overlay { display: block; }

@media (max-width: 575px) {
    .header { padding: 0 var(--space-lg); height: 48px; }
    .header-title { font-size: 0.85rem; }
    .header-user .user-name { display: none; }
}
