/* ==========================================================================
   Estrutura do portal: menu lateral + cabeçalho
   - PC (≥ 1024px): menu fixo à esquerda, recolhível para só ícones
   - Tablet/celular: menu vira gaveta que abre por cima do conteúdo
   ========================================================================== */
:root {
  --sb-w: 264px;
  --sb-w-mini: 78px;
  --hdr-h: 64px;
  --sb-bg: linear-gradient(180deg, #0b6a61 0%, #08534c 50%, #063f3a 100%);

  /* Paleta do portal: verde da Engenharia (diferente dos portais azul/amarelo da Bakof Tec) */
  --navy: #0b4f49;
  --navy-800: #083f3a;
  --navy-900: #052f2b;
  --eng-accent: #6fe3cf;
  --bg: #f1f6f5;
  --border: #e0e9e7;
  --border-strong: #cbd9d6;
  --shadow-xs: 0 1px 2px rgba(5, 47, 43, .06);
  --shadow-sm: 0 1px 3px rgba(5, 47, 43, .08), 0 1px 2px rgba(5, 47, 43, .04);
  --shadow: 0 4px 16px rgba(5, 47, 43, .08), 0 1px 3px rgba(5, 47, 43, .05);
  --shadow-lg: 0 18px 48px rgba(5, 47, 43, .16), 0 4px 12px rgba(5, 47, 43, .06);
}

body.admin { min-height: 100vh; }

/* ---------- Menu lateral ---------- */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 70;
  width: var(--sb-w);
  display: flex; flex-direction: column;
  background: var(--sb-bg);
  color: #fff;
  box-shadow: 1px 0 0 rgba(255,255,255,.04), 6px 0 24px rgba(5, 47, 43, .12);
  transition: width .25s var(--ease), transform .3s var(--ease);
  overflow: hidden;
}
.sb-top {
  height: var(--hdr-h); flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 0 22px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sb-brand { display: flex; align-items: center; text-decoration: none !important; }
.sb-logo-full { height: 36px; width: auto; display: block; }
.sb-logo-mini {
  display: none; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--eng-accent); color: var(--navy-900); font-weight: 900; font-size: 1.25em; letter-spacing: -.02em;
  box-shadow: 0 4px 14px rgba(111, 227, 207, .25);
}
.sb-close {
  display: none; width: 38px; height: 38px; border-radius: 10px; place-items: center;
  border: 1px solid rgba(255,255,255,.18); background: transparent; color: #fff; cursor: pointer;
}
.sb-close svg { width: 20px; height: 20px; }
.sb-portal {
  padding: 14px 24px 2px; flex: none;
  font-size: .7em; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--eng-accent); white-space: nowrap;
}

.sb-nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 6px 14px 18px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sb-section {
  margin: 18px 10px 6px;
  font-size: .68em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(207, 233, 229, .55); white-space: nowrap;
  position: relative;
}

.sb-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 44px; padding: 0 12px; margin: 2px 0;
  border: 0; border-radius: 11px; background: transparent;
  color: #cfe9e5; font: inherit; font-size: .92em; font-weight: 500; text-align: left;
  text-decoration: none !important; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s;
}
.sb-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sb-link:focus-visible { outline: 2px solid var(--eng-accent); outline-offset: -2px; }
.sb-link.active {
  background: rgba(255,255,255,.13); color: #fff; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.sb-link.active::before {
  content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--eng-accent);
}
.sb-icon { position: relative; flex: none; display: grid; place-items: center; width: 24px; height: 24px; }
.sb-icon svg { width: 20px; height: 20px; }
.sb-link.active .sb-icon { color: var(--eng-accent); }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sb-count {
  flex: none; min-width: 22px; height: 22px; padding: 0 7px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--eng-accent); color: var(--navy-900); font-size: .74em; font-weight: 800;
}
.sb-dot {
  display: none; position: absolute; top: -2px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--eng-accent); border: 2px solid #07504a;
}

