/* KENCore left sidebar shell — expand / minimize / pin / mobile drawer */

:root {
    --kencore-topbar-height: 3.5rem;
    --kencore-sidebar-width-expanded: 260px;
    --kencore-sidebar-width-minimized: 3.5rem;
    --kencore-sidebar-width: var(--kencore-sidebar-width-expanded);
}

html[data-kencore-sidebar="minimized"] {
    --kencore-sidebar-width: var(--kencore-sidebar-width-minimized);
}

.kencore-app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.kencore-topbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    min-height: var(--kencore-topbar-height);
    flex-shrink: 0;
}

.kencore-topbar .container-fluid {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--kencore-topbar-height);
}

.kencore-topbar-brand {
    font-size: 1.15rem;
    white-space: nowrap;
}

.kencore-topbar-actions {
    min-width: 0;
}

.kencore-sidebar-tenant {
    padding: 0.65rem 0.75rem;
    flex-shrink: 0;
}

.kencore-sidebar-tenant-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #adb5bd;
    margin-bottom: 0.35rem;
    padding-left: 0.25rem;
}

.kencore-tenant-switcher {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
}

.kencore-tenant-select {
    width: 100%;
    max-width: 100%;
    font-size: 0.8rem;
    background-color: rgba(255, 255, 255, 0.08);
    border-color: #495057;
    color: #f8f9fa;
}

.kencore-tenant-select:focus {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: #6c757d;
    color: #f8f9fa;
    box-shadow: none;
}

.kencore-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1045;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.45);
    cursor: pointer;
}

.kencore-sidebar {
    position: fixed;
    top: var(--kencore-topbar-height);
    left: 0;
    bottom: 0;
    width: var(--kencore-sidebar-width);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.kencore-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.kencore-sidebar-link,
.kencore-sidebar-section-btn,
.kencore-sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    text-align: left;
    font-size: 0.9rem;
}

.kencore-sidebar-link:hover,
.kencore-sidebar-section-btn:hover,
.kencore-sidebar-footer-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.kencore-sidebar-link.active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-weight: 600;
}

.kencore-sidebar-icon {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.kencore-sidebar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kencore-sidebar-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.kencore-sidebar-chevron.open {
    transform: rotate(180deg);
}

.kencore-sidebar-sub {
    padding: 0.15rem 0 0.35rem 0.5rem;
}

.kencore-sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1rem 0.4rem 2rem;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.85rem;
}

.kencore-sidebar-sublink:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.kencore-sidebar-sublink.active {
    color: #fff;
    font-weight: 600;
}

.kencore-sidebar-sublink i {
    width: 1rem;
    text-align: center;
    opacity: 0.85;
}

.kencore-sidebar-footer {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.kencore-sidebar-footer-btn.active {
    color: #9ec5fe;
}

.kencore-main-region {
    flex: 1;
    margin-top: 0;
    margin-left: var(--kencore-sidebar-width);
    min-height: calc(100vh - var(--kencore-topbar-height));
    transition: margin-left 0.2s ease;
}

/* Minimized: hide labels, chevrons, sub-menus collapsed visually */
html[data-kencore-sidebar="minimized"] .kencore-sidebar-label,
html[data-kencore-sidebar="minimized"] .kencore-sidebar-chevron,
html[data-kencore-sidebar="minimized"] .kencore-sidebar-sub,
html[data-kencore-sidebar="minimized"] .kencore-sidebar-tenant {
    display: none;
}

html[data-kencore-sidebar="minimized"] .kencore-sidebar-section-btn,
html[data-kencore-sidebar="minimized"] .kencore-sidebar-link,
html[data-kencore-sidebar="minimized"] .kencore-sidebar-footer-btn {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

html[data-kencore-sidebar="minimized"] .kencore-topbar-brand-text {
    display: none;
}

/* Mobile drawer */
@media (max-width: 991.98px) {
    .kencore-sidebar {
        transform: translateX(-100%);
        width: var(--kencore-sidebar-width-expanded);
    }

    html[data-kencore-sidebar-mobile-open="true"] .kencore-sidebar {
        transform: translateX(0);
    }

    .kencore-main-region {
        margin-left: 0 !important;
    }
}
