/* ==========================================
   SIDEBAR E ÁREA PRINCIPAL
========================================== */
.sidebar {
  box-sizing: border-box;
  width: 260px;
  overflow: visible;
  transition: width 280ms cubic-bezier(.22, 1, .36, 1), transform 280ms ease;
}

.sidebar *,
.sidebar *::before,
.sidebar *::after {
  box-sizing: border-box;
}

.main-area {
  margin-left: 260px;
  transition: margin-left 280ms cubic-bezier(.22, 1, .36, 1);
}

/* ==========================================
   CABEÇALHO DA SIDEBAR (ESTADO EXPANDIDO)
========================================== */
.brand-row {
  height: 84px;
  min-height: 84px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  transition: opacity 250ms ease, transform 250ms ease;
  transform-origin: left center;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 165px;
  height: auto;
  object-fit: contain;
}

.brand-toggle {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #7E93AE;
  background: transparent;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.brand-toggle:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.brand-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

/* ==========================================
   SIDEBAR RECOLHIDA — DESKTOP
========================================== */
@media (min-width: 761px) {
  .sidebar-collapsed .sidebar {
    width: 76px;
    transform: translateX(0);
  }

  .sidebar-collapsed .main-area {
    margin-left: 76px;
  }

  .sidebar-collapsed .brand-row {
    justify-content: center;
    padding: 0;
  }

  /* Ocultamos a logo suavemente */
  .sidebar-collapsed .brand {
    opacity: 0;
    transform: scale(0.92);
    pointer-events: none;
    position: absolute;
  }

  /* Botão centralizado e com aspecto "glass" */
  .sidebar-collapsed .brand-toggle {
    position: relative;
    inset: auto;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    opacity: 1;
    color: #AFC2DA;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  .sidebar-collapsed .brand-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
  }

  .sidebar-collapsed .brand-toggle svg {
    width: 20px;
    height: 20px;
  }

  /* Esconde os textos e ícones extras */
  .sidebar-collapsed .workspace-info,
  .sidebar-collapsed .workspace-switch > .bare-icon,
  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .nav-item > span:not(.nav-dot),
  .sidebar-collapsed .profile-text {
    display: none;
  }

  /* Centraliza elementos restantes */
  .sidebar-collapsed .workspace-switch {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar-collapsed .nav-list {
    padding-left: 10px;
    padding-right: 10px;
  }

  .sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    position: relative;
  }

  .sidebar-collapsed .nav-item > i {
    margin: 0;
  }

  .sidebar-collapsed .nav-count {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 7px;
    width: 7px;
    height: 7px;
    padding: 0;
    overflow: hidden;
    border-radius: 50%;
    font-size: 0;
  }

  .sidebar-collapsed .nav-dot {
    position: absolute;
    top: 7px;
    right: 8px;
  }

  .sidebar-collapsed .sidebar-bottom {
    padding-left: 10px;
    padding-right: 10px;
  }

  .sidebar-collapsed .profile-row {
    justify-content: center;
    padding: 10px 0;
  }

  .sidebar-collapsed .profile-menu-container {
    width: 100%;
  }

  .sidebar-collapsed .profile-menu-trigger {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 25px;
    height: 25px;
    background: var(--primary-light);
    border-radius: 50%;
  }

  .sidebar-collapsed .profile-dropdown {
    left: calc(100% + 12px);
    bottom: 0;
    transform-origin: bottom left;
  }
}

/* ==========================================
   ROLAGEM SEM BARRA VISÍVEL
========================================== */
.sidebar-navigation {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar-navigation::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* ==========================================
   MENU DO PERFIL
========================================== */
.profile-menu-container {
  position: relative;
  width: 100%;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  position: relative;
}

.profile-menu-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #B9C8DB;
  background: transparent;
  transition: background 180ms ease, color 180ms ease;
  cursor: pointer;
}

.profile-menu-trigger:hover,
.profile-menu-trigger[aria-expanded="true"] {
  color: #FFFFFF;
  background: rgba(255,255,255,.12);
}

.profile-menu-trigger svg {
  width: 19px;
  height: 19px;
}

.profile-dropdown {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 300;
  width: 100%;
  min-width: 205px;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  background: #102744;
  box-shadow: 0 12px 35px rgba(0,0,0,.28);
  transform-origin: bottom left;
  animation: profileDropdownIn 180ms ease;
}

.profile-dropdown[hidden] {
  display: none;
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #E4ECF5;
  text-decoration: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  transition: background 160ms ease;
}

.profile-dropdown-item:hover {
  background: rgba(255,255,255,.09);
}

.profile-dropdown-item svg {
  width: 17px;
  height: 17px;
  color: #AFC2DA;
}

.profile-dropdown-divider {
  height: 1px;
  margin: 5px 4px;
  background: rgba(255,255,255,.1);
}

.logout-option {
  color: #FFB4B4;
}

.logout-option svg {
  color: #FF9999;
}

@keyframes profileDropdownIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================
   TOPBAR
========================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

/* ==========================================
   MOBILE
========================================== */
@media (max-width: 760px) {
  .sidebar {
    width: min(290px, 85vw);
    transform: translateX(-100%);
    overflow: visible;
  }
  .main-area {
    margin-left: 0;
  }
  .mobile-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-collapsed .sidebar {
    width: min(290px, 85vw);
    transform: translateX(-100%);
  }
  .sidebar-collapsed .main-area {
    margin-left: 0;
  }
  .sidebar-close {
    display: flex;
  }
  .brand-toggle {
    display: none;
  }
  .profile-dropdown {
    width: 100%;
  }
}