/* ================================================================
   SANCTUARY ADMIN — Sidebar Layout  |  Material Design
   Kolombarium Parantijati Ordo Karmel
   ================================================================ */

/* ── LAYOUT SHELL ─────────────────────────────────────────────── */
body.has-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--c-bg);
}

.app-shell {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

/* ── TOPBAR ───────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--c-primary);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px 0 0;
    z-index: 1100;
    box-shadow: 0 2px 4px -1px rgba(0,0,0,0.2), 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 1.1rem;
    letter-spacing: .25px;
    color: #fff;
    text-decoration: none;
    padding: 0 16px;
    height: 100%;
    transition: background .18s;
}
.topbar-brand:hover { background: rgba(255,255,255,.07); color: #fff; }
.topbar-brand .brand-logo {
    width: 32px; height: 32px;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.topbar-toggle {
    background: none;
    border: none;
    color: #fff;
    width: 48px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border-radius: 0;
    transition: background .18s;
    flex-shrink: 0;
}
.topbar-toggle:hover { background: rgba(255,255,255,.1); }

.topbar-spacer { 
    flex: 1; 
    display: flex;
    justify-content: center;
    padding: 0 20px;
}

.topbar-search {
    background: rgba(255,255,255,.12);
    border-radius: 8px;
    height: 40px;
    width: 100%;
    max-width: 500px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    transition: background .18s, box-shadow .18s;
}
.topbar-search:focus-within {
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}
.topbar-search .search-icon {
    font-size: 20px;
    color: rgba(255,255,255,.8);
    margin-right: 8px;
}
.topbar-search:focus-within .search-icon { color: var(--c-primary); }
.topbar-search input {
    background: none;
    border: none;
    color: #fff;
    font-size: .875rem;
    width: 100%;
    height: 100%;
    outline: none;
}
.topbar-search:focus-within input { color: var(--c-text); }
.topbar-search input::placeholder { color: rgba(255,255,255,.6); }
.topbar-search:focus-within input::placeholder { color: var(--c-muted); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.topbar-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.85);
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .18s, color .18s;
    font-size: 20px;
    text-decoration: none;
}
.topbar-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 12px;
    border-radius: 24px;
    cursor: pointer;
    transition: background .18s;
    color: rgba(255,255,255,.9);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
}
.topbar-user:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
    flex-shrink: 0;
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1050;
    transition: transform .28s cubic-bezier(.4,0,.2,1), width .28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed {
    width: 60px;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 3px; }

/* Sidebar header section */
.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.sidebar-header .sidebar-app-name {
    font-size: .78rem;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .2s;
}
.sidebar.collapsed .sidebar-header .sidebar-app-name { opacity: 0; pointer-events: none; }

/* Nav sections */
.sidebar-section {
    padding: 12px 0 4px;
}
.sidebar-section-title {
    font-size: .68rem;
    font-weight: 700;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 6px 16px 6px 20px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .2s;
}
.sidebar.collapsed .sidebar-section-title { opacity: 0; }

/* Nav items */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px 10px 20px;
    color: var(--c-text);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 400;
    border-radius: 0 24px 24px 0;
    margin-right: 12px;
    transition: background .15s, color .15s;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-link .s-icon {
    flex-shrink: 0;
    font-size: 22px;
    width: 24px;
    text-align: center;
    color: var(--c-muted);
    transition: color .15s;
}
.sidebar-link .s-label {
    font-size: .875rem;
    transition: opacity .2s;
}
.sidebar-link:hover {
    background: rgba(0,0,0,.04);
    color: var(--c-primary);
}
.sidebar-link:hover .s-icon { color: var(--c-primary); }

.sidebar-link.active {
    background: var(--c-primary-glow);
    color: var(--c-primary);
    font-weight: 500;
}
.sidebar-link.active .s-icon { color: var(--c-primary); }

.sidebar.collapsed .sidebar-link {
    padding-left: 18px;
    margin-right: 0;
    border-radius: 0;
    justify-content: center;
}
.sidebar.collapsed .s-label { opacity: 0; width: 0; overflow: hidden; }

/* Tooltip on collapsed */
.sidebar.collapsed .sidebar-link[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: 64px;
    background: rgba(0,0,0,.8);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: .78rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 9999;
}
.sidebar.collapsed .sidebar-link:hover[data-label]::after { opacity: 1; }

.sidebar-divider {
    height: 1px;
    background: var(--c-border);
    margin: 6px 16px;
}

/* Sidebar footer (logout) */
.sidebar-footer {
    margin-top: auto;
    padding: 12px 0;
    border-top: 1px solid var(--c-border);
    flex-shrink: 0;
}

/* ── MAIN CONTENT ─────────────────────────────────────────────── */
.main-content {
    margin-top: 56px;
    margin-left: 260px;
    min-height: calc(100vh - 56px);
    transition: margin-left .28s cubic-bezier(.4,0,.2,1);
    padding: 28px 32px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}
body.sidebar-collapsed .main-content {
    margin-left: 60px;
}

/* ── OVERLAY (mobile) ─────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(0,0,0,.4);
    z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px !important;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
    }
    .topbar-brand-text { display: none; }
}

@media (max-width: 576px) {
    .main-content { padding: 16px 14px 40px; }
}

/* ── BADGE COUNT (notif) ───────────────────────────────────────── */
.sidebar-badge {
    margin-left: auto;
    background: var(--c-primary);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    line-height: 1.4;
    flex-shrink: 0;
}
.sidebar.collapsed .sidebar-badge { display: none; }
