/* ==========================================================================
   FenKaruGO - Shell: sidebar retratil, topo e abas.
   ========================================================================== */

:root {
    --fen-sidebar-bg: #c1121f;
    --fen-sidebar-bg-2: #a20e19;
    --fen-sidebar-fg: #ffffff;
    --fen-sidebar-fg-muted: rgba(255, 255, 255, .72);
    --fen-sidebar-hover: rgba(255, 255, 255, .16);
    --fen-sidebar-active: rgba(255, 255, 255, .24);
    --fen-sidebar-width: 250px;
    --fen-sidebar-width-collapsed: 66px;
    --fen-topbar-bg: #ffffff;
    --fen-topbar-border: #e5e7eb;
    --fen-tab-bg: #f1f3f5;
    --fen-tab-active-bg: #ffffff;
    --fen-content-bg: #f6f7f9;
}

[data-bs-theme="dark"] {
    --fen-sidebar-bg: #17191c;
    --fen-sidebar-bg-2: #101215;
    --fen-sidebar-fg: #f1f3f5;
    --fen-sidebar-fg-muted: rgba(255, 255, 255, .6);
    --fen-sidebar-hover: rgba(255, 255, 255, .10);
    --fen-sidebar-active: #c1121f;
    --fen-topbar-bg: #1c1f23;
    --fen-topbar-border: #2b2f36;
    --fen-tab-bg: #23272d;
    --fen-tab-active-bg: #14161a;
    --fen-content-bg: #14161a;
}

/* ---- Layout base ---- */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Recolhida por padrao (so icones); expande com a classe .expanded (hover) */
.sidebar {
    width: var(--fen-sidebar-width-collapsed);
    background: linear-gradient(180deg, var(--fen-sidebar-bg), var(--fen-sidebar-bg-2));
    color: var(--fen-sidebar-fg);
    display: flex;
    flex-direction: column;
    transition: width .18s ease;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar.expanded {
    width: var(--fen-sidebar-width);
}

.sidebar__logo {
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

/* logo horizontal (icone + KaruFEN) quando expandida */
.sidebar__logo img.logo-full {
    max-width: 200px;
    max-height: 46px;
    display: none;
}

/* so o icone quando recolhida */
.sidebar__logo img.logo-icon {
    width: 40px;
    height: 40px;
    display: block;
}

.sidebar.expanded .sidebar__logo img.logo-full {
    display: block;
}

.sidebar.expanded .sidebar__logo img.logo-icon {
    display: none;
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.sidebar__group-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--fen-sidebar-fg-muted);
    white-space: nowrap;
    text-align: center;
    padding: 12px 0 4px;
    font-size: 0;
}

.sidebar__group-title::after {
    content: "•";
    font-size: .9rem;
}

.sidebar.expanded .sidebar__group-title {
    text-align: left;
    padding: 14px 18px 6px;
    font-size: .68rem;
}

.sidebar.expanded .sidebar__group-title::after {
    content: none;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    justify-content: center;
    color: var(--fen-sidebar-fg);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: .93rem;
}

.sidebar.expanded .sidebar__item {
    justify-content: flex-start;
    padding: 10px 18px;
}

.sidebar__item:hover {
    background: var(--fen-sidebar-hover);
    color: #fff;
}

.sidebar__item.active {
    background: var(--fen-sidebar-active);
}

.sidebar__item i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar__item .label {
    display: none;
}

.sidebar.expanded .sidebar__item .label {
    display: inline;
}

.sidebar__subitems {
    display: none;
    padding-left: 0;
}

.sidebar__subitems.open {
    display: block;
}

.sidebar.expanded .sidebar__subitems {
    padding-left: 20px;
}

.sidebar__item .caret {
    margin-left: auto;
    transition: transform .15s;
    display: none;
}

.sidebar.expanded .sidebar__item .caret {
    display: inline;
}

.sidebar__item[aria-expanded="true"] .caret {
    transform: rotate(90deg);
}

/* ---- Main ---- */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--fen-content-bg);
}

.topbar {
    height: 52px;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 .6rem;
    background: var(--fen-topbar-bg);
    border-bottom: 1px solid var(--fen-topbar-border);
    flex-shrink: 0;
}

.topbar__toggle {
    border: 0;
    background: transparent;
    font-size: 1.35rem;
    line-height: 1;
    color: inherit;
    padding: .25rem .5rem;
    cursor: pointer;
}

