/**
 * Attendance OS — Layout Styles
 * Copyright © 2025 Josiah. All rights reserved.
 * Licensed under the MIT License.
 */

/* ── App shell ───────────────────────────────────────────────────── */
#app {
    display: none;
    height: 100vh;
    overflow: hidden;
}

.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-screen .loading-text {
    text-align: center;
}

.loading-screen .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-screen .loading-text p {
    margin-top: 1rem;
    color: var(--text-secondary);
}

.loading-screen .loading-text {
    text-align: center;
}

.loading-screen .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-screen .loading-text p {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
#sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    gap: var(--space-md);
    /* Glass panel */
    background: var(--glass-2);
    -webkit-backdrop-filter: var(--blur-md);
    backdrop-filter: var(--blur-md);
    border-right: 1px solid var(--border);
    /* Subtle inner highlight at top */
    box-shadow: inset -1px 0 0 var(--border-dim),
        1px 0 30px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    position: relative;
    z-index: 10;
}

/* Subtle gradient shimmer down the sidebar */
#sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(180deg,
            rgba(16, 185, 129, 0.05) 0%,
            transparent 100%);
    pointer-events: none;
}

#sidebar header {
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-dim);
}

#sidebar header h1 {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

#sidebar header h1 .icon-chart svg {
    color: var(--primary);
    filter: drop-shadow(0 0 6px var(--primary-glow));
}

.subtitle {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.user-display {
    font-size: var(--fs-sm);
    color: var(--primary);
    margin-top: var(--space-sm);
    font-weight: 500;
}

/* ── Navigation ──────────────────────────────────────────────────── */
#nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 10px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: 500;
    font-family: var(--font-sans);
    text-align: left;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.01em;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.nav-item:hover {
    background: var(--glass-hover);
    border-color: var(--border-dim);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--glass-active);
    border-color: var(--border-accent);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 0 20px var(--primary-glow-sm);
}

.nav-item.active::before {
    transform: scaleY(1);
}

/* ── Sidebar footer ───────────────────────────────────────────────── */
.sidebar-footer {
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-dim);
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
}

.theme-toggle,
.install-extension-btn {
    background: var(--glass-2);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0;
}

.install-extension-btn {
    width: auto;
    min-width: 140px;
    padding: 0 var(--space-sm);
    font-size: var(--fs-sm);
    border-radius: var(--radius-lg);
    font-weight: 700;
}

.theme-toggle:hover,
.install-extension-btn:hover {
    background: var(--glass-3);
    border-color: var(--border-bright);
    color: var(--text-primary);
    box-shadow: 0 0 12px var(--primary-glow-sm);
}

/* ── Sync status strip ───────────────────────────────────────────── */
.sync-status {
    background: var(--glass-1);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.sync-status #last-sync {
    margin-bottom: var(--space-sm);
    color: var(--text-muted);
}

/* ── Main content ────────────────────────────────────────────────── */
#content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl) var(--space-2xl);
    min-width: 0;
}

/* Module max-widths */
.dashboard,
.courses-module,
.calculator-module,
.sync-module,
.settings-module,
.analytics-module {
    max-width: 1100px;
}

.sync-module,
.settings-module {
    max-width: 720px;
}

/* ── Grid ────────────────────────────────────────────────────────── */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        padding: var(--space-md);
        border-right: none;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    #sidebar::before {
        height: 100px;
    }

    #nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav-item {
        flex: 1;
        min-width: 80px;
        text-align: center;
        padding: var(--space-sm);
        font-size: var(--fs-xs);
    }

    .nav-item::before {
        display: none;
    }

    #content {
        padding: var(--space-md);
    }

    .courses-grid {
        grid-template-columns: 1fr;
    }

    .analytics-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .analytics-stats-grid {
        grid-template-columns: 1fr;
    }
}