/**
 * ═══════════════════════════════════════════════════════════════
 * ALLDEBRID PANEL — Layout System
 * Sidebar, topbar, grid, responsive
 * ═══════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════ */

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

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-xl) var(--space-2xl);
    min-width: 0;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    background: var(--color-bg-primary);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform var(--duration-slow) var(--ease-out);
}

.sidebar-header {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--color-accent-glow);
}
.sidebar-logo .icon {
    color: #fff;
    width: 20px;
    height: 20px;
}

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

.sidebar-brand h1 {
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    line-height: 1.2;
    background: linear-gradient(135deg, var(--color-text), var(--color-accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-brand .sidebar-version {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
}

.nav-group {
    margin-bottom: var(--space-lg);
}

.nav-group-label {
    font-size: 10px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--color-text-tertiary);
    padding: var(--space-xs) var(--space-md);
    margin-bottom: var(--space-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
    user-select: none;
}

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

.nav-item.active {
    background: var(--color-accent-dim);
    color: var(--color-accent);
}

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

.nav-item .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--color-accent);
    color: #fff;
    font-size: 10px;
    font-weight: var(--weight-bold);
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.nav-item .nav-badge.red {
    background: var(--color-red);
}

/* Footer */
.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-sm);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--color-bg-card-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    color: var(--color-accent);
    font-weight: var(--weight-bold);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-status {
    font-size: var(--text-xs);
    color: var(--color-green);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-user-status .dot {
    width: 6px;
    height: 6px;
    background: var(--color-green);
    border-radius: 50%;
    display: inline-block;
}

/* ═══════════════════════════════════════════
   MOBILE TOPBAR
   ═══════════════════════════════════════════ */

.topbar-mobile {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--color-bg-primary);
    border-bottom: 1px solid var(--color-border);
    z-index: var(--z-sticky);
    padding: 0 var(--space-lg);
    align-items: center;
    justify-content: space-between;
}

.topbar-mobile .hamburger {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    cursor: pointer;
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ═══════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════ */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header h2 {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-header h2 .icon {
    color: var(--color-accent);
}

/* ═══════════════════════════════════════════
   GRIDS
   ═══════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-xl);
    margin-bottom: var(--space-2xl);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-xl);
}

.full-width { grid-column: 1 / -1; }

/* ═══════════════════════════════════════════
   PAGE VIEWS
   ═══════════════════════════════════════════ */

.page-view {
    display: none;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.page-view.active {
    display: block;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .topbar-mobile {
        display: flex;
    }

    .app-main {
        margin-left: 0;
        padding-top: calc(var(--topbar-height) + var(--space-xl));
        padding-left: var(--space-lg);
        padding-right: var(--space-lg);
    }
}

@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .glass-card {
        padding: var(--space-lg);
    }

    .toast-container {
        right: var(--space-md);
        left: var(--space-md);
    }
    .toast { min-width: auto; }
}

@media (max-width: 375px) {
    .app-main {
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }
}