/* Avatar do usuario: so o icone/foto grande e redondo, sem nome nem seta */
.topbar__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--fen-topbar-border);
    background: transparent;
    padding: 0;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.topbar__avatar:hover {
    border-color: var(--fen-sidebar-bg);
}

.topbar__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar__avatar i {
    font-size: 1.7rem;
    line-height: 1;
    color: #8a9099;
}

.topbar__avatar::after {
    display: none;
    /* remove a setinha do dropdown */
}

/* Selo STAGING no topo (so no ambiente de teste) */
.topbar__staging {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #fde047, #f59e0b);
    color: #7a0d17;
    font-weight: 800;
    font-size: .72rem;
    letter-spacing: .08em;
    padding: 4px 12px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
    flex-shrink: 0;
    margin-right: 4px;
}

/* ---- Abas ---- */
.tabbar {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    overflow-x: auto;
    height: 100%;
}

.tabbar::-webkit-scrollbar {
    height: 4px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-top: 8px;
    background: var(--fen-tab-bg);
    border: 1px solid var(--fen-topbar-border);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    font-size: .85rem;
    white-space: nowrap;
    cursor: pointer;
    color: inherit;
    max-width: 220px;
}

.tab-btn.active {
    background: var(--fen-tab-active-bg);
    font-weight: 600;
}

.tab-btn .tab-title {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.tab-btn .tab-close {
    border: 0;
    background: transparent;
    color: inherit;
    opacity: .6;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}

.tab-btn .tab-close:hover {
    opacity: 1;
}

.tabcontent {
    flex: 1;
    position: relative;
    min-height: 0;
}

.tab-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: none;
    background: var(--fen-content-bg);
}

.tab-frame.active {
    display: block;
}

.tab-home {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #8a9099;
    gap: .5rem;
}

.tab-home.hidden {
    display: none;
}

.tab-home img {
    width: 320px;
    max-width: 70%;
    height: auto;
    opacity: .7;
    margin-bottom: .75rem;
}

/* Conteudo embutido em iframe: sem margens da moldura */
html.embedded body {
    background: transparent;
}

/* ==========================================================================
   Ajuste fino do MODO ESCURO — superficies que nao trocam sozinhas.
   Escopo [data-bs-theme="dark"]; exclui os cartoes coloridos do Analytics
   (.an-card) e do Monitor (.vps-card) para preservar seus gradientes.
   ========================================================================== */
[data-bs-theme="dark"] {
    --fen-surface: #1c1f23;
    --fen-surface-2: #23272d;
    --fen-border: #2b2f36;
}

/* Fundo geral das paginas abertas nas abas */
[data-bs-theme="dark"] body,
[data-bs-theme="dark"] #app,
[data-bs-theme="dark"] #app > main,
[data-bs-theme="dark"] .tab-home {
    background-color: var(--fen-content-bg);
    color: var(--bs-body-color, #e6edf3);
}

/* Cartoes / listas / modais / dropdowns / acordeoes comuns */
[data-bs-theme="dark"] .card:not(.an-card):not(.vps-card),
[data-bs-theme="dark"] .list-group-item,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .accordion-item {
    background-color: var(--fen-surface);
    color: var(--bs-body-color, #e6edf3);
    border-color: var(--fen-border);
}

[data-bs-theme="dark"] .card:not(.an-card):not(.vps-card) .card-header,
[data-bs-theme="dark"] .card:not(.an-card):not(.vps-card) .card-footer {
    background-color: var(--fen-surface-2);
    border-color: var(--fen-border);
    color: var(--bs-body-color, #e6edf3);
}

/* Formularios */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
    background-color: var(--fen-surface-2);
    color: var(--bs-body-color, #e6edf3);
    border-color: var(--fen-border);
}
[data-bs-theme="dark"] .form-control::placeholder { color: #8a94a3; }

/* Tabelas */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--bs-body-color, #e6edf3);
    color: var(--bs-body-color, #e6edf3);
    border-color: var(--fen-border);
}
[data-bs-theme="dark"] .table > :not(caption) > * > * {
    border-color: var(--fen-border);
}

/* Bordas de fieldset (formularios de empresa) */
[data-bs-theme="dark"] fieldset { border-color: var(--fen-border) !important; }

/* Utilitarios que ficariam brancos */
[data-bs-theme="dark"] .bg-white { background-color: var(--fen-surface) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--fen-surface-2) !important; color: var(--bs-body-color, #e6edf3) !important; }
[data-bs-theme="dark"] .navbar.bg-white { background-color: var(--fen-surface) !important; }
