﻿/* ===== FontAwesome fallback handling ===== */
.emoji-fallback {
    display: none;
}

.fa-fallback-hide {
    display: inline-block;
}

/* ===== Desktop Sidebar ===== */
.lp-sidebar-desktop {
    position: fixed !important;
    top: 100px;
    left: 0;
    z-index: 900;
    display: flex;
    align-items: stretch;
    height: 85vh;
    max-height: calc(100vh - 120px);
    min-height: 340px;
}

@media (max-width: 900px) {
    .lp-sidebar-desktop {
        display: none;
    }
}

.lp-sidebar-tab {
    display: none;
    width: 18px;
    min-width: 18px;
    background: rgba(124, 58, 237, 0.85);
    border: none;
    cursor: pointer;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: #fff;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    border-radius: 0 8px 8px 0;
    box-shadow: 3px 0 8px rgba(0,0,0,0.15);
    transition: width 0.25s ease, opacity 0.25s ease;
    opacity: 0;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

.lp-sidebar-desktop.collapsed .lp-sidebar-tab {
    display: flex;
    opacity: 1;
}

/* ===== Auto-hide behavior (hover-based, mirrors top bar auto-hide) ===== */
html.sidebar-autohide .lp-sidebar-desktop .lp-sidebar-tab {
    display: flex;
    opacity: 1;
}

html.sidebar-autohide .lp-sidebar-desktop .lp-sidebar-panel {
    transform: translateX(-100%);
    opacity: 0;
    width: 0;
    pointer-events: none;
}

html.sidebar-autohide.sidebar-visible .lp-sidebar-desktop .lp-sidebar-panel {
    transform: translateX(0);
    opacity: 1;
    width: 260px;
    pointer-events: auto;
}

.lp-sidebar-tab-text {
    white-space: nowrap;
}

.lp-sidebar-panel {
    width: 260px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 0 16px 16px 0;
    box-shadow: 6px 6px 16px rgba(80, 90, 110, 0.18), -2px -2px 8px rgba(255,255,255,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease;
}

.lp-sidebar-desktop.collapsed .lp-sidebar-panel {
    transform: translateX(-100%);
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.lp-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.lp-sidebar-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.lp-sidebar-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #555;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.lp-sidebar-collapse-btn:hover {
    background: rgba(0,0,0,0.06);
}

.lp-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.lp-sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lp-sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    text-decoration: none;
    color: #d9363e;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}

.lp-sidebar-logout:hover {
    background: rgba(217, 54, 62, 0.1);
}

html.dark .lp-sidebar-footer {
    border-top-color: rgba(255,255,255,0.1);
}

html.dark .lp-sidebar-logout {
    color: #ff6b6b;
}

html.dark .lp-sidebar-logout:hover {
    background: rgba(255, 107, 107, 0.15);
}

/* ===== Top level items ===== */
.sidebar-toplevel {
    display: flex;
    flex-direction: column;
}

.sidebar-toplevel-toggle,
.sidebar-toplevel-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    color: #2b2b2b;
    text-decoration: none;
    transition: background 0.2s ease;
}

.sidebar-toplevel-toggle:hover,
.sidebar-toplevel-link:hover {
    background: rgba(124, 58, 237, 0.08);
}

.sidebar-toplevel-link.active {
    background: rgba(124, 58, 237, 0.15);
    font-weight: 600;
}

.sidebar-toplevel-icon {
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-toplevel-label {
    flex: 1;
}

.sidebar-toplevel-chevron {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.sidebar-toplevel-chevron.expanded {
    transform: rotate(180deg);
}

/* ===== Nested submenu (any depth) ===== */
.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-submenu.expanded {
    max-height: 800px;
}

.sidebar-node-toggle,
.sidebar-node-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem 0.5rem 2rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
    color: #3a3a3a;
    text-decoration: none;
    transition: background 0.2s ease;
}

.sidebar-node-toggle:hover,
.sidebar-node-link:hover {
    background: rgba(124, 58, 237, 0.08);
}

.sidebar-node-link.active {
    background: rgba(124, 58, 237, 0.15);
    font-weight: 600;
}

.sidebar-node .sidebar-submenu li .sidebar-node-toggle,
.sidebar-node .sidebar-submenu li .sidebar-node-link {
    padding-left: 3rem;
}

.sidebar-node-icon {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-node-label {
    flex: 1;
}

.sidebar-node-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.sidebar-node-chevron.expanded {
    transform: rotate(90deg);
}

/* ===== Mobile bottom-up sidebar ===== */
.lp-sidebar-mobile {
    display: none;
}

@media (max-width: 900px) {
    .lp-sidebar-mobile {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 950;
    }

    /* Reserve space for the fixed mobile sidebar tab bar (28px) plus safe-area
       inset so page content/buttons aren't hidden underneath it and remain tappable. */
    .apple-main {
        padding-bottom: calc(1rem + 28px + env(safe-area-inset-bottom, 0px));
    }
}

.lp-sidebar-mobile-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 28px;
    background: rgba(124, 58, 237, 0.9);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -3px 8px rgba(0,0,0,0.2);
}

.lp-sidebar-mobile-tab i,
.lp-sidebar-mobile-tab .emoji-fallback {
    transition: transform 0.25s ease;
}

.lp-sidebar-mobile-tab i.flipped,
.lp-sidebar-mobile-tab .emoji-fallback.flipped {
    transform: rotate(180deg);
}

.lp-sidebar-mobile-panel {
    max-height: 0;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    transition: max-height 0.3s ease;
}

.lp-sidebar-mobile.open .lp-sidebar-mobile-panel {
    max-height: 60vh;
}
