/* App shell: fixed sidebar + slim topbar. Loaded after custom.css so the
   body padding here overrides the old navbar offset. */

body {
  padding-top: 50px;
}

#app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  background: #222;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease, transform 0.2s ease;
}

#app-topbar {
  position: fixed;
  top: 0;
  left: 220px;
  right: 0;
  height: 50px;
  background: #fff;
  border-bottom: 1px solid #e7e7e7;
  z-index: 1030;
  display: flex;
  align-items: center;
  padding: 0 15px;
  transition: left 0.2s ease;
}

#app-content {
  margin-left: 220px;
  padding-top: 15px;
  padding-bottom: 40px;
  transition: margin-left 0.2s ease;
}

#sidebar-scrim {
  display: none;
}

/* Sidebar internals */

.sidebar-brand {
  border-bottom: 1px solid #333;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  color: #fff;
  font-size: 18px;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  color: #9d9d9d;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus {
  color: #fff;
  background: #333;
  text-decoration: none;
}

.sidebar-nav li.active > a {
  color: #fff;
  background: #080808;
}

.sidebar-nav .submenu {
  display: none;
  background: #1a1a1a;
}

.sidebar-nav li.open > .submenu {
  display: block;
}

.sidebar-nav .submenu a {
  padding-left: 40px;
  font-size: 13px;
}

.submenu-caret {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s ease;
}

li.open .submenu-caret {
  transform: rotate(180deg);
}

/* Split submenu header: the label navigates (e.g. Settings goes to
   /settings) while the caret alone toggles the submenu open/closed. */
.sidebar-nav .submenu-head {
  display: flex;
  align-items: stretch;
}

.sidebar-nav .submenu-head > a:first-child {
  flex: 1;
}

.sidebar-nav .submenu-head .submenu-toggle {
  margin-left: auto;
  flex: 0 0 auto;
}

.sidebar-nav a.active {
  color: #fff;
  background: #080808;
}

body.sidebar-collapsed .submenu-head .submenu-toggle {
  display: none;
}

.sidebar-search {
  padding: 15px;
  margin-top: auto;
}

.sidebar-search .form-control {
  background: #333;
  border-color: #444;
  color: #ddd;
}

/* Collapsed icon rail (desktop only) */

@media (min-width: 768px) {
  body.sidebar-collapsed #app-sidebar {
    width: 60px;
  }

  body.sidebar-collapsed #app-topbar {
    left: 60px;
  }

  body.sidebar-collapsed #app-content {
    margin-left: 60px;
  }

  body.sidebar-collapsed .sidebar-label,
  body.sidebar-collapsed .submenu-caret,
  body.sidebar-collapsed .sidebar-search,
  body.sidebar-collapsed #app-sidebar .submenu {
    display: none;
  }

  body.sidebar-collapsed .sidebar-brand a,
  body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
}

/* Mobile: sidebar becomes an overlay drawer */

@media (max-width: 767px) {
  #app-sidebar {
    width: 260px;
    transform: translateX(-100%);
  }

  body.sidebar-open #app-sidebar {
    transform: translateX(0);
  }

  body.sidebar-open #sidebar-scrim {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
  }

  #app-topbar {
    left: 0;
  }

  #app-content {
    margin-left: 0;
  }
}

/* Mobile brand: the sidebar (and its brand) becomes an overlay drawer
   under 768px, so the topbar carries the brand next to the hamburger
   there. Desktop keeps the sidebar brand only. */
.topbar-brand {
  display: none;
  align-items: center;
  gap: 8px;
  margin-right: 10px;
  color: #3c763d;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-brand:hover,
.topbar-brand:focus {
  color: #2b542c;
  text-decoration: none;
}

/* The mobile override must come AFTER the base rule above: at equal
   specificity the later rule wins, so a base `display: none` placed
   after the media query would hide the brand at every width. */
@media (max-width: 767px) {
  .topbar-brand {
    display: inline-flex;
  }
}

/* Topbar account menu */

.topbar-account {
  margin-left: auto;
}

.topbar-account .dropdown-toggle {
  color: #333;
  text-decoration: none;
  padding: 6px 0;
  display: inline-block;
}

#sidebar-toggle {
  margin-right: 10px;
}
