/* =================================================================
   DMS Sidebar
   Restrained · monochrome · alive
   ================================================================= */
:root {
    --sb-w:          260px;
    --sb-ink:        #0f172a;
    --sb-ink-2:      #475569;
    --sb-ink-3:      #64748b;
    --sb-ink-4:      #94a3b8;
    --sb-surface:    #ffffff;
    --sb-surface-2:  #f6f8fb;
    --sb-surface-3:  #eef2f7;
    --sb-border:     rgb(15 23 42 / .07);
    --sb-border-2:   rgb(15 23 42 / .12);
    --sb-accent:     #1d4ed8;
    --sb-accent-2:   #2563eb;
    --sb-accent-soft:rgb(29 78 216 / .08);
    --sb-accent-line:rgb(29 78 216 / .22);
    --sb-success:    #16a34a;
    --sb-mono:       'JetBrains Mono', 'Fira Code', Consolas, monospace;
    --sb-radius:     10px;
    --sb-shadow-r:   1px 0 0 var(--sb-border);
}

/* Reserve space — pages already use ml-64; keep 256px (16rem) */
.dms-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 16rem;
    height: 100vh;
    background: var(--sb-surface);
    box-shadow: var(--sb-shadow-r);
    display: flex;
    flex-direction: column;
    z-index: 30;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    /* On-load reveal */
    animation: sbSlideIn .5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes sbSlideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }

/* ============================
   BRAND
   ============================ */
.dms-sidebar-brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 16px 14px;
}
.brand-link {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none;
    transition: transform .15s ease;
}
.brand-link:hover { transform: translateX(1px); }
.brand-mark {
    position: relative;
    width: 32px; height: 32px;
    border-radius: 9px;
    background: linear-gradient(180deg, #0f172a 0%, #020617 100%);
    box-shadow: 0 4px 12px -4px rgba(15,23,42,.45), inset 0 0 0 1px rgba(255,255,255,.08);
    display: inline-flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.brand-mark-text {
    position: relative; z-index: 1;
    color: #fff;
    font-size: 12px; font-weight: 700;
    letter-spacing: -0.02em;
    font-feature-settings: 'cv11';
}
.brand-mark-glow {
    position: absolute; inset: 0;
    background: linear-gradient(120deg, transparent 25%, rgba(255,255,255,.18) 50%, transparent 75%);
    transform: translateX(-110%);
    animation: sbShine 4.2s ease-in-out infinite;
    animation-delay: 1.2s;
}
@keyframes sbShine {
    0%, 35% { transform: translateX(-110%); }
    65%, 100% { transform: translateX(110%); }
}
.brand-text { display: inline-flex; flex-direction: column; line-height: 1.05; }
.brand-name {
    font-size: 15px; font-weight: 600;
    color: var(--sb-ink);
    letter-spacing: -0.02em;
}
.brand-sub {
    font-size: 10.5px;
    color: var(--sb-ink-3);
    margin-top: 1px;
    letter-spacing: 0;
}
.brand-env {
    font-size: 9.5px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--sb-accent-soft);
    color: var(--sb-accent);
    box-shadow: inset 0 0 0 1px var(--sb-accent-line);
    font-family: var(--sb-mono);
}

/* ============================
   SEARCH
   ============================ */
.dms-sidebar-search {
    position: relative;
    margin: 0 12px 10px;
    display: flex; align-items: center;
}
.dms-sidebar-search input {
    width: 100%;
    background: var(--sb-surface-2);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 60px 8px 30px;
    font-size: 12.5px;
    color: var(--sb-ink);
    font-family: inherit;
    transition: all .18s ease;
    box-shadow: inset 0 0 0 1px var(--sb-border);
}
.dms-sidebar-search input::placeholder { color: var(--sb-ink-4); }
.dms-sidebar-search input:focus {
    outline: none;
    background: #fff;
    border-color: var(--sb-accent-2);
    box-shadow: inset 0 0 0 1px var(--sb-accent-2), 0 0 0 3px rgb(37 99 235 / .12);
}
.dms-sidebar-search input:focus::placeholder { color: var(--sb-ink-3); }
.search-icon {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--sb-ink-4);
    font-size: 11px;
    pointer-events: none;
    transition: color .18s ease;
}
.dms-sidebar-search input:focus ~ .search-icon,
.dms-sidebar-search:hover .search-icon { color: var(--sb-ink-2); }
.search-kbd {
    position: absolute; right: 8px; top: 50%;
    transform: translateY(-50%);
    display: inline-flex; gap: 2px;
    pointer-events: none;
    opacity: .85;
    transition: opacity .18s ease;
}
.dms-sidebar-search input:focus ~ .search-kbd { opacity: 0; }
.search-kbd kbd,
.nav-item-kbd kbd {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    font-family: var(--sb-mono);
    font-size: 9.5px; font-weight: 600;
    color: var(--sb-ink-3);
    background: var(--sb-surface);
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px var(--sb-border), 0 1px 0 var(--sb-border);
}