.sb-bottom { flex: none; padding: 10px 14px 14px; border-top: 1px solid rgba(255,255,255,.07); }
.sb-push.on { color: #b5f3dc; }
.sb-push.on .sb-icon { color: #5ee0b0; }

.sb-user { position: relative; margin-top: 4px; }
.sb-user-btn {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05);
  color: #fff; font: inherit; text-align: left; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.sb-user-btn:hover, .sb-user-btn[aria-expanded="true"] { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); }
.sb-user-btn .avatar { width: 36px; height: 36px; flex: none; font-size: .82em; }
.sb-user-info { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.sb-user-info strong { font-size: .88em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-info small { font-size: .74em; color: #a6d3cc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-chev { flex: none; display: grid; color: #a6d3cc; transition: transform .2s var(--ease); }
.sb-user-chev svg { width: 16px; height: 16px; }
.sb-user-btn[aria-expanded="true"] .sb-user-chev { transform: rotate(180deg); }
.sb-user .dropdown {
  top: auto; bottom: calc(100% + 8px); left: 0; right: 0; min-width: 0;
  transform: translateY(6px) scale(.98);
}
.sb-user .dropdown.open { transform: none; }
.sb-user .dropdown .who { word-break: break-all; }

.sb-backdrop {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(4, 30, 27, .5);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}

/* ---------- Cabeçalho do conteúdo ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--hdr-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(16px, 2.4vw, 36px);
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.hdr-btn {
  position: relative; flex: none;
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.hdr-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--navy); }
.hdr-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.hdr-btn svg { width: 19px; height: 19px; }
.hdr-logo { display: none; }
.hdr-logo img { height: 30px; width: auto; display: block; }
.hdr-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; font-size: .92em; }
.hdr-crumb { color: var(--muted); font-weight: 500; }
.hdr-sep { color: var(--border-strong); }
.hdr-title strong { color: var(--navy); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.hdr-actions { display: flex; align-items: center; gap: 14px; flex: none; }
.hdr-date { font-size: .84em; color: var(--muted); font-weight: 500; }
.hdr-date::first-letter { text-transform: uppercase; }
.hdr-bell .bell-count { border-color: #fff; }
.app-header .notif-dropdown { right: 0; }

/* ---------- Conteúdo fluido ---------- */
body.admin .admin-wrap {
  max-width: 1560px;
  padding: clamp(20px, 2.6vw, 36px) clamp(16px, 2.4vw, 36px) 64px;
}
body.admin .admin-wrap.narrow { max-width: 920px; }
.install-banner .inner { max-width: none; padding-left: clamp(16px, 2.4vw, 36px); padding-right: clamp(16px, 2.4vw, 36px); }
.detail-side { top: calc(var(--hdr-h) + 20px); }

/* ---------- PC: menu fixo ---------- */
@media (min-width: 1024px) {
  body.admin:has(.app-sidebar) { padding-left: var(--sb-w); transition: padding-left .25s var(--ease); }

  /* recolhido: só ícones */
  html.sb-collapsed body.admin:has(.app-sidebar) { padding-left: var(--sb-w-mini); }
  html.sb-collapsed .app-sidebar { width: var(--sb-w-mini); overflow: visible; }
  html.sb-collapsed .sb-top { padding: 0; justify-content: center; }
  html.sb-collapsed .sb-logo-full,
  html.sb-collapsed .sb-portal,
  html.sb-collapsed .sb-label,
  html.sb-collapsed .sb-count,
  html.sb-collapsed .sb-user-info,
  html.sb-collapsed .sb-user-chev { display: none; }
  html.sb-collapsed .sb-logo-mini { display: grid; }
  html.sb-collapsed .sb-nav { padding: 10px 12px 18px; overflow: visible; }
  html.sb-collapsed .sb-section { margin: 14px 8px 8px; height: 1px; background: rgba(255,255,255,.12); }
  html.sb-collapsed .sb-section span { display: none; }
  html.sb-collapsed .sb-link { justify-content: center; padding: 0; }
  html.sb-collapsed .sb-link.active::before { left: -12px; }
  html.sb-collapsed .sb-dot { display: block; }
  html.sb-collapsed .sb-bottom { padding: 10px 12px 14px; }
  html.sb-collapsed .sb-user-btn { justify-content: center; padding: 6px; }
  html.sb-collapsed .sb-user .dropdown {
    left: calc(100% + 14px); right: auto; bottom: 0; width: 240px;
    transform: translateX(-6px) scale(.98);
  }
  html.sb-collapsed .sb-user .dropdown.open { transform: none; }

  /* dica com o nome da aba ao passar o mouse no menu recolhido */
  html.sb-collapsed .sb-link[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%);
    padding: 7px 11px; border-radius: 8px;
    background: var(--navy-900); color: #fff; font-size: .82em; font-weight: 600; white-space: nowrap;
    box-shadow: var(--shadow-lg); pointer-events: none; z-index: 80;
    animation: fadeIn .15s var(--ease);
  }
}

/* ---------- Telas médias: some a data ---------- */
@media (max-width: 1280px) {
  .hdr-date { display: none; }
}

/* ---------- Tablet e celular: gaveta ---------- */
@media (max-width: 1023.98px) {
  .app-sidebar { width: min(300px, 86vw); transform: translateX(-102%); box-shadow: none; }
  .sb-close { display: inline-grid; }
  html.sb-open .app-sidebar { transform: none; box-shadow: 12px 0 40px rgba(4, 30, 27, .35); }
  html.sb-open .sb-backdrop { opacity: 1; pointer-events: auto; }
  html.sb-open, html.sb-open body { overflow: hidden; }
  .sb-link { min-height: 48px; font-size: .96em; }

  .hdr-logo { display: block; }
  .hdr-title { display: none; }
  .hdr-actions { margin-left: auto; }
}

@media (max-width: 760px) {
  :root { --hdr-h: 58px; }
  .app-header { gap: 10px; }
  .hdr-logo img { height: 27px; }
  .app-header .notif-dropdown { position: fixed; top: calc(var(--hdr-h) + 6px); left: 12px; right: 12px; width: auto; }
}

@media print {
  .app-sidebar, .sb-backdrop, .app-header { display: none !important; }
  body.admin { padding-left: 0 !important; }
}

/* ícone do botão do menu: painel no PC, hambúrguer no celular */
.hdr-btn .ico-pc, .hdr-btn .ico-mob { display: grid; }
.hdr-btn .ico-mob { display: none; }
@media (max-width: 1023.98px) {
  .hdr-btn .ico-pc { display: none; }
  .hdr-btn .ico-mob { display: grid; }
}

/* ---------- Detalhes da paleta verde ---------- */
.avatar { background: var(--eng-accent); color: var(--navy-900); }
.etapa.minha { background: linear-gradient(90deg, rgba(0, 128, 118, .08), transparent 60%); box-shadow: inset 3px 0 0 var(--teal); }
.login-hero {
  background:
    radial-gradient(600px 400px at 90% 110%, rgba(43, 179, 166, .55), transparent 60%),
    radial-gradient(500px 360px at 0% 0%, rgba(111, 227, 207, .16), transparent 60%),
    linear-gradient(145deg, #052f2b, #0b6a61);
}
