/* ============================================
   E-ERP B2B Portal — Layout CSS
   Sidebar, Header, Content Grid
   ============================================ */

/* === APP WRAPPER === */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    transition: width var(--transition-slow);
    overflow: hidden;
}

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

/* Sidebar Header / Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 60px;
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand .brand-name {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-brand .brand-sub {
    font-size: 11px;
    opacity: 0.6;
    white-space: nowrap;
}

.sidebar.collapsed .brand-text { display: none; }

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

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

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 8px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

.sidebar.collapsed .nav-section-title { display: none; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.9);
}

.nav-item.active {
    background: rgba(14,165,233,0.12);
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.nav-item span {
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar.collapsed .nav-badge { display: none; }

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px;
    background: rgba(255,255,255,0.06);
    border: none;
    border-radius: 8px;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* === HEADER === */
.app-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left .page-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
}

.header-left .page-subtitle {
    font-size: 12px;
    color: var(--gray-500);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.header-user:hover {
    background: var(--gray-100);
}

.header-user .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.header-user .user-info {
    display: flex;
    flex-direction: column;
}

.header-user .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
}

.header-user .user-role {
    font-size: 11px;
    color: var(--gray-500);
}

.header-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--transition-fast);
    font-size: 15px;
    position: relative;
}

.header-btn:hover {
    background: var(--gray-200);
    color: var(--dark);
}

.header-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--white);
}

/* === PAGE CONTENT === */
.page-content {
    flex: 1;
    padding: 20px 24px;
}

/* === USER DROPDOWN === */
.user-dropdown {
    position: absolute;
    top: calc(var(--header-height) - 4px);
    right: 24px;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    min-width: 200px;
    z-index: var(--z-dropdown);
    display: none;
    overflow: hidden;
}

.user-dropdown.show { display: block; }

.user-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--gray-700);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 13px;
}

.user-dropdown .dropdown-item:hover {
    background: var(--gray-50);
}

.user-dropdown .dropdown-item i {
    width: 18px;
    text-align: center;
    color: var(--gray-500);
}

.user-dropdown .dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

.user-dropdown .dropdown-item.danger {
    color: var(--danger);
}
.user-dropdown .dropdown-item.danger i {
    color: var(--danger);
}
