/* ===== Navbar ===== */
.navbar-custom {
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 10px),
        linear-gradient(135deg, rgba(30, 64, 215, 0.92) 0%, rgba(60, 90, 235, 0.88) 70%, rgba(85, 150, 245, 0.8) 100%);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    height: var(--header-height);
    box-shadow: 0 4px 20px rgba(40, 70, 220, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transition: transform .3s ease;
}
.navbar-custom .navbar-brand {
    color: #fff;
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.navbar-custom .navbar-brand i {
    display: inline-block;
    color: #fff;
    transition: transform .4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.navbar-custom .navbar-brand:hover i {
    transform: rotate(15deg) scale(1.15);
}
.navbar-custom .nav-link { 
    color: rgba(255,255,255,0.85); 
    font-weight: 600;
    padding: .45rem 1rem;
    margin: 0 .25rem;
    border-radius: 8px;
    transition: all .25s ease;
    position: relative;
}
.navbar-custom .nav-link i {
    transition: transform .25s ease;
    display: inline-block;
}
.navbar-custom .nav-link:hover { 
    color: #fff; 
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.navbar-custom .nav-link:hover i {
    transform: scale(1.1);
}
.navbar-custom .search-box { max-width: 320px; }
.navbar-custom .search-box .form-control {
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding-left: 36px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    transition: all .3s ease;
    box-shadow: none;
}
.navbar-custom .search-box .form-control::placeholder { color: rgba(255,255,255,0.6); }
.navbar-custom .search-box .form-control:focus {
    background: #fff;
    color: #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: transparent;
}
.navbar-custom .search-box .search-icon {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.7);
    pointer-events: none; z-index: 5;
}
.navbar-custom .search-box .form-control:focus ~ .search-icon { color: var(--primary); }
.navbar-action-group {
    flex-wrap: nowrap;
    min-width: 0;
}
.navbar-login-btn,
.navbar-user-toggle {
    flex-shrink: 1;
    white-space: nowrap;
}
.navbar-user-toggle {
    display: inline-flex;
    align-items: center;
    gap: .15rem;
    max-width: 100%;
}
.navbar-user-name {
    display: inline-block;
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}
@media (max-width: 991.98px) {
    .navbar-user-name {
        display: none;
    }
}

.theme-toggle-btn {
    background: transparent;
    border: none;
    color: #fff;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .2s;
    font-size: 1.1rem;
    padding: 0;
    border-radius: 50%;
}
.theme-toggle-btn:hover {
    background: rgba(255,255,255,.15);
}

/* Module Tabs */
.module-tabs { display: flex; gap: 4px; margin-left: 24px; }
.module-tab {
    color: rgba(255,255,255,.6); text-decoration: none; font-size: .85rem; font-weight: 500;
    padding: 4px 14px; border-radius: 20px; transition: all .2s; white-space: nowrap;
}
.module-tab:hover { color: #fff; background: rgba(255,255,255,.12); }
.module-tab.active { color: #fff; background: rgba(255,255,255,.2); }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: var(--header-height);
    left: 0; bottom: 0;
    background: var(--bg-sidebar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 1025;
    transition: transform .3s ease, background .3s, border-color .3s;
    padding-top: 0;
}
.sidebar-search {
    position: sticky; top: 0; z-index: 2;
    padding: 12px 14px 8px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    transition: background .3s, border-color .3s;
}
.sidebar-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-search-input-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}
.sidebar-search-inner--draw {
    justify-content: flex-end;
}
.sidebar-search--draw-only {
    padding-top: 10px;
    padding-bottom: 10px;
}
.sidebar-search .form-control {
    border-radius: 18px;
    padding-left: 32px;
    font-size: .85rem;
    background: var(--bg-sidebar-search);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.sidebar-search .form-control:focus {
    background: var(--bg-card);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 .15rem rgba(var(--primary-rgb),.15);
}
.sidebar-search-icon {
    position: absolute; left: 10px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: .8rem; pointer-events: none;
}
.sidebar .nav-link.search-hidden,
.sidebar .nav-category.search-hidden { display: none !important; }
.sidebar .nav-category {
    font-size: .72rem; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: .45rem 1rem;
    margin-top: .5rem;
    cursor: default;
}
.sidebar .nav-link {
    color: var(--text-primary);
    padding: .45rem 1rem .45rem 1.5rem;
    margin: 0.15rem 0.5rem;
    font-size: .86rem; 
    border-radius: 8px;
    display: flex; align-items: center; gap: .5rem;
    position: relative;
    transition: all .35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.sidebar .nav-link > * {
    position: relative;
    z-index: 2;
}

.sidebar .nav-link::before {
    content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 0;
    background: rgba(var(--primary-rgb), 0.06); border-radius: 8px; z-index: -1;
    transition: width .4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .nav-link::after {
    content: ''; position: absolute; bottom: 0; left: 0;
    width: 4px; height: 0; background: var(--primary); border-radius: 4px;
    opacity: 0; transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(var(--primary-rgb), 0.4);
    z-index: 0;
    pointer-events: none;
}

.sidebar .nav-link i { width: 20px; text-align: center; color: var(--text-muted); transition: all .35s cubic-bezier(0.4, 0, 0.2, 1); position: relative; z-index: 2; }

.sidebar .nav-link:hover { color: var(--primary); transform: translateX(4px); }
.sidebar .nav-link:hover::before { width: 100%; }
.sidebar .nav-link:hover:not(.active)::after { height: 16px; opacity: 1; left: 0; bottom: 50%; transform: translateY(50%) rotate(0deg); }
.sidebar .nav-link:hover i { color: var(--primary); transform: scale(1.1); }

.sidebar .nav-link.active { color: var(--primary); font-weight: 600; transform: translateX(0); }
.sidebar .nav-link.active::before { width: 100%; background: rgba(var(--primary-rgb), 0.1); }
.sidebar .nav-link.active::after { 
    opacity: 1; 
    left: calc(100% - 16px); 
    width: 7px; 
    height: 7px; 
    border-radius: 1.5px;
    bottom: 50%;
    animation: fluidSlideBottom 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.sidebar .nav-link.active i { color: var(--primary); }

@keyframes fluidSlideBottom {
    0% {
        left: 0; bottom: 50%; width: 4px; height: 16px; border-radius: 4px;
        transform: translateY(50%) rotate(0deg);
        box-shadow: 0 0 8px rgba(var(--primary-rgb), 0.4);
    }
    15% {
        left: 0; bottom: 0; width: 8px; height: 2px; border-radius: 2px;
        transform: translateY(0) rotate(0deg);
        box-shadow: 0 0 4px rgba(var(--primary-rgb), 0.2);
    }
    45% {
        left: 0; bottom: 0; width: 100%; height: 2px; border-radius: 2px;
        transform: translateY(0) rotate(0deg);
        box-shadow: 0 0 4px rgba(var(--primary-rgb), 0.2);
    }
    70% {
        left: calc(100% - 16px); bottom: 0; width: 4px; height: 2px; border-radius: 2px;
        transform: translateY(0) rotate(0deg);
        box-shadow: 0 0 4px rgba(var(--primary-rgb), 0.2);
    }
    100% {
        left: calc(100% - 16px); bottom: 50%; width: 7px; height: 7px; border-radius: 1.5px;
        transform: translateY(50%) rotate(-315deg);
        box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.8);
    }
}

/* ===== Sidebar Resize Handle ===== */
.sidebar-resize-handle {
    position: fixed;
    top: var(--header-height); bottom: 0;
    left: var(--sidebar-width);
    width: 5px;
    cursor: col-resize;
    z-index: 101;
    background: transparent;
    transition: background .15s;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
    background: var(--primary);
    opacity: .35;
}
.sidebar .nav-link i { width: 20px; text-align: center; color: var(--text-muted); transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); }

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 1.25rem; flex: 1;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left .3s ease, margin-top .3s ease;
    animation: contentBreathIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    z-index: 1;
}
@keyframes contentBreathIn {
    0%   { opacity: 0; transform: translateY(15px) scale(0.99); }
    100% { opacity: 1; transform: none; }
}

/* ===== Footer ===== */
.footer {
    margin-left: var(--sidebar-width);
    padding: 1rem; text-align: center;
    font-size: .8rem; color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    background: linear-gradient(to top, rgba(240, 244, 255, 0.8) 0%, rgba(255, 255, 255, 0.4) 100%);
    transition: margin-left .3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background .3s, border-color .3s;
}

/* ===== Site Version Badge ===== */
.site-version {
    font-size: .55rem;
    font-weight: 400;
    opacity: .7;
    vertical-align: super;
    display: inline-block;
    min-width: 2rem;
}

/* ===== Footer Helpers ===== */
.footer-icp { margin-top: 4px; }
.footer-icp-link { color: inherit; text-decoration: none; }

/* ===== Mobile ===== */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 1020;
}

.navbar-custom .navbar-brand {
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 180px);
}

@media (max-width: 991.98px) {
    body.sidebar-open { overflow: hidden; }
    .sidebar {
        transform: translateX(-100%);
        background: rgba(255, 255, 255, 0.82);
    }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; padding: 1rem .75rem; z-index: 0; }
    .footer { margin-left: 0; }
    .sidebar-module-switch {
        top: 0;
        z-index: 4;
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }
    .sidebar-search {
        top: 56px;
        z-index: 3;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.82));
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 8px 18px rgba(67, 97, 238, 0.06);
    }
    .sidebar .nav-category {
        position: relative;
        z-index: 1;
    }
    .row > [class*="col-lg-6"] { width: 100%; }
}

