/* Topo, menu e área de conteúdo - identidade Sabemi
   Aplicado só ao topo padrão (.sab-topo); as variações de parceiros seguem o tema antigo. */
:root {
    --sab-azul: #004077;
    --sab-azul-2: #008cc1;
    --sab-azul-3: #63b9e9;
    --sab-cinza: #b6c0c6;
    --sab-laranja: #ef7d00;
    --sab-laranja-h: #d66f00;
    --sab-texto: #1d2a36;
    --sab-texto-2: #4b5965;
    --sab-fundo: #eef2f5;
    --sab-linha: #e3e8ec;
    --sab-campo: #f0f3f5;
    --sab-fonte: "NeoSans", "Lexend", Calibri, sans-serif;
}

/* Elementos novos do topo ficam ocultos nas variações de parceiros */
.MasterPageHeader:not(.sab-topo) .sab-topo-logo,
.MasterPageHeader:not(.sab-topo) .sab-topo-produto,
.MasterPageHeader:not(.sab-topo) .sab-topo-negocios,
.MasterPageHeader:not(.sab-topo) .sab-avatar {
    display: none;
}

/* Fundo da página inteira (o tema antigo deixa preto abaixo do conteúdo) */
html:has(.sab-topo),
body:has(.sab-topo) {
    background: var(--sab-fundo) !important;
}

/* ---------- Topo ---------- */
.MasterPageHeader.sab-topo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 28px;
    height: auto !important;
    padding: 18px 32px;
    overflow: hidden;
    background: var(--sab-azul) !important;
    color: #fff;
    font-family: var(--sab-fonte);
    font-weight: 400;
}

.MasterPageHeader.sab-topo::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -160px;
    width: 360px;
    height: 360px;
    border-radius: 0 180px 0 180px;
    background: var(--sab-azul-2);
    pointer-events: none;
}

.sab-topo > table,
.sab-topo > table > tbody,
.sab-topo > table > tbody > tr {
    display: contents;
}

.sab-topo > table > tbody > tr > td {
    position: relative;
    z-index: 1;
    padding: 0;
}

.sab-topo > table > tbody > tr > td:first-child {
    order: 1;
    flex: none;
}

.sab-topo > table > tbody > tr > td:last-child {
    order: 3;
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.sab-topo .DefaultPageHyperlink {
    position: static;
    display: flex;
    align-items: center;
    gap: 28px;
    width: auto;
    height: auto;
    color: #fff !important;
    text-decoration: none !important;
}

/* Logo + "Negócios" com a base do texto na linha da base de "Sabemi" (como no login) */
.sab-topo .sab-topo-marca {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.sab-topo .sab-topo-negocios {
    padding-bottom: 3px;
    font-family: var(--sab-fonte);
    font-size: 16px !important;
    font-weight: 400;
    line-height: 1;
    letter-spacing: .01em;
    color: #fff;
    white-space: nowrap;
}

.sab-topo .sab-topo-logo {
    display: block;
    height: 36px;
    width: auto;
    filter: brightness(0) invert(1);
}

.sab-topo .sab-topo-produto {
    font-size: 15px !important;
    font-weight: 300;
    white-space: nowrap;
}

.sab-topo .sab-topo-produto b {
    font-weight: 700;
}

/* Nome/CNPJ do representante selecionado (o tema antigo o posiciona por cima do logo) */
.MasterPageHeader.sab-topo #divTituloSistema {
    position: relative;
    z-index: 1;
    order: 2;
    flex: none;
    padding: 0 0 0 20px;
    border-left: 1px solid rgba(255, 255, 255, .3);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    color: #cfe3f2;
}

.MasterPageHeader.sab-topo #divTituloSistema span {
    font-family: var(--sab-fonte);
    font-size: 12px;
    font-weight: 400;
}

.MasterPageHeader.sab-topo #divTituloSistema #spanRepresentanteNome {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
}

.MasterPageHeader.sab-topo #divTituloSistema:not(:has(span:not(:empty))) {
    display: none;
}

/* Cabeçalho enxuto: sem "Representante OnLine" e sem o bloco nome/CNPJ
   (o representante já aparece, completo, junto do usuário à direita) */
.MasterPageHeader.sab-topo #divTituloSistema,
.MasterPageHeader.sab-topo .sab-topo-produto {
    display: none !important;
}

