/* ==========================================================
   App shell layout
   ========================================================== */
.app-shell {
  min-height: 100vh;
  background: var(--bs-tertiary-bg);
  display: flex;
  flex-direction: column;
}
.app-shell__body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}
.app-main {
  padding: 24px 28px;
  width: 100%;
  min-width: 0;
}
@media (max-width: 575.98px) {
  .app-main {
    padding: 16px 14px;
  }
}

/* ==========================================================
   Sidebar Navigation (desktop) — primary-color surface
   Owns the brand mark, primary nav, and footer cluster
   (locale switcher, notifications bell, user menu).
   ========================================================== */

.sidebar {
  width: 248px;
  min-width: 248px;
  height: 100vh;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  z-index: 1020;
  background: var(--bs-primary);
  color: rgba(255, 255, 255, 0.85);
  border-right: 1px solid rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------
   Brand header — logo only (collapse moved to toolbar below)
   ---------------------------------------------------------- */
.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.875rem 0.5rem;
}
.sidebar__brand-link {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: #fff;
}
.sidebar__brand-logo {
  height: 26px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  flex-shrink: 1;
  min-width: 0;
}

/* ----------------------------------------------------------
   Top toolbar — collapse / inbox / language
   3 buttons in a row when expanded; stacked icon-only when collapsed.
   ---------------------------------------------------------- */
.sidebar__toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 0.375rem 0.625rem 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar__toolbar > * {
  min-width: 0;
}
.sidebar__toolbar-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 0.5rem 0.375rem;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar__toolbar-btn:hover,
.sidebar__toolbar-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}
.sidebar__toolbar-icon {
  font-size: 1rem;
  line-height: 1;
}
.sidebar__toolbar-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.sidebar__toolbar-icon-wrap .badge {
  font-size: 0.6875rem !important;
  font-weight: 700;
  padding: 0.2em 0.4em !important;
  min-width: 1.1rem;
  line-height: 1;
  border: 2px solid var(--bs-primary);
}
.sidebar__toolbar-icon--collapsed {
  display: none;
}
.sidebar__toolbar-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1;
}
.sidebar__toolbar-btn:hover .sidebar__toolbar-label,
.sidebar__toolbar-btn[aria-expanded="true"] .sidebar__toolbar-label {
  color: rgba(255, 255, 255, 0.85);
}

/* ----------------------------------------------------------
   Nav scroll area
   ---------------------------------------------------------- */
.sidebar__nav {
  padding: 0.5rem 0;
  min-height: 0;
}
.sidebar__nav::-webkit-scrollbar { width: 3px; }
.sidebar__nav::-webkit-scrollbar-track { background: transparent; }
.sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.sidebar__nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ----------------------------------------------------------
   Group section
   ---------------------------------------------------------- */
.sidebar__group {
  margin-bottom: 0.25rem;
}
.sidebar__group-header {
  padding: 0.875rem 1.25rem 0.375rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
  user-select: none;
}

/* ----------------------------------------------------------
   Nav items
   ---------------------------------------------------------- */
.sidebar__item {
  margin: 1px 0.625rem;
  padding: 0.5rem 0.625rem;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s ease;
  letter-spacing: -0.005em;
}
.sidebar__item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.sidebar__item--active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 rgba(255, 255, 255, 0.6);
}
.sidebar__item--active:hover {
  background: rgba(255, 255, 255, 0.14);
}
.sidebar__item-icon {
  width: 1.125rem;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  opacity: 0.85;
}
.sidebar__item--active .sidebar__item-icon {
  opacity: 1;
}
.sidebar__item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------
   Footer cluster — locale switcher / notification bell / user menu
   ---------------------------------------------------------- */
