/* =====================================================================================
   Casca do layout (sidebar + navbar + shell de conteudo) — portada do PLASAS
   (D:\GIT\PLASAS\src\Plasas.Wasm\Layout\MainLayout.razor + SideBar.razor + Navbar\NavBar.razor).
   La o app usa Tailwind; aqui tudo foi reescrito em CSS puro com os mesmos valores (brand
   #2563eb, slate, Public Sans, Material Symbols Rounded) pra nao introduzir o pipeline do
   Tailwind no Cms.Admin. Estrutura:

     .dashboard-container (flex, 100vh)
       aside.sidebar (92px, azul)  -> logo tile, .menu-item (icone+rotulo), .submenu (drawer
                                      branco 280px no hover), rodape .sidebar-user
       .menu-overlay              -> escurece o conteudo enquanto o submenu esta aberto
       main.main-content          -> shell cinza pontilhado (estilo Vercel/Linear)
         header.navbar-shell      -> navbar transparente com blur
         .content-shell > .content-panel (painel branco arredondado com o @Body) + footer

   Mobile (<768px): sidebar vira drawer de 280px (translateX), submenu vira accordion.
   JS de apoio em js/shell.js (cmsShell.initMenu / toggleMobileMenu).
   ===================================================================================== */

:root {
    --brand-50: #eff6ff;
    --brand-100: #dbeafe;
    --brand-200: #bfdbfe;
    --brand-300: #93c5fd;
    --brand-400: #60a5fa;
    --brand-500: #3b82f6;
    --brand-600: #2563eb;
    --brand-700: #1d4ed8;
    --brand-800: #1e40af;
    --brand-900: #1e3a8a;
    --sidebar-w: 92px;
}

/* Icone de fonte (Material Symbols Rounded) — mesmo ajuste do PLASAS */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    user-select: none;
}

/* Sem isso o body rola junto com o main; o scroll fica dentro de .main-content */
body.shell-ativo { overflow: hidden; }

.dashboard-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    background: #f8fafc;
    color: #1e293b;
}

/* ---------- Overlay (escurece o conteudo quando o submenu/drawer esta aberto) ---------- */
.menu-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, .5);
    z-index: 30; /* atras do submenu (40) e da sidebar (50) */
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
    backdrop-filter: blur(2px);
}
.menu-overlay.active { opacity: 1; pointer-events: auto; }

/* ---------- Sidebar estreita ---------- */
.sidebar {
    position: relative;
    width: var(--sidebar-w);
    background-color: var(--brand-600);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    z-index: 50;
    color: #fff;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar { width: 0; height: 0; }

.sidebar-logo {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-bottom: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
    text-decoration: none;
    outline: none;
}
.sidebar-logo-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .08);
    transition: background-color .2s ease, transform .2s ease;
}
.sidebar-logo:hover .sidebar-logo-tile { background: rgba(255, 255, 255, .14); transform: scale(1.04); }
.sidebar-logo:focus-visible .sidebar-logo-tile { box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.sidebar-logo img { width: 30px; height: auto; display: block; }

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 100%;
    flex: 1;
}

