/* === CS Repair — menu lateral (cores do site + barra deslizante) === */
:root {
  --cs-sidebar-w: 260px;
  --cs-topbar-h: 64px;
}

/* Overlay (mobile) */
.cs-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 1090;
  background: rgba(13, 71, 161, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.cs-nav-open .cs-sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

/* Painel lateral — desliza no telemóvel */
.cs-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1100;
  width: min(var(--cs-sidebar-w), 88vw);
  background: var(--azul, #0d47a1);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 4px 0 20px rgba(13, 71, 161, 0.25);
  transform: translateX(-105%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.cs-nav-open .cs-sidebar {
  transform: translateX(0);
}

.cs-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
}

.cs-sidebar-head {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
  position: relative;
}

.cs-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
}

.cs-sidebar-brand img {
  height: 34px;
  width: auto;
}

.cs-sidebar-tagline {
  margin: 6px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.cs-sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.cs-sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.cs-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 3px;
}

.cs-sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

/* Barra deslizante (item activo) */
.cs-nav-slider {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  height: 44px;
  background: var(--laranja, #ff6f00);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(255, 111, 0, 0.35);
  transform: translateY(0) scaleX(1);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1), height 0.28s ease, opacity 0.2s ease;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

/* Menu público: barra segue o hover e expande da esquerda para a direita */
#siteSidebar #mainNav .cs-nav-slider {
  transform-origin: left center;
  will-change: transform;
}

#siteSidebar #mainNav .cs-nav-slider.is-sweeping {
  box-shadow: 0 2px 10px rgba(255, 111, 0, 0.28);
}

.cs-sidebar-nav.has-slider .cs-nav-slider {
  opacity: 1;
}

.cs-sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  position: relative;
  z-index: 1;
  transition: color 0.2s ease;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.cs-sidebar-link .cs-nav-icon {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  font-size: 16px;
}

.cs-sidebar-link:hover {
  color: #fff;
}

.cs-sidebar-link.is-active,
.cs-sidebar-link.active {
  color: #fff;
  font-weight: 600;
}

.cs-sidebar-link--external {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.cs-sidebar-link--logout {
  color: #fff;
}

.cs-sidebar-foot {
  padding: 10px 8px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.cs-sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-sidebar-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
  margin-left: 6px;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.cs-sidebar-sub[hidden] {
  display: none !important;
}

.cs-sidebar-sub .cs-sidebar-link {
  font-size: 13px;
  padding: 9px 12px;
}

.cs-sidebar-group-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cs-sidebar-chevron {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.65;
  transition: transform 0.2s ease;
}

.cs-sidebar-group-btn[aria-expanded="true"] .cs-sidebar-chevron {
  transform: rotate(180deg);
}

.cs-sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 14px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s;
}

.cs-sidebar-close:hover {
  background: var(--laranja, #ff6f00);
}

/* Topbar — azul do site */
.cs-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--cs-topbar-h);
  min-height: var(--cs-topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  background: var(--azul, #0d47a1);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.3s ease, background 0.3s ease;
}

.cs-topbar.scrolled {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  background: #0c3e91;
}

body.admin .cs-topbar {
  background: var(--azul, #0d47a1);
}

.cs-topbar-title {
  font-weight: 600;
  color: #fff;
  font-size: 15px;
}

.cs-topbar-brand-mini {
  font-weight: 700;
  color: #fff;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-topbar-spacer {
  flex: 1;
}

.cs-topbar-action {
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--laranja, #ff6f00);
  white-space: nowrap;
  transition: background 0.2s, transform 0.2s;
}

.cs-topbar-action:hover {
  background: #e65100;
  transform: translateY(-1px);
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.menu-toggle:hover {
  background: var(--laranja, #ff6f00);
}

body.cs-shell-public,
body.admin.cs-shell-admin {
  padding-top: calc(var(--cs-topbar-h) + env(safe-area-inset-top, 0px));
}

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

.admin-shell-main {
  min-height: calc(100vh - var(--cs-topbar-h));
}

/* Desktop: painel fixo */
@media (min-width: 1024px) {
  .cs-sidebar {
    transform: translateX(0);
  }

  .cs-sidebar-close {
    display: none;
  }

  .cs-sidebar-overlay {
    display: none !important;
  }

  body.cs-shell-public,
  body.admin.cs-shell-admin {
    padding-left: var(--cs-sidebar-w);
  }

  .cs-topbar {
    left: var(--cs-sidebar-w);
    width: calc(100% - var(--cs-sidebar-w));
  }

  .cs-topbar-brand-mini {
    display: none;
  }

  .menu-toggle {
    display: none;
  }

  body.cs-nav-open {
    overflow: auto;
  }
}

@media (max-width: 1023px) {
  body.cs-nav-open {
    overflow: hidden;
  }

  .cs-sidebar-head {
    padding-right: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-sidebar,
  .cs-sidebar-overlay,
  .cs-nav-slider {
    transition: none;
  }
}
