/* ==================================================
   TEMPLATE 2_1 LAYOUT
================================================== */
:root {
    --t21-primary: #334155;
    --t21-primary-strong: #1f2937;
    --t21-accent: #3b82f6;
    --t21-danger: #b91c1c;
    --t21-ink: #1f2937;
    --t21-muted: #64748b;
    --t21-line: #cbd5e1;
    --t21-soft-line: #e5eaf0;
    --t21-bg: #e8edf3;
    --t21-panel: #ffffff;
    --t21-sidebar: #2f3a4a;
    --t21-sidebar-dark: #263141;
}

body {
    background:
        linear-gradient(180deg, #eef3f8 0%, #e7edf4 42%, #e4eaf1 100%);
    color: var(--t21-ink);
}

.page-wrap {
    min-height: 100vh;
    margin-left: 216px;
    padding: 28px;
    color: var(--t21-ink);
    transition: margin-left 0.18s ease;
}

body.sidebar-collapsed .page-wrap {
    margin-left: 76px;
}

.page-inner {
    width: min(1840px, 100%);
    margin: 0 auto;
}

/* ==================================================
   LEFT NAVIGATION
================================================== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 216px;
    height: 100vh;
    z-index: 2000;
    border-right: 1px solid #d8dee8;
    background: #ffffff;
    box-shadow: none;
    transition: width 0.18s ease;
}

body.sidebar-collapsed .topbar {
    width: 76px;
}

.topbar-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.topbar-head {
    min-width: 0;
    position: relative;
    background: var(--t21-sidebar);
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 76px;
    padding: 0 18px;
    background: var(--t21-sidebar);
    color: #ffffff;
    text-decoration: none;
}

body.sidebar-collapsed .topbar-logo {
    justify-content: center;
    padding: 0;
}

.topbar-logo-mark {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    background: #ffffff;
    object-fit: cover;
}

.topbar-logo-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
}

body.sidebar-collapsed .topbar-logo-text,
body.sidebar-collapsed .topbar-item a span {
    display: none;
}

.sidebar-collapse-btn {
    position: absolute;
    right: 10px;
    bottom: -16px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #d8dee8;
    border-radius: 999px;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}

.sidebar-collapse-btn:hover {
    color: #0f172a;
    background: #f8fafc;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    right: -16px;
}

body.sidebar-collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

.topbar-left {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 10px;
}

body.sidebar-collapsed .topbar-left {
    padding: 22px 10px 12px;
}

.topbar-left::-webkit-scrollbar {
    width: 6px;
}

.topbar-left::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #cbd5e1;
}

.topbar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar-section {
    list-style: none;
}

.topbar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 30px;
    margin: 8px 0 3px;
    padding: 0 12px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    line-height: 1.2;
    text-align: left;
}

.topbar-section:first-child .topbar-section-toggle {
    margin-top: 0;
}

.topbar-section-toggle:hover {
    background: #f1f5f9;
    color: #334155;
}

.topbar-section-toggle i {
    font-size: 10px;
    transition: transform 0.15s ease;
}

.topbar-section.is-collapsed .topbar-section-toggle i {
    transform: rotate(-90deg);
}

.topbar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar-section.is-collapsed .topbar-submenu {
    display: none;
}

.topbar-item a {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #334155;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.topbar-item.is-subitem a {
    min-height: 42px;
}

body.sidebar-collapsed .topbar-item a {
    justify-content: center;
    gap: 0;
    padding: 0;
}

body.sidebar-collapsed .topbar-section-toggle {
    min-height: 8px;
    margin: 4px 0;
    padding: 0;
    pointer-events: none;
}

body.sidebar-collapsed .topbar-section-toggle span,
body.sidebar-collapsed .topbar-section-toggle i {
    display: none;
}

body.sidebar-collapsed .topbar-section.is-collapsed .topbar-submenu {
    display: flex;
}

.topbar-item a i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #f1f5f9;
    text-align: center;
    font-size: 13px;
    color: #475569;
    flex-shrink: 0;
}

.topbar-item a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-item a:hover {
    border-color: #d8e0ea;
    background: #f8fafc;
    color: #0f172a;
}

body.sidebar-collapsed .topbar-item a:hover::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    z-index: 2100;
    transform: translateY(-50%);
    padding: 8px 10px;
    border-radius: 4px;
    background: #1f2937;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

.topbar-item a:hover i {
    background: #e2e8f0;
    color: #0f172a;
}

.topbar-item.is-active a {
    border-color: #cfe0ff;
    background: #eef4ff;
    color: #0f172a;
    box-shadow: none;
}

body.sidebar-collapsed .topbar-item.is-active a {
    box-shadow: none;
}

.topbar-item.is-active a i {
    background: #dbeafe;
    color: #1d4ed8;
}

.topbar-right {
    border-top: 1px solid var(--t21-soft-line);
    padding: 10px;
}

body.sidebar-collapsed .topbar-right {
    padding: 10px;
}

.topbar-right .topbar-menu {
    gap: 0;
}

.topbar-right .topbar-item a {
    background: #f8fafc;
    color: #334155;
}

.topbar-right .topbar-item a:hover {
    border-color: #fecaca;
    background: #fef2f2;
    color: var(--t21-danger);
}

.topbar-right .topbar-item a:hover i {
    background: #fee2e2;
    color: var(--t21-danger);
}

.topbar-toggle {
    display: none;
}

.topbar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
}

@media (max-width: 760px) {
    .page-wrap {
        margin-left: 0;
        padding: 82px 14px 24px;
    }

    body.sidebar-collapsed .page-wrap {
        margin-left: 0;
    }

    .topbar-toggle {
        position: fixed;
        top: 18px;
        left: 18px;
        z-index: 2200;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border: 1px solid var(--t21-line);
        border-radius: 4px;
        background: #ffffff;
        color: var(--t21-primary);
        box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
    }

    .topbar {
        width: min(280px, 86vw);
        transform: translateX(-100%);
        transition: transform 0.24s ease;
    }

    body.sidebar-collapsed .topbar {
        width: min(280px, 86vw);
    }

    .sidebar-collapse-btn {
        display: none;
    }

    body.sidebar-collapsed .topbar-logo-text,
    body.sidebar-collapsed .topbar-item a span {
        display: inline;
    }

    body.sidebar-collapsed .topbar-section-toggle span,
    body.sidebar-collapsed .topbar-section-toggle i {
        display: inline-flex;
    }

    body.sidebar-collapsed .topbar-logo {
        justify-content: flex-start;
        padding: 0 18px;
    }

    body.sidebar-collapsed .topbar-section-toggle {
        min-height: 30px;
        margin: 8px 0 3px;
        padding: 0 12px;
        pointer-events: auto;
    }

    body.sidebar-collapsed .topbar-section.is-collapsed .topbar-submenu {
        display: none;
    }

    body.sidebar-collapsed .topbar-item a {
        justify-content: flex-start;
        gap: 10px;
        padding: 0 12px;
    }

    .topbar.is-open {
        transform: translateX(0);
    }

    .topbar.is-open + .topbar-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}
