/* ============================================================
   APNA LIBRARY — Modern SPA Sidebar Layout
   ============================================================ */

:root {
    --sb-w:        260px;          /* sidebar width */
    --tb-h:        52px;           /* topbar height */
    --sb-bg:       #0c1220;
    --sb-border:   rgba(0,188,212,0.10);
    --sb-hover:    rgba(0,188,212,0.07);
    --sb-active-bg:rgba(0,188,212,0.13);
    --sb-active-c: #00d4ff;
    --sb-text:     #b8cce0;
    --sb-muted:    #3d5570;
    --sb-accent:   #00bcd4;
    --tb-bg:       rgba(8,14,28,0.97);
    --content-bg:  transparent;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body.lib-body {
    margin: 0; padding: 0;
    background: #060c1a;
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Mountain background */
body.lib-body::before {
    content: '';
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse at 70% 0%,   rgba(20,40,90,.9)  0%, transparent 55%),
        radial-gradient(ellipse at 50% 38%,  rgba(140,65,15,.4) 0%, transparent 50%),
        radial-gradient(ellipse at 25% 58%,  rgba(8,32,70,.85)  0%, transparent 50%),
        radial-gradient(ellipse at 75% 55%,  rgba(10,28,65,.85) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 88%,  rgba(4,10,30,.95)  0%, transparent 65%),
        linear-gradient(180deg,#030608 0%,#060d1c 20%,#091525 45%,#060d1c 70%,#030608 100%);
    background-attachment: fixed;
}
body.lib-body::after {
    content: '';
    position: fixed; top:28%; left:50%;
    transform: translateX(-50%);
    width: 80vw; height: 20vh;
    background: radial-gradient(ellipse, rgba(180,85,15,.14) 0%, transparent 70%);
    z-index: 0; pointer-events: none; filter: blur(10px);
}

#app-wrapper { position: relative; z-index: 1; }

/* Mobile overlay */
.lib-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.65); z-index: 998;
    backdrop-filter: blur(3px);
}
.lib-overlay.open { display: block; }

/* ── SIDEBAR ─────────────────────────────────────────── */
.lib-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sb-w);
    height: 100vh;
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex; flex-direction: column;
    z-index: 999;
    overflow: hidden;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    box-shadow: 2px 0 40px rgba(0,0,0,.5);
}
@media (max-width: 991px) {
    .lib-sidebar { transform: translateX(-100%); }
    .lib-sidebar.open { transform: translateX(0); }
}

/* ── Sidebar Logo ────────────────────────────────────── */
.lib-sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0; min-height: var(--tb-h);
    background: rgba(0,0,0,.2);
}
.lib-logo-icon {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg,#00bcd4,#0097a7);
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem; font-weight: 800; color: #000;
    flex-shrink: 0; letter-spacing: .3px;
    box-shadow: 0 2px 12px rgba(0,188,212,.3);
}
.lib-logo-text { flex: 1; min-width: 0; }
.lib-logo-name {
    font-size: .8rem; font-weight: 700; color: var(--sb-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    letter-spacing: .3px;
}
.lib-logo-sub { font-size: .62rem; color: var(--sb-muted); margin-top: 1px; }
.lib-sidebar-close {
    background: none; border: none;
    color: var(--sb-muted); font-size: .9rem; cursor: pointer;
    padding: 4px; flex-shrink: 0;
}

/* ── Nav Scroll Area ─────────────────────────────────── */
.lib-nav {
    flex: 1; overflow-y: auto;
    padding: 6px 0 20px;
}
.lib-nav::-webkit-scrollbar { width: 3px; }
.lib-nav::-webkit-scrollbar-thumb {
    background: rgba(0,188,212,.15); border-radius: 2px;
}

/* Section label */
.lib-nav-section {
    padding: 12px 16px 3px;
    font-size: .59rem; font-weight: 700;
    letter-spacing: 1.8px; text-transform: uppercase;
    color: var(--sb-muted);
}

/* ── Nav Group (collapsible) ─────────────────────────── */
.lib-nav-group { margin: 1px 0; }

.lib-nav-group-header {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; margin: 1px 8px;
    border-radius: 9px;
    color: var(--sb-text);
    font-size: .85rem; font-weight: 600;
    cursor: pointer; user-select: none;
    transition: background .15s, color .15s;
    position: relative;
}
.lib-nav-group-header:hover {
    background: var(--sb-hover);
    color: #d0e4f4;
}
.lib-nav-group-header.open {
    color: var(--sb-accent);
    background: rgba(0,188,212,.06);
}
.lib-nav-group-icon {
    width: 30px; height: 30px; border-radius: 7px;
    background: rgba(255,255,255,.05);
    display: flex; align-items: center; justify-content: center;
    font-size: .82rem; flex-shrink: 0;
    transition: background .2s, color .2s;
}
.lib-nav-group-header.open .lib-nav-group-icon {
    background: rgba(0,188,212,.15);
    color: var(--sb-accent);
}
.lib-nav-group-label { flex: 1; }
.lib-nav-group-arrow {
    font-size: .65rem; color: var(--sb-muted);
    transition: transform .25s;
    flex-shrink: 0;
}
.lib-nav-group-header.open .lib-nav-group-arrow {
    transform: rotate(180deg);
    color: var(--sb-accent);
}

/* Sub-items container */
.lib-nav-sub {
    overflow: hidden;
    max-height: 0;
    transition: max-height .28s cubic-bezier(.4,0,.2,1);
    padding-left: 8px;
}
.lib-nav-sub.open { max-height: 400px; }

/* ── Sub Item ────────────────────────────────────────── */
.lib-nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px 7px 12px;
    margin: 1px 8px 1px 14px;
    border-radius: 8px;
    color: var(--sb-muted);
    text-decoration: none; font-size: .83rem;
    cursor: pointer; transition: background .15s, color .15s;
    position: relative;
    border: none; background: none; width: calc(100% - 22px);
    text-align: left;
}
.lib-nav-item:hover {
    background: var(--sb-hover);
    color: var(--sb-text);
    text-decoration: none;
}
.lib-nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-c);
    font-weight: 600;
}
.lib-nav-item.active::before {
    content: '';
    position: absolute; left: -4px; top: 6px; bottom: 6px;
    width: 3px; background: var(--sb-active-c);
    border-radius: 0 2px 2px 0;
}
.lib-nav-item-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--sb-muted); flex-shrink: 0;
    transition: background .15s;
    display: none;  /* hidden — icons used instead */
}
.lib-nav-item.active .lib-nav-item-dot,
.lib-nav-item:hover .lib-nav-item-dot { background: var(--sb-accent); }

