/* Desktop: o módulo pertence à área de conteúdo, ao lado da navbar.
   Grid acompanha a largura real do menu, inclusive durante sua expansão. */
@media (min-width: 769px) {
  .main-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
  }
  .main-wrapper > .header { grid-area: 1 / 1; }
  .main-wrapper > .content-area { grid-area: 2 / 1; min-height: 0; }
  .main-wrapper:has(> .floating-window.active:not(.is-minimized)) > .content-area {
    visibility: hidden;
    pointer-events: none;
  }
  .main-wrapper > .floating-window,
  .main-wrapper > .floating-window.is-maximized {
    grid-area: 2 / 1;
    position: relative !important;
    inset: auto !important;
    align-self: stretch;
    width: auto !important;
    height: auto !important;
    min-width: 0;
    min-height: 0;
    max-width: none !important;
    max-height: none !important;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    resize: none;
    box-shadow: none;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    z-index: 1 !important;
  }
  .main-wrapper > .floating-window.is-minimized { display: none !important; }
  .main-wrapper > .floating-window .window-header { display: none; }
  .main-wrapper > .floating-window .window-body { min-height: 0; border: 0; border-radius: 0; }
  .main-wrapper > .floating-window .btn-ctrl[title="Maximizar"] { display: none; }
}

/* Navegação de página substitui os controles de janela no desktop. */
.spot-home-nav { display: none; }
@media (min-width: 769px) {
  .side-nav > .spot-home-nav {
    display: flex;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    flex-shrink: 0;
  }
  .spot-home-nav:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 12px; }
  /* O manual mantém sua ação de exportação, sem a moldura de modal. */
  .main-wrapper > #win-manual .window-header {
    display: flex;
    justify-content: flex-end;
    background: #EEF0F1;
    color: var(--text-main);
    cursor: default;
  }
  #win-manual .window-header h2,
  #win-manual .window-controls > .btn-ctrl:not(.btn-pdf-download) { display: none; }
  #win-manual .btn-pdf-download { color: #222 !important; background: #f1f1f1 !important; }
  /* O sinal de menos identifica os módulos preservados em segundo plano. */
  .side-nav .nav-opt.minimized-state .minimized-badge { display: block; }
  .side-nav:hover .nav-sub-opt.minimized-state .sub-minimized-badge { display: block; }
}

/* Retorno discreto, integrado à página, como na referência. */
.spot-module-navigation { display: none; }
@media (min-width: 769px) {
  .main-wrapper:has(> .floating-window.active:not(.is-minimized)) > .header > .spot-module-navigation {
    display: flex;
    position: absolute;
    left: 12px;
    top: 40px;
    height: 38px;
    align-items: center;
    padding: 0;
    z-index: 2;
  }
  .spot-module-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #000;
    font: inherit;
    cursor: pointer;
  }
  .spot-module-back svg {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    fill: none;
    stroke: #000 !important;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .spot-module-back:hover { color: #000; }
  .spot-module-back:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 4px; }
}

/* Mesma superfície do módulo: evita a faixa de outro cinza no topo. */
@media (min-width: 769px) {
  :root { --bg-color: #eef0f1; }
  body,
  .side-nav,
  .side-nav:hover,
  .main-wrapper,
  .main-wrapper > .header,
  .spot-module-navigation,
  .main-wrapper > .floating-window,
  .main-wrapper > .floating-window .window-body,
  .main-wrapper > .floating-window .window-body iframe,
  .floating-window.is-loading-module .window-body::before {
    background-color: var(--bg-color);
  }
}

/* Mantém a posição original do convite, sem sobrepor módulos abertos. */
body:has(.floating-window.active:not(.is-minimized)) > .fullscreen-prompt,
html.spot-account-open .fullscreen-prompt {
  display: none !important;
}

/* Chat e Manual fazem parte permanente da navbar.
   Eles continuam visíveis mesmo com módulos ou Minha conta abertos. */

/* Mobile: páginas integradas abaixo do cabeçalho, sem janela flutuante. */
@media (max-width: 768px) {
  :root { --bg-color: #EEF0F1; }
  .main-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    min-width: 0;
    height: 100%;
    background: #EEF0F1;
  }
  .main-wrapper > .header { grid-area: 1 / 1; background: #EEF0F1; }
  .main-wrapper > .content-area { grid-area: 2 / 1; min-height: 0; }
  .main-wrapper:has(> .floating-window.active:not(.is-minimized)) > .content-area {
    visibility: hidden;
    pointer-events: none;
  }
  .main-wrapper > .floating-window,
  .main-wrapper > .floating-window.is-maximized {
    grid-area: 2 / 1;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    max-width: none !important;
    max-height: none !important;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #EEF0F1;
    box-shadow: none;
    resize: none;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    z-index: 1 !important;
  }
  .main-wrapper > .floating-window.is-minimized { display: none !important; }
  .main-wrapper > .floating-window .window-header { display: none; }
  .main-wrapper > .floating-window .window-body {
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: #EEF0F1;
  }
  .main-wrapper:has(> .floating-window.active:not(.is-minimized)) > .header > .spot-module-navigation {
    display: flex;
    grid-row: 2;
    position: static;
    align-items: center;
  }
  .spot-module-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #000;
    font: inherit;
    cursor: pointer;
  }
  .spot-module-back svg {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    fill: none;
    stroke: #000 !important;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .main-wrapper > #win-manual .window-header {
    display: flex;
    justify-content: flex-end;
    background: #EEF0F1;
    cursor: default;
  }
  #win-manual .window-header h2,
  #win-manual .window-controls > .btn-ctrl:not(.btn-pdf-download) { display: none; }
  #win-manual .btn-pdf-download { color: #222 !important; background: #EEF0F1 !important; }
}
