:root {
  --sb-collapsed-w: 64px;
  --sb-expanded-w: 240px;
  --sb-text: #1a1a1a;
  --sb-text-dark: #f2f2f2;
  --sb-accent: var(--primary, #47abfc);
  --sb-bg: color-mix(in srgb, var(--sb-accent) 28%, rgba(255, 255, 255, 0.3));
  --sb-bg-dark: color-mix(
    in srgb,
    var(--sb-accent) 22%,
    rgba(0, 0, 0, 0.34)
  );
  --sb-sep: rgba(255, 255, 255, 0.18);
  --sidebar-offset-width: 0px;
}

.app-shell {
  display: flex;
  width: 100%;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.app-shell--with-sidebar {
  align-items: stretch;
}

.app-shell--full-width {
  flex-direction: column;
}

.app-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1 1 auto;
  min-height: 100vh;
  padding-top: var(--navbar-height, 70px);
}

.sidebar {
  position: sticky;
  top: 0;
  margin-left: 0;
  display: flex;
  flex: 0 0 var(--sb-collapsed-w);
  width: var(--sb-collapsed-w);
  max-width: var(--sb-expanded-w);
  height: 100vh;
  z-index: 111049;
  isolation: isolate;
  overflow: visible;
}

.sidebar .sidebar-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px;
  width: var(--sb-expanded-w);
  min-width: var(--sb-expanded-w);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--sb-bg);
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.15);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  clip-path: inset(0 calc(var(--sb-expanded-w) - var(--sb-collapsed-w)) 0 0);
  transition:
    clip-path 0.2s ease,
    box-shadow 0.2s ease;
}

.dark-mode .sidebar .sidebar-inner {
  background: var(--sb-bg-dark);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.06);
}

.sidebar .sb-section {
  border-radius: 14px;
  overflow: hidden;
  background: transparent;
  transition:
    background 0.25s ease,
    box-shadow 0.25s ease;
}

.sidebar .sb-section.active {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sb-accent) 25%, transparent)
    inset;
}

.sidebar .sb-section.active .sb-btn {
  background: color-mix(in srgb, var(--sb-accent) 15%, transparent);
  color: var(--sb-accent);
}

.sidebar .sb-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px;
  border-radius: 14px;
  font-weight: 500;
  color: var(--sb-text);
  text-decoration: none;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.dark-mode .sb-btn {
  color: var(--sb-text-dark);
}

.sidebar .sb-btn:hover {
  background: color-mix(in srgb, var(--sb-accent) 20%, transparent);
  transform: translateX(2px);
}

.sidebar .sb-btn.active {
  background: color-mix(in srgb, var(--sb-accent) 15%, transparent);
  color: var(--sb-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sb-accent) 20%, transparent)
    inset;
}

.dark-mode .sidebar .sb-btn.active {
  color: var(--sb-accent);
  background: color-mix(in srgb, var(--sb-accent) 18%, transparent);
}

body.sidebar-expanded .sidebar .sb-home-btn {
  justify-content: flex-start;
}

.sidebar .sb-home-divider {
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin: 10px 0 12px;
}

.dark-mode .sidebar .sb-home-divider {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.sidebar .sb-ico {
  width: 28px;
  text-align: center;
  font-size: 18px;
  flex: 0 0 28px;
}

.sidebar .sb-label {
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar .sb-submenu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition:
    max-height 0.3s ease,
    opacity 0.2s ease,
    margin 0.3s ease,
    transform 0.3s ease;
}

.sidebar .sb-section.open .sb-submenu {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.sidebar-expanded .sidebar .sb-section.open .sb-submenu {
  margin: 6px 0 10px 36px;
}

.sidebar .sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  padding: 6px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  opacity: 0.85;
  transition:
    background 0.2s ease,
    opacity 0.2s ease;
}

.sidebar .sb-link i {
  flex: 0 0 24px;
  text-align: center;
  font-size: 16px;
}

.sidebar .sb-link .sb-link-label {
  flex: 1 1 auto;
  white-space: nowrap;
}

.sidebar .sb-link:hover {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.dark-mode .sb-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar .sb-link.highlight {
  font-weight: 600;
}

.sidebar .sb-link.active {
  color: var(--sb-accent);
  font-weight: 600;
}

.sidebar hr.sb-sep {
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin: 6px 0;
}

.dark-mode .sidebar hr.sb-sep {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar .sb-category-label {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(26, 26, 26, 0.7);
  transition: color 0.2s ease;
}

.dark-mode .sidebar .sb-category-label {
  color: rgba(242, 242, 242, 0.7);
}

body.sidebar-expanded .sidebar .sidebar-inner {
  clip-path: inset(0 0 0 0);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

body.has-sidebar {
  --sidebar-offset-width: var(--sb-collapsed-w);
}

body.sidebar-expanded .sidebar .sb-label {
  opacity: 1;
  pointer-events: auto;
}

body:not(.sidebar-expanded) .sidebar .sb-submenu {
  width: 100%;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-submenu {
  width: var(--sb-collapsed-w);
  margin: 6px 0 10px 0;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link {
  justify-content: center;
  gap: 0;
  padding: 8px 0;
  width: 100%;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link i {
  flex: 0 0 auto;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link i.small {
  font-size: 0.875rem;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link .sb-link-label {
  display: none;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-submenu .sb-sep {
  display: none;
}

@media (max-width: 991.98px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    display: none;
  }
  body.has-sidebar,
  body.sidebar-expanded {
    --sidebar-offset-width: 0px;
  }
  .app-content {
    min-height: calc(100vh - var(--navbar-height, 70px));
  }
}
