/* ===== Identity Rail — bespoke sidebar ===== */
/* MenuComponent.js owns 100% of #layout-menu's inner markup (.sb-* classes
   below) — this is NOT a restyle of Vuexy's stock menu markup. The outer
   shell (fixed position, full height, and the collapsed-width shrink) is
   still provided by the template's own `.layout-menu`/`.menu-vertical`
   classes, which the <aside> keeps — only what's INSIDE is custom. */

:root {
    --company: #c9a227;
}

#layout-menu.sb {
    /* No `position` here on purpose: the template already sets
       `position: relative` (default) or `position: fixed` (when
       `.layout-menu-fixed` is active, keeping the sidebar pinned while
       the page scrolls) on this exact element. An ID selector like this
       one outranks the template's two-class selector regardless of
       source order — overriding `position` here, even to `relative`,
       silently downgrades a fixed sidebar to a scrolling one. Both of
       the template's positioning modes already work as containing
       blocks for the `position: absolute` children below. */
    background: #0f1115 !important;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* The signature "Identity Rail" effect: a seam of the company's own color
   bleeding along the sidebar's edge, plus a soft ambient glow behind the
   header. Isolated in its own layer (rather than `overflow:hidden` on
   #layout-menu.sb itself) so the user popover — which needs to escape the
   sidebar's bounds in collapsed mode — is never clipped by it. */
.sb-glow {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.sb-glow::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(180deg, transparent, var(--company) 35%, var(--company) 65%, transparent);
    opacity: 0.6;
    filter: blur(2px);
}

.sb-glow::after {
    content: '';
    position: absolute;
    top: 8%;
    right: -40px;
    width: 120px;
    height: 60%;
    background: var(--company);
    opacity: 0.18;
    filter: blur(46px);
}

#layout-menu.sb > *:not(.sb-glow) {
    position: relative;
    z-index: 1;
}

/* ===== Header ===== */

.sb-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0.75rem;
    padding: 0.7rem 0.65rem;
    border-radius: 14px;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.sb-head:hover {
    background: #181c24;
}

.sb-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, #2a2d36, #14161b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: #f2f0ea;
    box-shadow: 0 0 0 2px #0f1115, 0 0 0 3.5px var(--company), 0 0 14px var(--company);
    overflow: hidden;
    /* Company logos arrive in whatever aspect ratio/crop the client
       uploaded — not pre-cropped to a circle — so a couple px of
       breathing room plus `contain` below keeps the whole logo visible
       instead of `cover` slicing off its edges to fill the circle. */
    padding: 3px;
}

.sb-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sb-headtext {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sb-company {
    font-weight: 600;
    font-size: 14px;
    color: #f2f0ea;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-headmeta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: #8a8f9c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.sb-headmeta .sep {
    opacity: 0.35;
}

.sb-headmeta-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sb-headmeta-dot--on {
    background: #3ddba0;
    box-shadow: 0 0 4px #3ddba0;
}

.sb-headmeta-dot--off {
    background: #6b6f7a;
}

.sb-hr {
    height: 1px;
    margin: 0 1.1rem 0.6rem;
    background: linear-gradient(90deg, rgba(201, 162, 39, 0.35), transparent 70%);
    flex-shrink: 0;
}

/* ===== Scrollable nav area ===== */

.sb-nav-scroll {
    flex: 1 1 auto;
    /* Flex items default to min-height:auto (= their content's natural
       height), which stops them from ever shrinking below that — so
       overflow-y:auto never actually triggers, and this area grows past
       its allotted space instead of scrolling, pushing the footer down
       or breaking the whole sidebar into a page-level scroll. This one
       line is the fix. */
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0.75rem;
}

.sb-nav-scroll::-webkit-scrollbar {
    width: 5px;
}

.sb-nav-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

.sb-eyebrow {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #8a8f9c;
    margin: 1.1rem 0.5rem 0.55rem;
}

.sb-eyebrow:first-child {
    margin-top: 0.2rem;
}

/* ===== Nav items ===== */

.sb-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.6rem;
    border-radius: 10px;
    margin-bottom: 2px;
    font-size: 13.5px;
    font-weight: 500;
    color: #8a8f9c;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    user-select: none;
}

.sb-item:hover {
    background: #181c24;
    color: #f2f0ea;
}

.sb-item.active {
    background: #181c24;
    color: #f2f0ea;
}

.sb-item.active::before {
    content: '';
    position: absolute;
    left: -0.45rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    border-radius: 2px;
    background: var(--company);
    box-shadow: 0 0 8px var(--company);
}