/* ============================
   NAV
   ============================ */
.dms-sidebar-nav {
    position: relative;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 8px 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--sb-border-2) transparent;
}
.dms-sidebar-nav::-webkit-scrollbar { width: 6px; }
.dms-sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.dms-sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sb-border-2);
    border-radius: 3px;
}
.dms-sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--sb-ink-4); }

/* Sliding pill that tracks hovered/active item */
.nav-pill {
    position: absolute;
    left: 8px; right: 8px;
    height: 34px;
    background: var(--sb-accent-soft);
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px var(--sb-accent-line);
    transform: translateY(0);
    transition: transform .35s cubic-bezier(.4,0,.2,1), opacity .25s ease, height .2s ease;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    will-change: transform;
}
.dms-sidebar-nav[data-pill-mode="hover"] .nav-pill { opacity: 1; }
.dms-sidebar-nav[data-pill-mode="active"] .nav-pill { opacity: 1; }

/* Group */
.nav-group { position: relative; z-index: 1; padding: 0; margin-top: 8px; }
.nav-group:first-of-type { margin-top: 2px; }
.nav-group-label {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px 4px;
    font-size: 9.5px; font-weight: 700;
    color: var(--sb-ink-4);
    letter-spacing: .12em;
    text-transform: uppercase;
}
.nav-group-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--sb-border) 0%, transparent 100%);
}

/* Item */
.nav-item {
    position: relative;
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 1px 0;
    border-radius: 8px;
    text-decoration: none;
    color: var(--sb-ink-2);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -.005em;
    transition: color .15s ease, transform .15s ease;
    cursor: pointer;
    z-index: 1;
    animation: sbItemIn .35s calc(.05s + var(--i, 0) * .03s) cubic-bezier(.2,.7,.2,1) both;
}
@keyframes sbItemIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: translateX(0); } }
.nav-item:hover:not(.active) { color: var(--sb-ink); }
.nav-item:hover:not(.active) .nav-item-icon { color: var(--sb-ink); transform: scale(1.06); }
.nav-item:hover:not(.active) .nav-item-kbd kbd { color: var(--sb-ink-2); }

.nav-item.active {
    color: var(--sb-accent);
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -8px; top: 8px; bottom: 8px;
    width: 2px;
    border-radius: 2px;
    background: var(--sb-accent);
    box-shadow: 0 0 8px var(--sb-accent-line);
    animation: sbActiveBar .4s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes sbActiveBar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.nav-item.active .nav-item-icon { color: var(--sb-accent); }
.nav-item.active .nav-item-icon::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 6px;
    background: var(--sb-accent-soft);
    z-index: -1;
}

