/* =====================================================================
   layout.css — Page layout: topbar, sidebar, content, footer
   IDEVAPI Ajuda — v2.0 (Material Design 3 / Inter)
   ===================================================================== */

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Site Header / Topbar ───────────────────────────────────────────────── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 0 var(--color-border);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  min-height: var(--topbar-height);
}

.topbar__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar__logo img {
  height: 38px;
  width: auto;
  display: block;
}

.topbar__title {
  color: var(--color-text);
  font-size: 1rem;
  font-weight: 600;
  margin-left: 0.5rem;
  white-space: nowrap;
}

/* Mobile hamburger button (hidden on desktop) */
.topbar__menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  color: var(--color-text-muted);
  line-height: 1;
  flex-shrink: 0;
}

.hamburger {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  position: relative;
}

.hamburger::before,
.hamburger::after {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  position: absolute;
}

.hamburger::before { top: -6px; }
.hamburger::after  { top:  6px; }

/* Controls area (search + selects) */
.topbar__controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ─── Main layout grid ───────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  position: sticky;
  top: var(--gva-header-height, 74px);
  height: calc(100vh - var(--gva-header-height, 74px) - var(--footer-height, 30px));
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar__inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
}

.sidebar__controls {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ─── Content area ───────────────────────────────────────────────────────── */
#content-area {
  flex: 1;
  min-width: 0;
  outline: none;
  height: calc(100vh - var(--gva-header-height, 74px) - var(--footer-height, 30px));
  overflow-y: auto;
  overflow-x: hidden;
}

.content {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
#site-footer {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.gva-footer-stub .footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-inner img {
  height: 34px;
  width: auto;
  opacity: 0.6;
}

.footer-inner p {
  font-size: 0.82rem;
  margin: 0;
  opacity: 0.8;
}

/* ─── Mobile overlay ─────────────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 998;
}

.overlay.visible { display: block; }

/* ─── Responsive: mobile < 750px ─────────────────────────────────────────── */
@media (max-width: 750px) {
  #sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width) - 10px);
    top: 0;
    height: calc(100% - var(--footer-height, 30px));
    z-index: 999;
    transition: left 0.3s ease;
    padding-top: var(--gva-header-height, 74px);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  #sidebar.open {
    left: 0;
  }

  .topbar__menu-btn {
    display: flex;
    align-items: center;
  }

  .topbar__controls {
    gap: 0.4rem;
  }

  .content {
    padding: 1.25rem 1rem 3rem;
  }

  .topbar__logo img { height: 30px; }
  .topbar__title    { display: none; }
}

@media (min-width: 751px) {
  .topbar__menu-btn { display: none !important; }
}

/* ─── Dark mode layout overrides ────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  #sidebar {
    background: var(--color-surface);
    border-right-color: var(--color-border);
  }

  .sidebar__controls { background: #1b1e26; }

  #site-footer { background: #1b1e26; }
}
