/* ==========================================================================
   CT UNIVERSE 2-layer sidebar (rail + category panel)
   Plain CSS, no build. Replaces the legacy sb-admin-2 left menu.
   Palette: slate + blue-500/600 accent (matches the pasted spec, light theme).
   ========================================================================== */

:root {
    --ctu-hh: 64px;          /* CT UNIVERSE header height (set live by JS) */
    --ctu-rail-w: 80px;      /* module rail width */
    --ctu-cats-w: 256px;     /* category panel width (open) */
    --ctu-cats-w-collapsed: 16px;
    /* Total sidebar width. NOTE: must be resolved inline (in each real
       property) so that overriding --ctu-cats-w on body propagates here;
       a precomputed :root value would lock --ctu-cats-w at 256px. */
    --ctu-sb-w: calc(var(--ctu-rail-w) + var(--ctu-cats-w));
}

/* Keep the brand header pinned so the fixed sidebar lines up under it.
   Also drop the gray divider line/shadow under the header. */
.ctu-header {
    position: sticky;
    top: 0;
    z-index: 1050;
    border-bottom: 0;
    box-shadow: none;
}

/* Belt-and-suspenders: never let the empty legacy navbar paint a gray bar */
#navbar-top.ctu-legacy-navbar {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    height: 0;
    min-height: 0;
}

/* ---- Override the legacy sb-admin-2 sidebar shell ---- */
.ctu-legacy-navbar .navbar-default.sidebar.ctu-sb {
    position: fixed;
    left: 0;
    top: var(--ctu-hh);
    bottom: 0;
    width: calc(var(--ctu-rail-w) + var(--ctu-cats-w));
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: row;
    z-index: 1040;
    transition: transform 0.25s ease-in-out, width 0.3s ease;
}

/* Shift the page content to clear the new sidebar */
@media (min-width: 768px) {
    #page-wrapper {
        margin-left: calc(var(--ctu-rail-w) + var(--ctu-cats-w)) !important;
        transition: margin-left 0.3s ease;
    }
    body.ctu-cats-collapsed {
        --ctu-cats-w: var(--ctu-cats-w-collapsed);
    }
    /* full hide via the header hamburger (#ctu-sidebar-toggle) */
    body.sidebar-collapsed .navbar-default.sidebar.ctu-sb {
        transform: translateX(-100%);
    }
    body.sidebar-collapsed #page-wrapper {
        margin-left: 0 !important;
    }
}