@media (max-width: 767.98px) {
    .module-tabs { display: none !important; }
    .row > .col-md-6 { width: 100%; }
}

@media (max-width: 575.98px) {
    .main-content { padding: .75rem .5rem; }
    .navbar-custom .navbar-brand {
        font-size: 1rem;
        max-width: calc(100vw - 160px);
    }
    #siteVersion { display: none; }
    .navbar-custom {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }
    .navbar-action-group {
        gap: .35rem !important;
    }
    .navbar-login-btn {
        padding: .28rem .55rem;
        min-width: 2.1rem;
    }
    .navbar-login-btn i {
        margin-right: 0 !important;
    }
    #userLoggedArea {
        gap: .35rem !important;
        min-width: 0;
    }
    .navbar-user-toggle {
        gap: .12rem;
    }
    .navbar-user-name {
        display: none;
    }
    #navVipBadge {
        margin-left: .15rem !important;
    }
}

/* Sidebar module switch (mobile) */
.sidebar-module-switch {
    display: flex; gap: 8px; padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    position: sticky; top: 0; z-index: 2;
}
.smw-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 6px; padding: 8px 10px; border-radius: 10px;
    text-decoration: none; font-size: .88rem; font-weight: 600;
    color: var(--text-muted); background: var(--bg-sidebar-search);
    border: 1px solid var(--border-color);
    transition: all .18s;
}
.smw-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.smw-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.smw-btn i { font-size: 1rem; }

/* ===== Sidebar Collapse (Desktop，与搜索框同行 sticky，滚动列表时仍可见) ===== */
.sidebar-collapse-btn {
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: var(--bg-sidebar-search);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    transition: background .2s, color .2s, border-color .2s;
}
.sidebar-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--primary);
    border-color: var(--primary);
}
.sidebar-expand-btn {
    display: none !important;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1060;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: .9rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    transition: background .2s, color .2s;
}
.sidebar-expand-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .sidebar-resize-handle { display: none !important; }
body.sidebar-collapsed .main-content { margin-left: 0; margin-top: 0; padding-top: 12px; }
body.sidebar-collapsed .footer { margin-left: 0; }
body.sidebar-collapsed #mainNavbar { transform: translateY(-100%); }
body.sidebar-collapsed .sidebar-expand-btn { display: flex !important; }