.sab-topo #divLogotipo {
    display: none;
}

/* Usuário + acesso rápido */
.sab-topo #ctl00__UserInfoTable {
    display: flex;
    align-items: center;
    gap: 28px;
    width: 100% !important;
    padding: 0 !important;
}

.sab-topo #ctl00__UserInfoTable > tbody,
.sab-topo #ctl00__UserInfoTable > tbody > tr,
.sab-topo #ctl00__UserInfoTable table,
.sab-topo #ctl00__UserInfoTable table > tbody,
.sab-topo #ctl00__UserInfoTable table > tbody > tr {
    display: contents;
}

.sab-topo #ctl00__UserInfoTable td {
    display: flex;
    align-items: center;
    gap: 14px;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    font-size: 13px;
    white-space: nowrap;
}

.sab-topo #ctl00__UserInfoUpdatePanel {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* A linha do "acesso rápido" vem antes do usuário */
.sab-topo #ctl00__UserInfoTable > tbody > tr:last-child > td {
    order: -1;
    flex: 1;
    max-width: 420px;
    min-width: 160px;
    margin-left: auto;
}

.sab-topo #ctl00__SiteMapDropDownList {
    width: 100% !important;
    height: 42px;
    padding: 0 40px 0 16px;
    border: 0;
    border-radius: 12px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23004077' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 16px center;
    font: 14px var(--sab-fonte);
    color: var(--sab-texto);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.sab-topo .sab-avatar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 0 14px 14px 14px;
    background: var(--sab-laranja);
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.sab-topo .sab-avatar:empty {
    display: none;
}

.sab-topo .sab-usuario-nome {
    line-height: 1.35;
}

.MasterPageHeader.sab-topo .UserInfoLabels {
    font-family: var(--sab-fonte);
    font-size: 13px !important;
    font-weight: 400;
    color: #fff !important;
}

/* "Bem Vindo, Nome" numa linha só */
.sab-topo #ctl00__WellcomeMessage br {
    display: none;
}

.sab-topo #ctl00__WellcomeMessage b {
    margin-left: .3em;
    font-weight: 700;
}

.sab-topo #ctl00__SelectedRepresentative:empty,
.sab-topo #ctl00__SelectedRepresentative:empty ~ br {
    display: none;
}

/* Separadores verticais (células de 2px do layout antigo) */
.sab-topo #ctl00__UserInfoTable td[style*="width: 2px"] {
    width: 1px !important;
    height: 18px !important;
    background: rgba(255, 255, 255, .3) !important;
}

.sab-topo #ctl00__UserInfoTable a {
    color: #fff !important;
    text-decoration: none;
}

.sab-topo #ctl00__UserInfoTable a:hover {
    color: #ffd962 !important;
    text-decoration: underline;
}

/* ---------- Menu ---------- */
.sab-topo + div {
    background: #fff;
    border-bottom: 1px solid var(--sab-linha);
    font-family: var(--sab-fonte);
}

.sab-topo + div .menuHorizontal {
    padding: 0 20px;
    border: 0 !important;
    background: #fff !important;
}

.sab-topo + div #ctl00__MainMenu td {
    padding: 0 !important;
    background: transparent !important;
}

.sab-topo + div #ctl00__MainMenu a {
    display: block;
    padding: 16px 12px !important;
    border-bottom: 3px solid transparent;
    font-family: var(--sab-fonte);
    font-size: 15px !important;
    font-weight: 500;
    color: var(--sab-texto-2) !important;
    white-space: nowrap;
    text-decoration: none !important;
}

.sab-topo + div #ctl00__MainMenu a:hover,
.sab-topo + div #ctl00__MainMenu a.sab-menu-ativo {
    color: var(--sab-azul) !important;
    border-bottom-color: var(--sab-cinza);
}

.sab-topo + div #ctl00__MainMenu a.sab-menu-ativo {
    border-bottom-color: var(--sab-laranja);
}

/* Submenus */
.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] {
    padding: 6px !important;
    border: 1px solid var(--sab-linha) !important;
    border-radius: 0 12px 12px 12px;
    background: #fff !important;
    box-shadow: 0 6px 18px rgba(0, 30, 60, .10);
    font-family: var(--sab-fonte);
}

/* Tabelas internas do asp:Menu: sem margem, fundo ou cor de hover próprios */
.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] table {
    width: 100%;
    margin: 0 !important;
    border: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent !important;
}