.nav-item-icon {
    position: relative;
    width: 22px; height: 22px;
    border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--sb-ink-3);
    transition: color .15s ease, transform .15s ease;
}
.nav-item-icon svg {
    width: 16px; height: 16px;
    opacity: .9;
}
.nav-item-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-item-kbd {
    display: inline-flex; gap: 2px;
    opacity: 0;
    transition: opacity .15s ease;
}
.nav-item:hover .nav-item-kbd { opacity: 1; }
.nav-item-badge {
    display: inline-flex; align-items: center;
    height: 18px; padding: 0 7px;
    border-radius: 999px;
    font-family: var(--sb-mono);
    font-size: 9.5px; font-weight: 600;
    color: var(--sb-ink-3);
    background: var(--sb-surface-2);
    box-shadow: inset 0 0 0 1px var(--sb-border);
    transition: all .18s ease;
    letter-spacing: .02em;
}
.nav-item.active .nav-item-badge {
    color: var(--sb-accent);
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--sb-accent-line);
}
.nav-item-badge[data-badge="AI"]  { color: #6d28d9; box-shadow: inset 0 0 0 1px rgb(109 40 217 / .22); background: rgb(109 40 217 / .06); }
.nav-item-badge[data-badge="BRD"] { color: var(--sb-accent); box-shadow: inset 0 0 0 1px var(--sb-accent-line); background: var(--sb-accent-soft); }

/* Search-filter states */
.nav-item.is-hidden { display: none !important; }
.nav-group.is-hidden { display: none !important; }
.nav-item.is-matched .nav-item-label mark {
    background: rgb(250 204 21 / .35);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

.nav-empty {
    text-align: center;
    padding: 26px 16px;
    color: var(--sb-ink-3);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 12px;
}
.nav-empty[hidden] { display: none; }
.nav-empty i { font-size: 14px; color: var(--sb-ink-4); margin-bottom: 4px; }
.nav-empty span { font-weight: 600; color: var(--sb-ink-2); }
.nav-empty small { font-size: 10.5px; color: var(--sb-ink-4); }

/* ============================
   FOOTER
   ============================ */
.dms-sidebar-foot {
    border-top: 1px solid var(--sb-border);
    padding: 10px 12px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    background: linear-gradient(180deg, transparent, var(--sb-surface-2) 100%);
}
.foot-status {
    display: flex; align-items: center; gap: 9px;
    flex: 1; min-width: 0;
}
.foot-status-pulse {
    position: relative;
    width: 10px; height: 10px;
    flex-shrink: 0;
}
.foot-status-dot {
    position: absolute; inset: 2px;
    background: var(--sb-success);
    border-radius: 50%;
    z-index: 1;
}
.foot-status-ring {
    position: absolute; inset: 0;
    border-radius: 50%;
    background: rgb(22 163 74 / .35);
    animation: sbPulse 1.8s ease-out infinite;
}
@keyframes sbPulse {
    0%   { transform: scale(.6); opacity: .8; }
    100% { transform: scale(2.2); opacity: 0; }
}
.foot-status-text {
    display: flex; flex-direction: column; line-height: 1.15;
    min-width: 0;
}
.foot-status-text strong {
    color: var(--sb-ink);
    font-size: 11.5px; font-weight: 600;
    letter-spacing: -.005em;
}
.foot-status-text small {
    color: var(--sb-ink-3);
    font-size: 10.5px;
    margin-top: 1px;
    font-family: var(--sb-mono);
}
.foot-status-text small .mono { color: var(--sb-ink-2); font-weight: 500; }

.foot-meta {
    display: flex; align-items: center; gap: 6px;
}
.foot-version {
    font-family: var(--sb-mono);
    font-size: 10px;
    color: var(--sb-ink-4);
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--sb-surface);
    box-shadow: inset 0 0 0 1px var(--sb-border);
}
.foot-user {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px -2px rgba(29,78,216,.5);
    cursor: pointer;
    transition: transform .15s ease;
    letter-spacing: .02em;
}
.foot-user:hover { transform: scale(1.06); }

/* ============================
   REDUCED MOTION
   ============================ */
@media (prefers-reduced-motion: reduce) {
    .dms-sidebar,
    .nav-item,
    .brand-mark-glow,
    .foot-status-ring {
        animation: none !important;
    }
    *, *::before, *::after {
        transition-duration: .01ms !important;
    }
}
