/* The Case Tracker sidebar.
 *
 * PLAIN CSS, NOT TAILWIND, AND INLINE SVG, NOT AN ICON FONT. Both on purpose.
 *
 * Tailwind: activity.html and settings.html do not load it -- they are styled
 * by their own <style> blocks. A Tailwind-classed sidebar would have rendered
 * there as an unstyled list, and adding Tailwind to them would have brought
 * its preflight reset with it, changing two pages that work today. This file
 * styles the same markup everywhere regardless of what else a page loads.
 *
 * Icon font: no Case Tracker page loads one. The sister app shipped a sidebar
 * whose markup was correct and whose icons were invisible, because the page
 * that carried it never pulled Font Awesome -- labels with blank gaps, and
 * nothing in the markup to suggest why. Inline SVG cannot fail that way: if
 * the page renders, the icon renders.
 *
 * LAYOUT. The sidebar is fixed and the body gets a left margin, rather than
 * every page being rebuilt as a flex row. The six pages have four different
 * body styles between them (Tailwind padding utilities on two, custom CSS on
 * two, neither on the rest), and margin is the one property none of them set,
 * so this adds the sidebar without touching any page's own layout.
 */

:root {
    --ct-sidebar-width: 15rem;
}

body.ct-has-sidebar {
    /* margin, not padding: two pages set their padding with Tailwind
     * utilities, whose class specificity would beat a bare element rule. */
    margin-left: var(--ct-sidebar-width);
}

.ct-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--ct-sidebar-width);
    background: #0f172a;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 40;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

.ct-sidebar__brand {
    padding: 1.4rem 1.25rem 1rem;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.ct-sidebar__brand span {
    color: #3b82f6;
}

.ct-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0 0.6rem;
    flex-grow: 1;
}

.ct-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    color: #cbd5e1;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

.ct-sidebar__link:hover {
    background: #1e293b;
    color: #fff;
}

.ct-sidebar__link svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.ct-sidebar__link--current {
    background: rgba(37, 99, 235, 0.12);
    border-right: 3px solid #3b82f6;
    color: #60a5fa;
    font-weight: 600;
}

/* Logout sits apart: it ends the session rather than navigating, and putting
 * it in the same run of links invites a mis-click on the way to Settings. */
.ct-sidebar__footer {
    padding: 0.6rem;
    border-top: 1px solid #1e293b;
    margin-top: auto;
}

.ct-sidebar__link--logout {
    color: #fca5a5;
}

.ct-sidebar__link--logout:hover {
    background: #7f1d1d;
    color: #fff;
}

/* Narrow screens: the sidebar becomes an ordinary block at the top of the
 * document rather than a fixed overlay sitting on top of the content. */
@media (max-width: 820px) {
    body.ct-has-sidebar {
        margin-left: 0;
    }

    .ct-sidebar {
        position: static;
        width: 100%;
        bottom: auto;
        border-right: 0;
        border-bottom: 1px solid #1e293b;
    }

    .ct-sidebar__nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding-bottom: 0.6rem;
    }

    .ct-sidebar__footer {
        border-top: 0;
        margin-top: 0;
    }
}

/* View switching on the entry page (see views.js).
 *
 * !important, and a class rather than the `hidden` attribute, because the
 * elements being hidden carry Tailwind display utilities: the entry header and
 * the form are both `flex`. `.flex { display: flex }` and the browser's
 * `[hidden] { display: none }` have equal specificity, and Tailwind's
 * stylesheet comes later, so it wins -- setting el.hidden on them did nothing
 * at all and both views rendered on top of each other.
 */
.ct-view-hidden {
    display: none !important;
}