.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] td {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
}

.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] a {
    display: block;
    padding: 10px 16px !important;
    border: 0 !important;
    border-radius: 8px;
    font-family: var(--sab-fonte);
    font-size: 13px !important;
    font-weight: 400;
    color: var(--sab-texto) !important;
    white-space: nowrap;
    text-decoration: none !important;
    background: transparent !important;
}

/* Seta de submenu: troca o triângulo preto por um chevron */
.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] td > img {
    display: none;
}

.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] tr:has(> td > img) a {
    position: relative;
    padding-right: 40px !important;
}

.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] tr:has(> td > img) a::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 7px;
    height: 7px;
    margin-top: -4px;
    border-top: 2px solid var(--sab-laranja);
    border-right: 2px solid var(--sab-laranja);
    transform: rotate(45deg);
}

.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] tr:hover > td > table {
    border-radius: 8px;
    background: var(--sab-fundo) !important;
}

.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] tr:hover a,
.sab-topo + div div[id^="ctl00__MainMenun"][id$="Items"] a:hover {
    color: var(--sab-azul) !important;
}

/* ---------- Área de conteúdo ---------- */
.sab-topo ~ #conteudo {
    padding: 0;
    background: var(--sab-fundo) !important;
    font-family: var(--sab-fonte);
}

.sab-topo ~ #conteudo > div:first-child {
    padding: 24px 32px 6px !important;
}

.sab-topo ~ #conteudo > div:first-child,
.sab-topo ~ #conteudo > div:first-child a,
.sab-topo ~ #conteudo > div:first-child span {
    font-family: var(--sab-fonte);
    font-size: 13px !important;
    font-weight: 400;
    color: var(--sab-texto-2) !important;
}

/* ---------- Acesso Rápido flutuante (painel da MasterPage) ---------- */
body:has(.sab-topo) .proposta-destaque {
    top: 150px;
    z-index: 50;
    width: 240px;
    min-width: 44px;
    height: auto;
    padding: 0;
    overflow: hidden;
    border-radius: 24px 0 0 24px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0, 30, 60, .18);
    font-family: var(--sab-fonte);
    text-align: left;
}

body:has(.sab-topo) .proposta-destaque .btn-recolher {
    display: block;
    float: none;
    width: 100%;
    margin: 0;
    padding: 12px 18px 0;
    border: 0;
    background: var(--sab-azul);
    font-size: 13px;
    color: #cfe3f2;
    opacity: 1;
    text-align: left;
    text-shadow: none;
}

body:has(.sab-topo) .proposta-destaque .btn-recolher:hover {
    color: #fff;
}

body:has(.sab-topo) .proposta-destaque .content {
    padding: 0;
}

body:has(.sab-topo) .proposta-destaque h2 {
    margin: 0;
    padding: 6px 24px 4px;
    background: var(--sab-azul);
    font-family: var(--sab-fonte);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

body:has(.sab-topo) .proposta-destaque p {
    margin: 0;
    padding: 0 24px 20px;
    background: var(--sab-azul);
    font-size: 13px;
    color: #cfe3f2;
}

body:has(.sab-topo) .proposta-destaque .grupo-opcoes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 24px 24px;
}

body:has(.sab-topo) .proposta-destaque .grupo-opcoes .btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 46px;
    margin: 0;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: var(--sab-laranja);
    box-shadow: none;
    font-family: var(--sab-fonte);
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    transition: background .15s;
}

body:has(.sab-topo) .proposta-destaque .grupo-opcoes .btn::after {
    content: "\2192";
    font-weight: 400;
}

body:has(.sab-topo) .proposta-destaque .grupo-opcoes .btn:hover {
    background: var(--sab-laranja-h);
}

/* Recolhido: aba azul estreita com o título na vertical */
body:has(.sab-topo) .proposta-destaque:has(.content.collapsed) {
    background: var(--sab-azul);
}

/* Abrir/fechar (scripts/chamada-proposta.js troca a classe .sab-ar-aberto):
   a largura anima pelo CSS e o conteúdo, com largura fixa, vai sendo revelado/recortado,
   sem esconder e reaparecer os elementos no meio da animação. */
body:has(.sab-topo) .proposta-destaque {
    width: 44px !important;
    min-height: 170px;
    transition: width .28s cubic-bezier(.4, 0, .2, 1), box-shadow .28s;
}

