/* Navigation components: hamburger, sidebar, breadcrumbs */

/* GLOBALLY DISABLE BROWSER BACK GESTURE */
html,
body {
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Hamburger menu - Liquid Glass ---------- */
.hamburger {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: none;
    cursor: pointer;
    padding: 20px;
    width: 60px;
    height: 60px;
    border-bottom: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
}

.hamburger-icon {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-color);
    position: relative;
    transition: all 0.3s ease-out;
    margin: 0 auto;
}

.hamburger-icon:before,
.hamburger-icon:after {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-color);
    position: absolute;
    transition: all 0.3s ease-out;
    left: 0;
}

.hamburger-icon:before {
    top: -6px;
}

.hamburger-icon:after {
    bottom: -6px;
}

/* Hamburger animation */
.hamburger.active .hamburger-icon {
    background: transparent !important;
}

.hamburger.active .hamburger-icon:before {
    top: 0;
    transform: rotate(45deg);
}

.hamburger.active .hamburger-icon:after {
    bottom: 0;
    transform: rotate(-45deg);
}

.hamburger.scrolled {
    box-shadow: var(--shadow);
}

/* ---------- Sidebar - macOS Floating Pill Style ---------- */
.sidebar {
    width: calc(var(--sidebar-width) - 24px);
    height: calc(100vh - 24px);
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow-elevated);
    box-sizing: border-box;
    position: fixed;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
    z-index: 1001;
}

/* Fixed header section */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    background: transparent;
}

.sidebar-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    font-size: 24px;
    width: 100%;
}

.sidebar-title:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.sidebar-logo {
    height: 120px;
    width: 120px;
    object-fit: contain;
}

.title-text {
    text-align: center;
}

.search-container {
    margin: 16px 0 0 0;
    padding: 0 4px;
}

/* Scrollable content section */
.nav-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Fixed footer section */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
    background: transparent;
    font-size: 12px;
    color: var(--breadcrumb-color);
    text-align: center;
}

.sidebar-footer .owner {
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 4px;
}

.sidebar-footer .notice {
    font-style: italic;
    line-height: 1.4;
    margin-bottom: 12px;
}

.nav-item {
    margin: 0;
    border-radius: 1rem;
}

.nav-item.directory {
    font-weight: 600;
    margin-top: 8px;
}

.nav-item.active>a {
    color: var(--nav-active-color);
    background: var(--nav-active-bg);
    border: none;
}

.nav-item.active>a:hover {
    background: var(--nav-active-bg-hover);
    color: var(--nav-active-color);
}

.nav-children {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 2px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.nav-item a {
    color: var(--text-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: .5rem;
    transition: var(--transition-smooth);
    position: relative;
    gap: 6px;
    unicode-bidi: plaintext;
    border: none;
    font-size: 14px;
}

.nav-item a:hover {
    background: var(--nav-hover-bg);
}

/* Arrow indicator */
.nav-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    padding: 4px;
    transform: rotate(-45deg);
    opacity: 0.6;
    transition: transform 0.2s ease;
}

/* Rotate arrow down when directory is expanded (active) */
.nav-item.active>a .nav-arrow {
    transform: rotate(45deg);
}

/* ---------- Breadcrumbs - Flush Top Bar ---------- */
.breadcrumbs {
    margin-bottom: 14px;
    color: var(--breadcrumb-color);
    font-size: 13px;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    padding: 12px 24px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--glass-border);
    z-index: 90;
    transition: var(--transition-smooth);
}

/* When the password warning banner is visible, push breadcrumbs below it on desktop */
body.has-password-warning .breadcrumbs {
    top: 40px;
}

.breadcrumbs-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    /* Match the inner width of .content (which has 48px left + 48px right padding) */
    max-width: calc(var(--content-max-width) - 96px);
    margin: 0;
    /* left aligned (no centering) */
    height: 48px;
}

.breadcrumbs-path {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none !important;
    /* Firefox */
    -ms-overflow-style: none !important;
    /* IE and Edge */
}

.breadcrumbs-path::-webkit-scrollbar {
    display: none !important;
    /* Chrome, Safari, Opera */
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.breadcrumbs a:hover {
    color: var(--text-color);
}

.breadcrumbs .separator {
    color: var(--text-muted);
    opacity: 0.5;
    margin: 0 2px;
}

/* Mobile responsive adjustments */
@media (max-width: 950px) {

    /* Hamburger button - flush with top bar on mobile */
    .hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 63px;
        height: 63px;
        padding: 12px;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1001;
        background: var(--bg-color);
        border: none;
        border-right: 1px solid var(--glass-border);
        border-bottom: 1px solid var(--glass-border);
        border-radius: 0;
        box-shadow: none;
        box-sizing: border-box;
    }

    /* Override global styles for password warning on mobile */
    body.has-password-warning .hamburger {
        top: 40px;
        left: 0;
    }

    /* Ensure hamburger transforms into X when sidebar is active */
    .hamburger.active {
        z-index: 1002;
    }

    /* Sidebar - slide in on mobile */
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 85vw);
        height: 100%;
        box-shadow: var(--glass-shadow-elevated);
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1001;
        border-radius: 0 16px 16px 0;
        border: none;
        border-right: 1px solid var(--glass-border);
    }

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

    /* Editor is now full-screen fixed overlay, no sidebar adjustment needed */

    body.sidebar-active {
        position: fixed;
        width: 100%;
        height: 100%;
    }

    body.sidebar-active::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 90;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    /* Mobile breadcrumbs - flush top bar */
    .breadcrumbs {
        top: 0;
        left: 63px;
        right: 0;
        padding: 0 16px;
        margin: 0;
        height: 63px;
        display: flex;
        align-items: center;
        border: none;
        border-radius: 0;
        border-bottom: 1px solid var(--glass-border);
        box-shadow: none;
        box-sizing: border-box;
        background: var(--bg-color);
    }

    .breadcrumbs-container {
        width: 100%;
        max-width: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin: 0;
        height: 63px;
        overflow-x: auto;
        scrollbar-width: none !important;
        /* Firefox */
        -ms-overflow-style: none !important;
        /* IE and Edge */
    }

    .breadcrumbs-container::-webkit-scrollbar {
        display: none !important;
        /* Chrome, Safari, Opera */
    }

    .breadcrumbs-path {
        padding: 0;
        display: flex;
        align-items: center;
        height: 100%;
        scrollbar-width: none !important;
        /* Firefox */
        -ms-overflow-style: none !important;
        /* IE and Edge */
    }

    .breadcrumbs-path::-webkit-scrollbar {
        display: none !important;
        /* Chrome, Safari, Opera */
    }

    .breadcrumbs .separator {
        margin: 0 4px;
    }

    body.has-password-warning .breadcrumbs {
        top: 40px;
    }
}

/* ---------- Dark Theme Overrides ---------- */
:root[data-theme="dark"] .breadcrumbs-path {
    scrollbar-width: none !important;
    /* Firefox */
    -ms-overflow-style: none !important;
    /* IE and Edge */
}

:root[data-theme="dark"] .breadcrumbs-path::-webkit-scrollbar {
    display: none !important;
    /* Chrome, Safari, Opera */
}