/**
 * Layout Styles - Topbar, Sidebar, Main Content
 * Responsive layout với collapsible sidebar
 */

/* === MAIN LAYOUT STRUCTURE === */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-secondary);
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-base);
}

.app-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* === TOPBAR === */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background-color: var(--bg-primary);
    border-bottom: var(--border-width-thin) solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
}

.topbar-brand-icon {
    font-size: var(--font-size-2xl);
}

.topbar-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.topbar-balance {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.5rem 1rem;
    background-color: var(--color-success-light);
    border-radius: var(--border-radius-md);
    font-weight: var(--font-weight-semibold);
    color: var(--color-success);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-md);
    transition: background-color var(--transition-fast);
}

.topbar-user:hover {
    background-color: var(--bg-secondary);
}

.topbar-user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--border-radius-full);
    background-color: var(--color-primary);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
}

.topbar-user-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.topbar-user-role {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-primary);
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-primary);
    border-right: var(--border-width-thin) solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base), transform var(--transition-base);
    z-index: var(--z-fixed);
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    border-bottom: var(--border-width-thin) solid var(--border-light);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    white-space: nowrap;
}

.sidebar-logo-icon {
    font-size: var(--font-size-2xl);
    flex-shrink: 0;
}

.sidebar-logo-text {
    transition: opacity var(--transition-fast);
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-md) 0;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: var(--border-medium);
    border-radius: var(--border-radius-full);
}

.sidebar-section {
    margin-bottom: 0;
    padding-bottom: var(--spacing-md);
}

.sidebar-section:not(:last-child) {
    border-bottom: var(--border-width-thin) solid var(--border-light);
    margin-bottom: var(--spacing-md);
}

.sidebar-section-title {
    padding: 0 var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-section-title {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu-item {
    margin: 0;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0.75rem var(--spacing-lg);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
    position: relative;
}

.sidebar-menu-link:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.sidebar-menu-link.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
}

.sidebar-menu-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--color-primary);
}

.sidebar-menu-icon {
    font-size: var(--font-size-xl);
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}

.sidebar-menu-text {
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-menu-text {
    opacity: 0;
    width: 0;
}

.sidebar-menu-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    background-color: var(--color-accent);
    color: var(--text-inverse);
    font-size: var(--font-size-xs);
    border-radius: var(--border-radius-full);
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-menu-badge {
    opacity: 0;
    width: 0;
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: var(--border-width-thin) solid var(--border-light);
}

.sidebar-footer-text {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    text-align: center;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-footer-text {
    opacity: 0;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
}

.sidebar-overlay.show {
    display: block;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    padding: var(--spacing-xl);
    max-width: var(--container-max-width);
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: var(--spacing-xl);
}

.page-title {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.page-subtitle {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
}

.page-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* === FOOTER === */
.app-footer {
    background-color: var(--bg-primary);
    border-top: var(--border-width-thin) solid var(--border-light);
    padding: var(--spacing-lg);
    text-align: center;
}

.footer-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-sm);
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--text-primary);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-content {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

    .mobile-menu-toggle {
        display: block;
    }

    .topbar-balance {
        display: none;
    }

    .topbar-user-info {
        display: none;
    }

    .main-content {
        padding: var(--spacing-md);
    }

    .page-title {
        font-size: var(--font-size-2xl);
    }
}