body:has(.sab-topo) .proposta-destaque.sab-ar-aberto {
    width: 240px !important;
}

body:has(.sab-topo) .proposta-destaque .content {
    width: 240px;
}

body:has(.sab-topo) .proposta-destaque .content.collapsed {
    width: 44px;
}

body:has(.sab-topo) .proposta-destaque .content.collapsed :is(p, .grupo-opcoes) {
    display: none !important;
}

body:has(.sab-topo) .proposta-destaque .btn-recolher {
    width: 240px;
    cursor: pointer;
}

body:has(.sab-topo) .proposta-destaque .btn-recolher:has(+ .content.collapsed) {
    width: 44px;
}

/* Conteúdo aparece suavemente ao abrir e o título vertical ao fechar */
body:has(.sab-topo) .proposta-destaque.sab-ar-aberto .content > *,
body:has(.sab-topo) .proposta-destaque h2.vertical {
    animation: sab-ar-surgir .3s ease-out both;
}

body:has(.sab-topo) .proposta-destaque.sab-ar-aberto .content > * {
    animation-delay: .08s;
}

@keyframes sab-ar-surgir {
    from { opacity: 0; }
    to { opacity: 1; }
}

body:has(.sab-topo) .proposta-destaque .btn-recolher:has(+ .content.collapsed) {
    padding: 12px 0 0;
    text-align: center;
}

body:has(.sab-topo) .proposta-destaque h2.vertical {
    position: static;
    width: auto;
    margin: 0 auto;
    padding: 12px 0 18px;
    transform: rotate(180deg);
    writing-mode: vertical-rl;
    font-size: 15px;
    text-align: center;
}

/* O "Aguarde" precisa cobrir também o painel flutuante */
body:has(.sab-topo) #ctl00__WaitingDiv {
    z-index: 100000 !important;
}

.sab-topo #ctl00__SelectedRepresentative {
    white-space: nowrap;
}

/* Usuário logado (avatar + "Bem Vindo" + representante) logo ao lado do logo;
   acesso rápido, Alterar Senha e Sair continuam à direita */
.sab-topo #ctl00__UserInfoTable td:has(> #ctl00__UserInfoUpdatePanel) {
    order: -2;
    padding-left: 24px !important;
    border-left: 1px solid rgba(255, 255, 255, .3);
}

/* O separador que ficava à direita do nome não é mais necessário */
.sab-topo #ctl00__UserInfoUpdatePanel td[style*="width: 2px"] {
    display: none !important;
}

/* ---------- Chat flutuante (Sabemi AI Hub) ---------- */
.sab-chat {
    display: none;
}

/* Só nas telas internas (cabeçalho Sabemi); não aparece no login nem nas marcas parceiras */
body:has(.sab-topo) .sab-chat {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: var(--sab-fonte);
}

/* Acima da barra fixa de contratação do simulador */
body.sab-com-barra:has(.sab-topo) .sab-chat {
    bottom: 100px;
}

.sab-chat-botao {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 0 20px 20px 20px;
    background: var(--sab-laranja);
    box-shadow: 0 10px 24px rgba(0, 30, 60, .25);
    color: #fff;
    cursor: pointer;
    transition: background .15s, transform .15s;
}

.sab-chat-botao:hover {
    background: var(--sab-laranja-h);
    transform: translateY(-2px);
}

.sab-chat-botao.sab-chat-aberto {
    background: var(--sab-azul);
}

.sab-chat-painel {
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 48px);
    overflow: hidden;
    border-radius: 0 20px 20px 20px;
    background: #fff;
    box-shadow: 0 20px 50px rgba(0, 30, 60, .28);
    animation: sab-chat-abrir .2s ease-out;
}

.sab-chat-painel[hidden] {
    display: none;
}

.sab-chat-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--sab-azul);
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.sab-chat-fechar {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    cursor: pointer;
}

.sab-chat-fechar:hover {
    background: rgba(255, 255, 255, .15);
}

.sab-chat-painel iframe {
    display: block;
    width: 400px;
    max-width: 100%;
    height: 600px;
    max-height: calc(100vh - 200px);
    border: 0;
}

@keyframes sab-chat-abrir {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* A tela de login usa a MasterPage com o cabeçalho escondido: lá o chat não aparece */
body:has(.login-shell) .sab-chat {
    display: none !important;
}
