﻿/* === Collapsible Sidebar Shell (Desktop & Mobile) === */
.shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100dvh;
}

/* Lock grid placement so content never slides under the sidebar */
.sidebar {
    grid-column: 1;
}

.main {
    grid-column: 2;
}

/* Sidebar (desktop) */
.sidebar {
    position: sticky; /* fixed-on-scroll feel */
    top: 0;
    height: 100dvh;
    width: 260px;
    background: var(--card);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 12px 10px;
    transition: width .2s ease, transform .3s ease;
    overflow-y: auto;
}

    .sidebar.collapsed {
        width: 76px;
    }

/* Header row inside the sidebar */
.side-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.brand {
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 12px;
}

/* Toggle (desktop & mobile) */
.toggle {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    box-shadow: var(--shadow);
}

    .toggle .bar {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--text);
        margin: 4px 0;
    }

/* Menu links */
.menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
}

    .menu-item:hover {
        background: #f3f4f6;
    }

    .menu-item.active {
        background: #eef2ff;
        border: 1px solid #c7d2fe;
    }

    .menu-item i {
        font-size: 1rem;
        width: 20px;
        min-width: 20px;
        text-align: center;
        opacity: .8;
    }

/* Main column */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

.content {
    padding: 16px;
}

/* Visibility helpers */
.mobile-only {
    display: none;
}

.desktop-only {
    display: inline-flex;
}

/* Backdrop lives OUTSIDE .shell; never affects layout */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.4);
    z-index: 999;
    display: none;
}

    .sidebar-backdrop.visible {
        display: block;
    }

/* ===== Desktop-only rules ===== */
@media (min-width: 981px) {
    /* Make sure gray overlay never shows on desktop */
    .sidebar-backdrop {
        display: none !important;
    }
}

/* ===== Mobile (off-canvas drawer) ===== */
@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .main {
        grid-column: 1;
    }
    /* keep content in the single column on phones */

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100dvh;
        width: 260px;
        transform: translateX(-100%);
        z-index: 1000;
    }

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

        /* ignore collapsed width on phones */
        .sidebar.collapsed {
            width: 260px;
        }

    .mobile-only {
        display: inline-flex;
    }

    .desktop-only {
        display: none;
    }
}

/* Optional: pages that intentionally have no sidebar */
.no-sidebar {
    padding: 16px;
}