/* Single-level nav item (no group) */
.lib-nav-direct {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; margin: 1px 8px;
    border-radius: 9px;
    color: var(--sb-text);
    text-decoration: none; font-size: .85rem;
    cursor: pointer; transition: background .15s, color .15s;
    position: relative; border: none; background: none;
    width: calc(100% - 16px); text-align: left;
}
.lib-nav-direct:hover {
    background: var(--sb-hover); color: #d0e4f4;
    text-decoration: none;
}
.lib-nav-direct.active {
    background: var(--sb-active-bg); color: var(--sb-active-c);
    font-weight: 600;
}
.lib-nav-direct.active::before {
    content: '';
    position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 3px; background: var(--sb-active-c);
    border-radius: 0 2px 2px 0;
}
.lib-nav-direct-icon {
    width: 30px; height: 30px; border-radius: 7px;
    background: rgba(255,255,255,.05);
    display: flex; align-items: center; justify-content: center;
    font-size: .82rem; flex-shrink: 0; transition: all .2s;
}
.lib-nav-direct.active .lib-nav-direct-icon {
    background: rgba(0,188,212,.15); color: var(--sb-accent);
}

.lib-nav-divider { height:1px; background:var(--sb-border); margin:8px 14px; }

/* Logout */
.lib-nav-logout { color: rgba(255,82,82,.7) !important; }
.lib-nav-logout:hover { background: rgba(255,82,82,.08) !important; color:#ff5252 !important; }
.lib-nav-logout .lib-nav-direct-icon { background: rgba(255,82,82,.08) !important; color: #ff5252 !important; }

/* Sidebar footer */
.lib-sidebar-footer {
    padding: 8px 14px; font-size: .65rem;
    color: var(--sb-muted);
    border-top: 1px solid var(--sb-border); flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
}

/* ── MAIN ────────────────────────────────────────────── */
.lib-main {
    margin-left: var(--sb-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
    transition: margin-left .3s;
}
@media (max-width: 991px) { .lib-main { margin-left: 0; } }

/* ── TOPBAR ──────────────────────────────────────────── */
.lib-topbar {
    height: var(--tb-h);
    background: var(--tb-bg);
    border-bottom: 1px solid var(--sb-border);
    display: flex; align-items: center;
    padding: 0 16px; gap: 10px;
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.lib-hamburger {
    background: none; border: none;
    color: var(--sb-muted); font-size: 1.05rem;
    cursor: pointer; padding: 6px; border-radius: 6px;
    transition: color .2s; flex-shrink: 0;
}
.lib-hamburger:hover { color: var(--sb-accent); }

.lib-topbar-breadcrumb {
    flex: 1;
    display: flex; align-items: center; gap: 6px;
    font-size: .82rem; color: var(--sb-muted);
    min-width: 0;
}
.lib-topbar-breadcrumb .crumb-page {
    color: var(--sb-text); font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-topbar-breadcrumb .crumb-sep { color: var(--sb-muted); font-size: .75rem; }

.lib-topbar-right {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.lib-tb-btn {
    width: 30px; height: 30px; border-radius: 8px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--sb-border);
    color: var(--sb-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: .82rem; text-decoration: none; cursor: pointer;
    transition: all .2s;
}
.lib-tb-btn:hover { background: rgba(0,188,212,.1); color: var(--sb-accent); }
.lib-tb-logout:hover { background: rgba(255,82,82,.1) !important; color: #ff5252 !important; }
.lib-tb-sep { width:1px; height:20px; background:var(--sb-border); margin:0 2px; }

.lib-tb-user {
    display: flex; align-items: center; gap: 7px;
    padding: 3px 10px 3px 4px;
    border-radius: 20px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--sb-border);
    cursor: default;
}
.lib-tb-avatar {
    width: 26px; height: 26px; border-radius: 7px;
    background: linear-gradient(135deg,#00bcd4,#0097a7);
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 800; color: #000; flex-shrink: 0;
}
.lib-tb-uname { font-size: .76rem; font-weight: 600; color: var(--sb-text); }

/* ── CONTENT AREA ────────────────────────────────────── */
.lib-content {
    flex: 1;
    padding: 18px 20px;
    min-height: calc(100vh - var(--tb-h));
}

/* ── Toast ───────────────────────────────────────────── */
.lib-toast {
    background: rgba(10,18,38,.97);
    border: 1px solid var(--sb-border);
    border-radius: 10px; padding: 10px 16px;
    font-size: .84rem; color: var(--sb-text);
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4); min-width: 200px;
    backdrop-filter: blur(12px);
}
.lib-toast.success { border-color: rgba(0,230,118,.35); }
.lib-toast.success i { color: #00e676; }
.lib-toast.error   { border-color: rgba(255,82,82,.35); }
.lib-toast.error   i { color: #ff5252; }

/* ── scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,188,212,.25); border-radius: 3px; }