.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 0.625rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
}
.sidebar__footer-btn {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar__footer-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.sidebar__footer-btn .bi {
  font-size: 1rem;
}

/* User dropup wrapper takes the remaining horizontal space */
.sidebar__footer > .dropup {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

/* User chip occupies the remaining horizontal space */
.sidebar__user {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.375rem;
  background: transparent;
  border: 0;
  border-radius: 0.375rem;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.sidebar__user:hover,
.sidebar__user[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
}
.sidebar__user-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
}
.sidebar__user-avatar span { line-height: 1; }
.sidebar__user-meta {
  flex: 1;
  min-width: 0;
  line-height: 1.15;
}
.sidebar__user-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-account {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__user-caret {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
}

/* ----------------------------------------------------------
   Locale switcher — sidebar variant (toolbar globe + EN label).
   ---------------------------------------------------------- */
.sidebar__toolbar .locale-switcher,
.sidebar__toolbar .locale-switcher__trigger {
  width: 100%;
}
.sidebar__toolbar .locale-switcher__trigger {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0.5rem 0.375rem;
  border: 0;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  background: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sidebar__toolbar .locale-switcher__trigger:hover,
.sidebar__toolbar .locale-switcher__trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}
.sidebar__toolbar .locale-switcher__trigger-icon {
  font-size: 1rem;
  line-height: 1;
}
.sidebar__toolbar .locale-switcher__trigger-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1;
}
.sidebar__toolbar .locale-switcher__trigger:hover .locale-switcher__trigger-label,
.sidebar__toolbar .locale-switcher__trigger[aria-expanded="true"] .locale-switcher__trigger-label {
  color: rgba(255, 255, 255, 0.85);
}
.sidebar__toolbar .locale-switcher__trigger-caret {
  display: none;
}

/* ----------------------------------------------------------
   Notification bell — toolbar placement.
   Panel pops out to the RIGHT of the sidebar, anchored at the top.
   ---------------------------------------------------------- */
.notification-bell--in-sidebar {
  position: relative;
}
.notification-bell--in-sidebar .notification-bell__panel {
  top: 0;
  right: auto;
  bottom: auto;
  left: calc(100% + 0.5rem);
  width: 360px;
}

/* ----------------------------------------------------------
   Content area (kept for back-compat with main wrapper class)
   ---------------------------------------------------------- */
.sidebar__content {
  min-width: 0;
}

/* ==========================================================
   Collapsed state — icon-only mini sidebar
   ========================================================== */
.sidebar--collapsed {
  width: 64px;
  min-width: 64px;
}
.sidebar--collapsed .sidebar__brand-link,
.sidebar--collapsed .sidebar__group-header,
.sidebar--collapsed .sidebar__user-meta,
.sidebar--collapsed .sidebar__user-caret,
.sidebar--collapsed .sidebar__toolbar-label,
.sidebar--collapsed .locale-switcher__trigger-label,
.sidebar--collapsed .locale-switcher__trigger-caret {
  display: none;
}
.sidebar--collapsed .sidebar__brand {
  padding: 0.625rem 0.375rem 0.375rem;
}

/* Collapsed toolbar: stack the 3 buttons vertically (icon-only) */
.sidebar--collapsed .sidebar__toolbar {
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 0.25rem 0.375rem 0.5rem;
}
.sidebar--collapsed .sidebar__toolbar-btn,
.sidebar--collapsed .sidebar__toolbar .locale-switcher__trigger {
  padding: 0.5rem 0;
}

/* Arrow direction flip on the collapse button */
.sidebar--collapsed .sidebar__toolbar-icon--expanded {
  display: none;
}
.sidebar--collapsed .sidebar__toolbar-icon--collapsed {
  display: inline-block;
}
.sidebar--collapsed .sidebar__item {
  justify-content: center;
  padding: 0.5rem;
  margin: 1px 0.5rem;
}
.sidebar--collapsed .sidebar__item > :not(.sidebar__item-icon) {
  display: none;
}
.sidebar--collapsed .sidebar__item-icon {
  font-size: 1.05rem;
}
.sidebar--collapsed .sidebar__footer {
  flex-direction: column;
  padding: 0.5rem 0.375rem;
}
.sidebar--collapsed .sidebar__user {
  justify-content: center;
}

/* ==========================================================
   Compact sidebar on notebook screens (md → xxl)
   ========================================================== */
@media (min-width: 768px) and (max-width: 1399.98px) {
  .sidebar:not(.sidebar--collapsed) {
    width: 208px;
    min-width: 208px;
  }
  .sidebar:not(.sidebar--collapsed) .sidebar__group-header {
    padding: 0.75rem 0.875rem 0.35rem;
    font-size: 0.6rem;
  }
  .sidebar:not(.sidebar--collapsed) .sidebar__item {
    margin: 1px 0.5rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }
}