/* ========================= Layer 1 — Module Rail ========================= */
.ctu-rail {
    position: relative;
    width: var(--ctu-rail-w);
    flex: 0 0 var(--ctu-rail-w);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    border-right: 1px solid #e2e8f0;       /* slate-200 */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

/* the sliding active indicator */
.ctu-rail__bar {
    position: absolute;
    left: 0;
    width: 4px;
    background: #3b82f6;                    /* blue-500 */
    border-radius: 0 9999px 9999px 0;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    transition: top 0.3s ease, height 0.3s ease, opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

.ctu-mod {
    position: relative;
    width: 100%;
    height: 72px;                          /* h-18 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: #64748b;                        /* slate-500 */
    transition: color 0.3s ease;
}
.ctu-mod:hover { color: #1e293b; }         /* slate-800 */
.ctu-mod.is-active { color: #2563eb; }     /* blue-600 */

.ctu-mod__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;                /* rounded-xl */
    transition: background 0.2s ease;
    font-size: 20px;
}
.ctu-mod:hover .ctu-mod__icon { background: #f1f5f9; }       /* slate-100 */
.ctu-mod.is-active .ctu-mod__icon { background: #dbeafe; }   /* blue-100 */

.ctu-mod__label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.03em;
}

.ctu-rail__spacer { flex: 1 1 auto; }

/* ========================= Layer 2 — Category Panel ===================== */
.ctu-cats {
    position: relative;
    width: var(--ctu-cats-w);
    flex: 0 0 var(--ctu-cats-w);
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;                    /* slate-50 */
    border-right: 1px solid #e2e8f0;
    transition: width 0.3s ease, flex-basis 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}
body.ctu-cats-collapsed .ctu-cats {
    padding-left: 0;
    padding-right: 0;
    align-items: center;
}

/* round chevron toggle that overhangs the right edge */
.ctu-cats__toggle {
    position: absolute;
    right: -12px;
    top: 24px;
    width: 24px;
    height: 24px;
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    font-size: 12px;
    transition: transform 0.15s ease;
    z-index: 50;
}
.ctu-cats__toggle:hover { transform: scale(1.1); }

.ctu-cats__inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    overflow: hidden;
    transition: opacity 0.2s ease;
}
body.ctu-cats-collapsed .ctu-cats__inner {
    opacity: 0;
    pointer-events: none;
}

.ctu-cats__title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;                        /* slate-800 */
    text-transform: capitalize;
    white-space: nowrap;
    margin: 0 0 0.75rem 0;
    padding: 0 0.5rem 0.75rem 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ctu-cats__list { display: none; flex-direction: column; gap: 0.375rem; overflow-y: auto; }
.ctu-cats__list.is-active { display: flex; }

/* category item (button or anchor) */
.ctu-cat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    border-radius: 0.5rem;
    text-align: left;
    white-space: nowrap;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: #64748b;                        /* slate-500 */
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.ctu-cat:hover { background: #f1f5f9; color: #0f172a; text-decoration: none; }
.ctu-cat.is-active {
    background: #e2e8f0;                    /* slate-200 */
    color: #0f172a;                        /* slate-900 */
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.ctu-cat__icon { flex: 0 0 auto; width: 18px; text-align: center; font-size: 16px; color: #94a3b8; }
.ctu-cat.is-active .ctu-cat__icon { color: #0f172a; }
.ctu-cat__label {
    flex: 1 1 auto;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctu-cat__badge {
    font-size: 9px;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.ctu-cat__badge--ortho { background: rgba(34,197,94,0.10); color: #16a34a; border-color: rgba(34,197,94,0.20); }
.ctu-cat__badge--3d    { background: rgba(59,130,246,0.10); color: #2563eb; border-color: rgba(59,130,246,0.20); }

.ctu-cats__empty { text-align: center; padding: 1rem; font-size: 12px; color: #94a3b8; font-style: italic; }

/* ===================== Detech workspace iframe overlay ================== */
.ctu-detech {
    position: fixed;
    left: calc(var(--ctu-rail-w) + var(--ctu-cats-w));
    top: var(--ctu-hh);
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 1030;
    display: none;
    transition: left 0.25s ease-in-out;
}
.ctu-detech.is-open { display: block; }
body.ctu-cats-collapsed .ctu-detech { /* width follows the sidebar */ }
body.sidebar-collapsed .ctu-detech { left: 0; }
.ctu-detech iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ===================== Mobile: stack/hide gracefully ==================== */
@media (max-width: 767px) {
    .ctu-legacy-navbar .navbar-default.sidebar.ctu-sb {
        position: static;
        width: 100%;
        flex-direction: column;
    }
    .ctu-rail { flex-direction: row; width: 100%; height: auto; padding: 0.25rem; }
    .ctu-rail__bar { display: none; }
    .ctu-cats { width: 100%; flex-basis: auto; }
    #page-wrapper { margin-left: 0 !important; }
    .ctu-detech { left: 0; top: auto; position: static; height: 70vh; }
}

/* ============ Carbon (base-map) iframe overlay — same as detech ============== */
#ctu-carbon {
    position: fixed;
    left: calc(var(--ctu-rail-w) + var(--ctu-cats-w));
    top: var(--ctu-hh);
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 1030;
    display: none;
    transition: left 0.25s ease-in-out;
}
#ctu-carbon.is-open { display: block; }
body.ctu-cats-collapsed #ctu-carbon { left: var(--ctu-rail-w); }
body.sidebar-collapsed #ctu-carbon { left: 0; }
#ctu-carbon iframe { width: 100%; height: 100%; border: 0; display: block; }