.sb-ic {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

.sb-item .lbl {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-chev {
    font-size: 9px;
    color: #8a8f9c;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.sb-group.open > .sb-toggle .sb-chev {
    transform: rotate(90deg);
}

/* ===== Submenu accordion (CSS grid-rows — no JS height calc) ===== */

.sb-submenu-wrap {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 1.15rem;
}

.sb-group.open .sb-submenu-wrap {
    grid-template-rows: 1fr;
}

.sb-submenu-inner {
    overflow: hidden;
}

.sb-submenu {
    list-style: none;
    padding: 2px 0 4px 0.85rem;
    margin: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.sb-sub-item {
    margin-bottom: 1px;
}

.sb-sub-item .lbl {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    font-size: 12.5px;
    color: #8a8f9c;
    text-decoration: none;
    position: relative;
}

.sb-sub-item .lbl:hover {
    background: #181c24;
    color: #f2f0ea;
}

.sb-sub-item.active .lbl {
    color: #f2f0ea;
    font-weight: 600;
}

.sb-sub-item.active .lbl::before {
    content: '';
    position: absolute;
    left: -0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--company);
    box-shadow: 0 0 6px var(--company);
}

/* ===== Footer: signature + collapse bar ===== */

.sb-foot {
    flex-shrink: 0;
    padding: 0.7rem 0.75rem 0.85rem;
    position: relative;
}

/* ===== User row + actions popover ===== */

.sb-user-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    margin-bottom: 0.35rem;
    transition: background 0.15s ease;
}

.sb-user-row:hover {
    background: #181c24;
}

.sb-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    background: linear-gradient(135deg, #3a3e48, #1c1f26);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: #f2f0ea;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.sb-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sb-user-text {
    flex: 1;
    min-width: 0;
}

.sb-user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #f2f0ea;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-user-role {
    font-size: 10px;
    color: #8a8f9c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-user-menu {
    color: #8a8f9c;
    font-size: 15px;
    flex-shrink: 0;
    line-height: 0;
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

.sb-user-row:hover .sb-user-menu {
    opacity: 1;
}

.sb-user-pop {
    position: absolute;
    width: 184px;
    bottom: calc(100% + 6px);
    left: 0.5rem;
    background: #181c24;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}

.sb-user-row.open .sb-user-pop {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.sb-pop-item {
    padding: 7px 9px;
    border-radius: 7px;
    font-size: 12px;
    color: #8a8f9c;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}

.sb-pop-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #f2f0ea;
}

.sb-pop-item.danger:hover {
    color: #ff6a6a;
}

.sb-signature {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 0 4px;
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #6b7280;
}

.sb-signature-brand {
    font-weight: 700;
    color: #8a90a0;
}

.sb-collapse-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0.6rem;
    border-radius: 12px;
    background: #181c24;
    color: #8a8f9c;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s ease, color 0.15s ease;
}

.sb-collapse-bar:hover {
    background: #20242e;
    color: #f2f0ea;
}

.sb-collapse-bar svg {
    flex-shrink: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.layout-menu-collapsed .sb-collapse-bar svg {
    transform: rotate(180deg);
}

/* Two labels sharing the button: "Recolher menu" normally, but while the
   rail is only widened as a hover preview (collapsed state persisted,
   .layout-menu-hover temporary) a click actually pins it open — not
   collapses it further — so the label swaps to "Fixar menu" to match
   what clicking will really do. */
.sb-collapse-bar .txt-pin {
    display: none;
}

.layout-menu-collapsed.layout-menu-hover .sb-collapse-bar .txt-collapse {
    display: none;
}

.layout-menu-collapsed.layout-menu-hover .sb-collapse-bar .txt-pin {
    display: inline;
}

/* ===== Collapsed rail (width shrink to 5.25rem is already handled by the
   template's own `.menu-vertical` + `layout-menu-collapsed` CSS — this is
   only the bespoke content inside reacting to that narrower width) =====
   Every rule below is guarded with `:not(.layout-menu-hover)` — Vuexy's
   own menu.js adds `.layout-menu-hover` to <html> while the mouse is over
   a collapsed rail, widening it back out as a hover preview (see its own
   `.layout-menu-collapsed:not(.layout-menu-hover) ...` rules in core.css).
   Without the same guard here, that native width-expand ran but our
   bespoke labels/submenus stayed hidden — a wide rail with no text. */

.layout-menu-collapsed:not(.layout-menu-hover) .sb-head {
    justify-content: center;
    padding: 0.7rem 0;
    margin: 0.75rem 0.4rem;
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-headtext,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-eyebrow,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-item .lbl,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-chev,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-collapse-bar .txt,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-signature,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-user-text,
.layout-menu-collapsed:not(.layout-menu-hover) .sb-user-menu {
    display: none;
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-user-row {
    justify-content: center;
    padding: 0.5rem 0.25rem;
}

/* Too narrow to host the popover above a squeezed row — fly out to the right instead */
.layout-menu-collapsed:not(.layout-menu-hover) .sb-user-pop {
    left: calc(100% + 10px);
    bottom: auto;
    top: 50%;
    transform: translateY(calc(-50% + 4px));
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-user-row.open .sb-user-pop {
    transform: translateY(-50%);
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-nav-scroll {
    padding: 0 0.5rem;
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-item {
    justify-content: center;
    padding: 0.6rem;
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-item.active::before {
    left: -0.15rem;
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-group .sb-submenu-wrap {
    display: none;
}

.layout-menu-collapsed:not(.layout-menu-hover) .sb-collapse-bar {
    padding: 0.6rem;
}
