:root { --dei-header-height: 60px; --dei-footer-height: 55px; }
body.dei-chrome-visible { padding-top: var(--dei-header-height); padding-bottom: var(--dei-footer-height); }
#dei-header { position: fixed; z-index: 10000; top: 0; left: 0; display: flex; width: 100%; height: var(--dei-header-height); align-items: center; justify-content: center; padding: 8px 16px; border-bottom: 1px solid rgba(128,128,128,.4); background: inherit; color: inherit; }
#dei-header a { display: flex; align-items: center; color: inherit; text-decoration: none; }
#dei-header .dei-logo { position: absolute; left: 8px; height: 100%; }
#dei-header .dei-logo img { height: 40px; }
#dei-header .uc-logo img { height: 44px; }
.dei-dark-only, .dark-mode .dei-light-only { display: none; }
.dark-mode .dei-dark-only { display: block; }
#dei-footer { position: fixed; z-index: 9999; bottom: 0; left: 0; width: 100%; min-height: var(--dei-footer-height); border-top: 1px solid rgba(128,128,128,.4); background: inherit; color: inherit; }
.dei-footer-inner { display: flex; min-height: var(--dei-footer-height); align-items: center; justify-content: space-between; padding: 8px 10px; }
.dei-footer-brand { display: flex; flex-direction: column; align-items: flex-start; }
.dei-sic-logo { width: 100px; max-width: 30vw; height: auto; }
.dei-footer-text { margin-top: 3px; color: rgba(0,0,0,.6); font-size: .75rem; }
.dark-mode .dei-footer-text { color: rgba(255,255,255,.6); }
.dei-social { display: flex; align-items: center; gap: 10px; }
.dei-social a { color: #232323; opacity: .8; }
.dark-mode .dei-social a { color: #fff; }
.dei-social a:focus, .dei-social a:hover { opacity: 1; }
.dei-social img { width: 24px; height: 24px; }
.dark-mode .dei-social img { filter: invert(1); }
.dei-chrome-hidden #dei-header, .dei-chrome-hidden #dei-footer { display: none; }
.dei-chrome-toggle { margin: 0; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; }
.dei-chrome-toggle svg { width: 32px; height: 32px; fill: currentColor; }
.dei-chrome-toggle .dei-icon-collapse, .dei-chrome-hidden .dei-chrome-toggle .dei-icon-expand { display: none; }
.dei-chrome-hidden .dei-chrome-toggle .dei-icon-collapse { display: block; }
@media (max-width: 639px) {
  :root { --dei-header-height: 48px; --dei-footer-height: 48px; }
  #dei-header .dei-logo img { height: 24px; }
  #dei-header .uc-logo img { height: 30px; }
  .dei-footer-text { display: none; }
}
@media print {
  #dei-header, #dei-footer, .dei-chrome-toggle { display: none !important; }
  body.dei-chrome-visible { padding: 0; }
}

.dei-chrome-toggle.btn.btn-secondary {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 2px !important;
    border: 1px solid #007fb5 !important;
    border-radius: 4px;
    background-color: #0096d6 !important;
    color: #fff !important;
    opacity: .9;
    box-shadow: none;
}

.dei-chrome-toggle.btn.btn-secondary:hover,
.dei-chrome-toggle.btn.btn-secondary:focus,
.dei-chrome-toggle.btn.btn-secondary:focus-visible {
    border-color: #006f9f !important;
    background-color: #007fb5 !important;
    color: #fff !important;
    opacity: 1;
    outline: 2px solid rgba(0, 150, 214, .35);
    outline-offset: 2px;
}

.dei-chrome-toggle.btn.btn-secondary svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

/* Botão institucional: apenas ícone visível */
.dei-chrome-toggle.btn.btn-secondary {
    border-color: transparent !important;
    background: transparent !important;
    color: #2c363a !important;
    opacity: 1 !important;
}

.dark-mode .dei-chrome-toggle.btn.btn-secondary {
    color: #fff !important;
}

.dei-chrome-toggle.btn.btn-secondary:hover,
.dei-chrome-toggle.btn.btn-secondary:focus,
.dei-chrome-toggle.btn.btn-secondary:focus-visible {
    border-color: rgba(128, 128, 128, .25) !important;
    background: rgba(128, 128, 128, .15) !important;
    color: #0096d6 !important;
    opacity: 1 !important;
}

.dei-chrome-toggle.btn.btn-secondary {
    color: #fff !important;
}

/* Reserva espaço real para o header e footer institucionais */
body.dei-chrome-visible {
    padding: 0 !important;
}

body.dei-chrome-visible #layout {
    top: var(--dei-header-height) !important;
    bottom: var(--dei-footer-height) !important;
    height: auto !important;
}

body.dei-chrome-hidden #layout {
    top: 0 !important;
    bottom: 0 !important;
    height: auto !important;
}

/* Layout DEI em fluxo: header + Roundcube + footer, sem sobreposição */
body.dei-chrome-visible,
body.dei-chrome-hidden {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100vh !important;
    padding: 0 !important;
    overflow: hidden !important;
}

#dei-header {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    flex: 0 0 var(--dei-header-height) !important;
    width: 100% !important;
}

#dei-footer {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    flex: 0 0 var(--dei-footer-height) !important;
    width: 100% !important;
}

body.dei-chrome-visible #layout,
body.dei-chrome-hidden #layout {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
}

/* Ajuste final da altura do footer */
:root {
    --dei-footer-height: 64px;
}

#dei-footer {
    box-sizing: border-box !important;
    height: var(--dei-footer-height) !important;
    min-height: var(--dei-footer-height) !important;
}

.dei-footer-inner {
    box-sizing: border-box !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
}

.dei-sic-logo {
    width: auto !important;
    max-width: 100px !important;
    max-height: 38px !important;
}

@media (max-width: 639px) {
    :root {
        --dei-footer-height: 48px;
    }

    .dei-sic-logo {
        max-height: 32px !important;
    }
}

/* Mesmo logótipo e dimensões nos modos claro e escuro */
.dei-sic-logo {
    width: 100px !important;
    height: 38px !important;
    max-width: 100px !important;
    max-height: 38px !important;
    object-fit: contain !important;
    object-position: left center !important;
}

.dark-mode .dei-sic-logo {
    filter: brightness(0) invert(1);
}

@media (max-width: 639px) {
    .dei-sic-logo {
        width: 84px !important;
        height: 32px !important;
        max-width: 84px !important;
        max-height: 32px !important;
    }
}
/* Notificações do Roundcube acima do footer institucional */
body.dei-chrome-visible #messagestack {
    bottom: calc(var(--dei-footer-height) + 0.5rem) !important;
    z-index: 10001 !important;
}

/* Posição normal quando o header/footer estão ocultos */
body.dei-chrome-hidden #messagestack {
    bottom: 0.5rem !important;
    z-index: 10001 !important;
}