.menu-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: calc(100% - 16px);
    margin: 2px 8px;
    padding: .7rem 0;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color .2s;
    color: var(--brand-200);
    text-decoration: none;
    font-weight: inherit;
}
.menu-item:hover, .menu-item.menu-hovering, .menu-item.menu-clicked { background-color: rgba(255, 255, 255, .12); color: #fff; }

/* Ponte de hover invisivel entre o item (margin 8px) e o submenu (comeca em --sidebar-w) */
.menu-item::after {
    content: '';
    position: absolute;
    top: 0;
    right: -12px;
    width: 12px;
    height: 100%;
}

.menu-item.active { background-color: var(--brand-700) !important; }

.menu-item .icon {
    font-size: 24px;
    margin-bottom: .25rem;
    color: var(--brand-200);
    transition: color .2s;
}
.menu-item:hover .icon, .menu-item.menu-hovering .icon, .menu-item.active .icon { color: #fff; }

.menu-item .menu-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    color: var(--brand-200);
    text-align: center;
    max-width: 68px;
    word-wrap: break-word;
    line-height: 1.3;
    white-space: normal;
    transition: color .2s;
}
.menu-item:hover .menu-label, .menu-item.menu-hovering .menu-label, .menu-item.active .menu-label { color: #fff; }

/* ---------- Submenu (drawer branco ao lado da sidebar) ---------- */
.submenu {
    display: none;
    position: fixed;
    left: var(--sidebar-w);
    top: 0;
    bottom: 0;
    width: 280px;
    background-color: #fff;
    box-shadow: 4px 0 15px rgba(0, 0, 0, .05);
    z-index: 40;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    animation: submenuFadeIn .15s ease-out;
    cursor: default;
}
@keyframes submenuFadeIn { from { opacity: 0; } to { opacity: 1; } }

.menu-item:hover .submenu, .menu-item.open .submenu { display: flex; }

.submenu-header { padding: 1.5rem; border-bottom: 1px solid #e2e8f0; }
.submenu-title-large {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-600);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.submenu-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
}
.submenu-group { margin-bottom: 1.5rem; }
.submenu-group:last-child { margin-bottom: 0; }
.submenu-group-title {
    display: flex;
    align-items: center;
    font-size: .6875rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: .35rem;
    padding: 0 1.5rem;
}
.submenu-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .625rem 1.5rem;
    color: #334155;
    font-size: .9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: all .2s;
}
.submenu-link .material-symbols-rounded { font-size: 20px; color: #94a3b8; }
.submenu-link:hover { color: #fff; background-color: var(--brand-600); font-weight: 700; }
.submenu-link:hover .material-symbols-rounded { color: #fff; }
.submenu-link.active { color: var(--brand-700); background: var(--brand-50); font-weight: 700; }
.submenu-link.active .material-symbols-rounded { color: var(--brand-600); }

.submenu-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background-color: #f8fafc;
    font-size: .8125rem;
    color: #64748b;
}

/* ---------- Rodape da sidebar: usuario + popover ---------- */
.sidebar-user {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-user-btn {
    background: none;
    border: none;
    padding: 8px 4px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 76px;
    transition: background-color .2s;
    color: #fff;
    font-family: inherit;
}
.sidebar-user-btn:hover, .sidebar-user-btn.open { background-color: rgba(255, 255, 255, .12); border-color: transparent; }
.sidebar-user-name {
    max-width: 68px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .2px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
}

.user-menu-overlay { position: fixed; inset: 0; z-index: 55; }
.user-menu {
    position: fixed;
    left: 100px;
    bottom: 16px;
    width: 244px;
    background: #fff;
    border: 1px solid #e4eaf2;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(15, 28, 46, .12);
    z-index: 60;
    overflow: hidden;
    animation: userMenuIn .18s ease-out;
    color: #1a2533;
}
@keyframes userMenuIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.user-menu-header { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid #e4eaf2; }
.user-menu-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: #eaf1f9; color: var(--brand-600);
    display: flex; align-items: center; justify-content: center; flex: none;
    font-weight: 800; font-size: 14px;
}
.user-menu-info { min-width: 0; }
.user-menu-name { font-size: 14px; font-weight: 700; color: #1a2533; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-email { font-size: 12px; font-weight: 500; color: #8593a5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-actions { display: flex; flex-direction: column; padding: 6px; }
.user-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 9px;
    font-size: 13.5px; font-weight: 600; color: #3a4859;
    text-decoration: none; background: none; border: none; cursor: pointer;
    font-family: inherit; text-align: left; width: 100%;
    transition: background-color .15s;
}
.user-menu-item:hover { background-color: #f1f5fa; color: #3a4859; border-color: transparent; }
.user-menu-item .material-symbols-rounded { font-size: 20px; color: #5b6b7f; }
.user-menu-item.danger { color: #c0392b; }
.user-menu-item.danger:hover { background-color: #fbecea; color: #c0392b; }
.user-menu-item.danger .material-symbols-rounded { color: #c0392b; }

/* ---------- Conteudo principal (shell cinza) ---------- */
.main-content {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: #eef2f7;
    background-image:
        radial-gradient(120% 75% at 50% -10%, rgba(37, 99, 235, .06), rgba(37, 99, 235, 0) 55%),
        radial-gradient(rgba(37, 99, 235, .045) 1px, transparent 1px);
    background-size: 100% 100%, 24px 24px;
}

.navbar-shell {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
    background: rgba(238, 242, 247, .82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.navbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: 0 2rem;
}
.navbar-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.navbar-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.navbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}
.navbar-subtitle { font-size: .75rem; color: #64748b; font-weight: 500; }

.navbar-icon-btn {
    display: none; /* so mobile */
    background: none;
    border: none;
    padding: .5rem;
    margin-left: -.5rem;
    border-radius: 8px;
    color: #475569;
    cursor: pointer;
    line-height: 0;
}
.navbar-icon-btn:hover { background: #e2e8f0; border-color: transparent; }
.navbar-icon-btn .material-symbols-rounded { font-size: 30px; }

/* Seletor de empresa (so pra quem nao e SuperAdmin) */
.empresa-switch { position: relative; }
.empresa-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    height: 38px;
    padding: 0 .75rem 0 .85rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    max-width: 260px;
}
.empresa-switch-btn:hover { border-color: var(--brand-300); background: #fff; }
.empresa-switch-btn .material-symbols-rounded { font-size: 20px; color: var(--brand-600); }
.empresa-switch-btn .material-symbols-rounded.caret { color: #94a3b8; font-size: 18px; }
.empresa-switch-btn span.nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empresa-switch-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 240px;
    max-height: 60vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e4eaf2;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(15, 28, 46, .12);
    z-index: 60;
    padding: 6px;
    animation: userMenuIn .18s ease-out;
}
.empresa-switch-menu .user-menu-item.active { background: var(--brand-50); color: var(--brand-700); }

/* Relogio (data + hora) ao lado do perfil */
.navbar-relogio {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    height: 38px;
    padding: 0 .85rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: .8125rem;
    font-weight: 600;
    white-space: nowrap;
}
.navbar-relogio .material-symbols-rounded { font-size: 18px; color: var(--brand-600); }
.navbar-relogio-data { color: #64748b; font-weight: 500; }
.navbar-relogio-hora { font-variant-numeric: tabular-nums; }
@media (max-width: 767px) {
    .navbar-relogio { padding: 0 .6rem; }
    .navbar-relogio-data { display: none; }
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: none;
    border: none;
    border-left: 1px solid #cbd5e1;
    border-radius: 0;
    padding: .25rem 0 .25rem 1rem;
    margin-left: .5rem;
    cursor: pointer;
    font-family: inherit;
    color: #334155;
    font-size: .875rem;
    font-weight: 500;
}
.navbar-user:hover { background: none; border-color: #cbd5e1; }
.navbar-user .avatar-nav {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--brand-600); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12px;
    border: 1px solid #e2e8f0;
}
.navbar-user .material-symbols-rounded { font-size: 18px; color: #94a3b8; }
.navbar-user-menu-wrap { position: relative; }
.navbar-user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 244px;
    background: #fff;
    border: 1px solid #e4eaf2;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(15, 28, 46, .12);
    z-index: 60;
    overflow: hidden;
    animation: userMenuIn .18s ease-out;
}

.content-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 4px 16px 16px;
}
.content-panel {
    flex: 1;
    min-height: 0;
    background: #fff;
    border: 1px solid #e4eaf2;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(37, 99, 235, .07);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 2rem;
}
.content-footer {
    font-size: .75rem;
    color: #64748b;
    text-align: center;
    padding: .75rem 0 0;
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
    .navbar { padding: 0 1rem; }
    .navbar-title { font-size: 1rem; }
    .navbar-icon-btn { display: inline-flex; }
    .navbar-user span.nome { display: none; }
    .navbar-user .material-symbols-rounded { display: none; }
    .navbar-user { border-left: none; padding-left: .25rem; margin-left: 0; }
    .empresa-switch-btn span.nome { max-width: 110px; }
    .content-shell { padding: 4px 8px 8px; }
    .content-panel { padding: 1rem; border-radius: 12px; }

    .dashboard-container { flex-direction: column; }
    .menu-item::after { content: none; }

    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        --sidebar-w: 280px;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform .3s ease;
        box-shadow: 4px 0 15px rgba(0, 0, 0, .1);
        padding: 1rem;
        overflow-y: auto;
    }
    .sidebar.mobile-open { transform: translateX(0); }

    .sidebar-menu { gap: .25rem; }
    .menu-item {
        flex-direction: row;
        justify-content: flex-start;
        flex-wrap: wrap;
        align-items: center;
        padding: .75rem 1rem;
        border-radius: .5rem;
        gap: 0 .75rem;
        width: 100%;
        margin: 0;
    }
    .menu-item .icon { font-size: 22px; margin-bottom: 0; color: #fff !important; flex: none; }
    .menu-item .menu-label {
        font-size: .9375rem;
        letter-spacing: normal;
        font-weight: 500;
        max-width: none;
        flex: 1;
        text-align: left;
        word-wrap: normal;
        color: #fff;
    }
    .menu-item:has(> .submenu)::before {
        content: 'expand_more';
        font-family: 'Material Symbols Rounded';
        font-size: 20px;
        line-height: 1;
        color: #fff;
        order: 3;
        flex: none;
        transition: transform .2s ease;
    }
    .menu-item.open::before { transform: rotate(180deg); }

    .submenu {
        position: static;
        flex: 0 0 100%;
        order: 4;
        width: auto;
        max-width: none;
        box-shadow: none;
        border-right: none;
        border-left: 3px solid rgba(255, 255, 255, .25);
        margin-left: 0;
        margin-top: .5rem;
        padding-left: .75rem;
        background-color: rgba(255, 255, 255, .07);
        border-radius: .5rem;
        animation: none;
    }
    .submenu-header { display: none; }
    .submenu-content { padding: .375rem 0; gap: .25rem; }
    .submenu-group { margin-bottom: .25rem; }
    .submenu-link {
        padding: .6875rem .75rem;
        font-size: .9375rem;
        color: rgba(255, 255, 255, .85);
        border-radius: .375rem;
    }
    .submenu-link .material-symbols-rounded { color: rgba(255, 255, 255, .7); }
    .submenu-link:hover, .submenu-link:active, .submenu-link.active { color: #fff; background-color: rgba(255, 255, 255, .14); }
    .submenu-link.active .material-symbols-rounded, .submenu-link:hover .material-symbols-rounded { color: #fff; }
    .submenu-group-title {
        color: rgba(255, 255, 255, .6);
        font-size: .75rem;
        padding: 0 .75rem;
        margin-top: 1rem;
        margin-bottom: .25rem;
    }
    .submenu-footer { display: none; }

    .menu-item .submenu { display: none; }
    .menu-item.open .submenu { display: flex; }
    .menu-item:hover .submenu { display: none; }
    .menu-item.open:hover .submenu { display: flex; }

    .sidebar.mobile-open ~ .menu-overlay { opacity: 1; pointer-events: auto; }

    .main-content { margin-left: 0; width: 100%; }

    .sidebar-logo-tile { width: 56px; height: 56px; }
    .sidebar-logo img { width: 36px; }

    .sidebar-user { padding-top: .75rem; }
    .sidebar-user-btn {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        padding: .75rem 1rem;
        gap: .75rem;
        border-radius: .5rem;
    }
    .sidebar-user-name { max-width: none; font-size: .9375rem; font-weight: 600; text-align: left; }
    .user-menu { left: 1rem; right: 1rem; width: auto; bottom: 1rem; }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .submenu { width: 240px; }
    .navbar { padding: 0 1.25rem; }
}
