/* Version 0 Layout CSS - Minimal container layout for left navigation + main area */
:root {
    --complex-font-base: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --complex-font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
}

body,
.main-layout,
.left-navigation,
.main-content,
.content-area,
.project-page,
.create-project-page,
.thread-page,
button,
input,
select,
textarea,
label {
    font-family: var(--font-base, var(--complex-font-base));
}

code,
pre,
.code-font {
    font-family: var(--font-mono, var(--complex-font-mono));
}

.main-layout {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-left 0.2s ease;
}

.left-navigation + .main-content {
    margin-left: var(--nav-expanded-width);
}

.left-navigation.collapsed + .main-content {
    margin-left: var(--nav-collapsed-width);
}

/* Complex left nav variant — same positioning rules */
.complex-left-nav + .main-content {
    margin-left: var(--nav-expanded-width);
}

.complex-left-nav.collapsed + .main-content {
    margin-left: var(--nav-collapsed-width);
}

.main-content header {
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
}

.content-body-hidden {
    display: none;
}

/* Global scrollbar thin styling */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.45);
    border-radius: 9999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.65);
}

*::-webkit-scrollbar-track {
    background: transparent;
}

.panel-collapse-toggle {
    border: none;
    background: transparent;
    color: #cbd5e1;
    width: 16px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s ease;
    font-size: 1.6rem;
    font-weight: 400;
    position: absolute;
    right: -2px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.panel-collapse-toggle .collapse-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: inherit;
    transition: color 0.15s ease, transform 0.15s ease;
}

    .panel-collapse-toggle:hover {
        color: #64748b;
        font-size: 1.8rem;
    }

.panel-collapse-toggle:hover .collapse-icon {
    font-size: 1.4rem;
    transform: scale(1.2);
}

/* ?? PageHeader — shared page header layout ??
 * Styles live in layout.css (global) rather than scoped CSS so that
 * RenderFragment content (Actions slot) can use page-level CSS classes
 * without Blazor CSS isolation conflicts. */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.page-header-titles {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.page-header-titles h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.page-header-subtitle {
    margin: 0;
    font-size: 0.95rem;
    color: #64748b;
    line-height: 1.4;
}

/* Complex theme overrides */
.complex-theme .page-header-titles h1 {
    color: #1c1917;
}

.complex-theme .page-header-subtitle {
    color: #57534e;
}

/* ?? Mobile floating nav toggle (FAB) ??
 * Fixed-position button, top-left. No layout impact — floats over page content.
 * Hidden on desktop. Visible ?1024px. Excluded from /threads/ pages via Blazor.
 * Hides on scroll-down, reappears on scroll-up (driven by layoutHelpers.js). */

.mobile-nav-fab {
    display: none;
}

.mobile-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    border: none;
    padding: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    cursor: pointer;
    display: none;
}

body.nav-drawer-open .mobile-drawer-overlay,
body.inspector-drawer-open .mobile-drawer-overlay {
    opacity: 1;
    pointer-events: auto;
    display: block;
}

body.nav-drawer-open,
body.inspector-drawer-open {
    overflow: hidden;
}

/* Hide the FAB when the drawer is open — the overlay + nav handle closing */
body.nav-drawer-open .mobile-nav-fab {
    opacity: 0;
    pointer-events: none;
}

/* Responsive Design for Mobile/Tablet */
@media (max-width: 1024px) {
    .main-layout {
        height: 100dvh;
    }

    /* ?? PageHeader mobile ??
     * Nav toggle is inline inside PageHeader, sitting next to the h1.
     * Align the row so toggle + title are vertically centered.
     * Hide the floating FAB when a PageHeader is present on the page. */
    .page-header {
        align-items: center;
    }

    .page-header-titles h1 {
        font-size: 1.5rem;
    }

    .main-content:has(.page-header) ~ .mobile-nav-fab,
    .main-content:has(.sub-resource-page) ~ .mobile-nav-fab {
        display: none;
    }

    /* ?? Floating nav FAB ?? */
    .mobile-nav-fab {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 0.65rem;
        left: 0.65rem;
        z-index: 1100;
        width: 36px;
        height: 36px;
        border-radius: 0.6rem;
        border: 1px solid rgba(0, 0, 0, 0.06);
        background: rgba(255, 255, 255, 0.55);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        color: #374151;
        cursor: pointer;
        padding: 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                    background 0.15s ease,
                    box-shadow 0.15s ease;
        transform: translateY(0);
    }

    .mobile-nav-fab:hover,
    .mobile-nav-fab:focus-visible {
        background: rgba(255, 255, 255, 0.8);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .mobile-nav-fab:active {
        transform: scale(0.94);
    }

    .mobile-nav-fab:focus-visible {
        outline: 2px solid #93c5fd;
        outline-offset: 2px;
    }

    /* Scroll-hidden state — slides up and fades out */
    .mobile-nav-fab.fab-hidden {
        transform: translateY(-120%);
        opacity: 0;
        pointer-events: none;
    }

    /* Complex theme variant — warm tones */
    .complex-theme .mobile-nav-fab {
        background: rgba(249, 249, 248, 0.55);
        border-color: rgba(0, 0, 0, 0.04);
        color: #1c1917;
    }

    .complex-theme .mobile-nav-fab:hover,
    .complex-theme .mobile-nav-fab:focus-visible {
        background: rgba(255, 255, 255, 0.8);
        border-color: #c2410c;
    }

    /* ?? Standard LeftNavigation — slide off-screen ?? */
    .left-navigation,
    .left-navigation.collapsed {
        width: min(90vw, var(--nav-expanded-width));
        max-width: min(90vw, var(--nav-expanded-width));
    }

    .left-navigation {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
        z-index: 1200;
    }

    body.nav-drawer-open .left-navigation {
        transform: translateX(0);
        box-shadow: 0 25px 60px rgba(15, 23, 42, 0.3);
    }

    .left-navigation + .main-content,
    .left-navigation.collapsed + .main-content {
        margin-left: 0;
    }

    .nav-chrome .collapse-toggle,
    .nav-brand-row .collapse-toggle {
        display: none;
    }

    /* ?? ComplexLeftNav — slide off-screen ?? */
    .complex-left-nav,
    .complex-left-nav.collapsed {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    body.nav-drawer-open .complex-left-nav,
    body.nav-drawer-open .complex-left-nav.collapsed {
        transform: translateX(0);
        box-shadow: 0 25px 60px rgba(15, 23, 42, 0.3);
    }

    .complex-left-nav + .main-content,
    .complex-left-nav.collapsed + .main-content {
        margin-left: 0;
    }
}
