/*
 * Sidebar theme on top of Tabler (lib/tabler). Tabler's core files are not modified;
 * all colors and sizes are --sb-* variables, so the light/dark themes only change
 * their values. The theme is chosen with data-sb-theme="light|dark" on <aside class="sb">.
 *
 * Modes (set by window.sidebarMode() in _Layout.cshtml and js/sidebar.js):
 *   html.sb-rail     sidebar collapsed to a row of icons
 *   html.sb-overlay  tablet: sidebar opened in full, temporarily over the content
 *   html.sb-open     phone: off-canvas drawer open
 */

/* ---------- Sizes ---------- */

:root {
  --sb-width: 16.25rem;
  --sb-rail-width: 4.25rem;
  --sb-header-height: 4rem;
  --app-navbar-height: 3.75rem;
  --sb-padding-x: .625rem;
  --sb-item-height: 2.375rem;
  --sb-subitem-height: 2.125rem;
  --sb-item-padding-x: .625rem;
  --sb-icon-size: 1.25rem;
  --sb-icon-gap: .75rem;
  --sb-radius: .5rem;
  --sb-transition: .2s ease;
}

/* ---------- Colors ---------- */

.sb,
.sb[data-sb-theme="light"] {
  --sb-bg: #fff;
  --sb-border: var(--tblr-border-color, #e6e7e9);
  --sb-text: #1d273b;
  --sb-text-soft: #3e4a5c;
  --sb-muted: #8a94a6;
  --sb-icon: #667382;
  --sb-hover-bg: #f3f5f8;
  --sb-active-bg: rgba(var(--tblr-primary-rgb, 6, 111, 209), .08);
  --sb-active-text: var(--tblr-primary, #066fd1);
  --sb-line: #e3e6ea;
  --sb-badge-bg: #eef1f5;
  --sb-badge-text: #4b5565;
  --sb-logo-bg: var(--tblr-primary, #066fd1);
  --sb-focus: rgba(var(--tblr-primary-rgb, 6, 111, 209), .35);
}

.sb[data-sb-theme="dark"] {
  --sb-bg: #1f2940;
  --sb-border: rgba(255, 255, 255, .08);
  --sb-text: #eef1f6;
  --sb-text-soft: #c9d1dd;
  --sb-muted: #8692a6;
  --sb-icon: #a7b1c2;
  --sb-hover-bg: rgba(255, 255, 255, .05);
  --sb-active-bg: rgba(var(--tblr-primary-rgb, 6, 111, 209), .22);
  --sb-active-text: #8cc0ff;
  --sb-line: rgba(255, 255, 255, .12);
  --sb-badge-bg: rgba(0, 0, 0, .3);
  --sb-badge-text: #fff;
  --sb-logo-bg: #fff;
  --sb-focus: rgba(255, 255, 255, .35);
}
.sb[data-sb-theme="dark"] .sb-logo { color: var(--tblr-primary, #066fd1); }

/* ---------- Layout ---------- */

.sb {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1035;
  display: flex;
  flex-direction: column;
  width: var(--sb-width);
  color: var(--sb-text);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
}

.sb-content { min-width: 0; min-height: 100vh; margin-left: var(--sb-width); }

/* Transitions only turn on after the page is shown (sb-ready), so the initial mode doesn't animate. */
.sb-ready .sb { transition: width var(--sb-transition), transform var(--sb-transition), box-shadow var(--sb-transition); }
.sb-ready .sb-content { transition: margin-left var(--sb-transition); }

.sb-backdrop { display: none; position: fixed; inset: 0; z-index: 1034; background: rgba(24, 36, 51, .45); }


/* ---------- Header ---------- */

.sb-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  height: var(--sb-header-height);
  padding: 0 .75rem 0 calc(var(--sb-padding-x) + .375rem);
}

.sb-brand { display: flex; align-items: center; gap: .625rem; min-width: 0; color: var(--sb-text, var(--tblr-body-color)); text-decoration: none; }
.sb-brand:hover { color: var(--sb-text, var(--tblr-body-color)); text-decoration: none; }
.sb-logo { display: grid; flex: none; place-items: center; width: 2rem; height: 2rem; color: #fff; background: var(--sb-logo-bg, var(--tblr-primary)); border-radius: .5rem; }
.sb-logo .ti { font-size: 1.25rem; line-height: 1; }
.sb-brand-name { overflow: hidden; font-size: 1.125rem; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; text-overflow: ellipsis; }

.sb-collapse-btn { display: grid; flex: none; place-items: center; width: 2rem; height: 2rem; padding: 0; color: var(--sb-icon); background: none; border: 0; border-radius: .375rem; }
.sb-collapse-btn:hover { color: var(--sb-text); background: var(--sb-hover-bg); }
.sb-collapse-btn .ti { font-size: 1.25rem; line-height: 1; }

/* ---------- Menu ---------- */

.sb-body { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: .25rem var(--sb-padding-x) 1rem; scrollbar-width: thin; }

.sb-section {
  padding: 1.25rem var(--sb-item-padding-x) .375rem;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--sb-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.sb-menu { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }

.sb-link,
.sb-sublink {
  display: flex;
  align-items: center;
  border-radius: var(--sb-radius);
  color: var(--sb-text);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.sb-link:hover, .sb-sublink:hover { color: var(--sb-text); background: var(--sb-hover-bg); text-decoration: none; }
.sb-link:focus-visible, .sb-sublink:focus-visible, .sb-collapse-btn:focus-visible { outline: 2px solid var(--sb-focus); outline-offset: -2px; }

.sb-link { gap: var(--sb-icon-gap); height: var(--sb-item-height); padding: 0 var(--sb-item-padding-x); font-weight: 500; }

.sb-icon { position: relative; display: inline-flex; flex: none; justify-content: center; width: var(--sb-icon-size); font-size: var(--sb-icon-size); color: var(--sb-icon); }
.sb-icon .ti { font-size: inherit; line-height: 1; }
.sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.sb-chevron { flex: none; font-size: 1rem; color: var(--sb-muted); transition: transform var(--sb-transition); }
.sb-link[aria-expanded="true"] .sb-chevron, .sb-sublink[aria-expanded="true"] .sb-chevron { transform: rotate(180deg); }

/* Active menu: soft background and primary-colored text. */
.sb-link.active, .sb-sublink.active { color: var(--sb-active-text); background: var(--sb-active-bg); font-weight: 600; }
.sb-link.active .sb-icon, .sb-link.has-active .sb-icon { color: var(--sb-active-text); }

.sb-badge { flex: none; min-width: 1.375rem; padding: .125rem .375rem; font-size: .6875rem; font-weight: 600; line-height: 1.25; text-align: center; color: var(--sb-badge-text); background: var(--sb-badge-bg); border-radius: .375rem; }

/* Red dot replacing the badge when the sidebar is collapsed. */
.sb-dot { display: none; position: absolute; top: -2px; right: -3px; width: 7px; height: 7px; background: var(--tblr-danger, #d63939); border-radius: 50%; box-shadow: 0 0 0 2px var(--sb-bg); }

/* Sub-menu: vertical line aligned with the center of the parent icon, text aligned with the parent label. */
.sb-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: .125rem 0 .375rem calc(var(--sb-item-padding-x) + var(--sb-icon-size) / 2);
  padding: 0 0 0 .5rem;
  list-style: none;
  border-left: 1px solid var(--sb-line);
}
.sb-sublink {
  gap: .5rem;
  height: var(--sb-subitem-height);
  padding: 0 var(--sb-item-padding-x) 0 calc(var(--sb-icon-size) / 2 + var(--sb-icon-gap) - .5rem - 1px);
  color: var(--sb-text-soft);
}

/* Nested sub-menus: each level's vertical line aligns with the start of its parent's text. */
.sb-submenu .sb-submenu { margin: .125rem 0 .25rem calc(var(--sb-icon-size) / 2 + var(--sb-icon-gap) - .5rem - 1px); }
.sb-sublink .sb-chevron { margin-left: auto; font-size: .875rem; }
.sb-sublink.has-active { color: var(--sb-text); font-weight: 600; }

/* ---------- Collapsed sidebar (rail) ---------- */

html.sb-rail .sb { width: var(--sb-rail-width); }
html.sb-rail .sb-content,
html.sb-overlay .sb-content { margin-left: var(--sb-rail-width); }

html.sb-rail .sb-header { flex-direction: column; justify-content: center; gap: .5rem; height: auto; padding: .875rem 0 .5rem; }
html.sb-rail .sb-section { height: 1px; margin: .75rem var(--sb-item-padding-x); padding: 0; overflow: hidden; color: transparent; background: var(--sb-border); }
html.sb-rail .sb-link { justify-content: center; padding: 0; }
html.sb-rail .sb-link.has-active { background: var(--sb-active-bg); }
html.sb-rail .sb-dot { display: block; }
html.sb-rail .sb-brand-name,
html.sb-rail .sb-label,
html.sb-rail .sb-chevron,
html.sb-rail .sb-badge,
html.sb-rail .sb-body .collapse { display: none; }

/* Tablet: full sidebar, temporarily over the content. */
html.sb-overlay .sb { box-shadow: 0 0 2.5rem rgba(24, 36, 51, .18); }
html.sb-overlay .sb-backdrop { display: block; background: rgba(24, 36, 51, .2); }

/* ---------- Drawer (phone) ---------- */

@media (max-width: 767.98px) {
  .sb { width: min(var(--sb-width), 85vw); transform: translateX(-100%); }
  html.sb-open .sb { transform: none; box-shadow: 0 0 2.5rem rgba(24, 36, 51, .25); }
  html.sb-open .sb-backdrop { display: block; }
  html.sb-open body { overflow: hidden; }
  .sb-content { margin-left: 0; }
  .sb-collapse-btn { display: none; }
}

/* ---------- Navbar above the content: breadcrumb and user ---------- */

.app-navbar { display: flex; align-items: center; gap: .75rem; min-height: var(--app-navbar-height); padding: .5rem 1.5rem; }

.sb-hamburger { display: none; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; padding: 0; color: var(--tblr-body-color, #1d273b); background: none; border: 0; border-radius: .375rem; }
.sb-hamburger:hover { background: rgba(24, 36, 51, .06); }
.sb-hamburger .ti { font-size: 1.5rem; line-height: 1; }

.app-breadcrumb-wrap { min-width: 0; }
.app-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; font-size: .75rem; color: var(--tblr-secondary, #667382); list-style: none; }
.app-breadcrumb li + li::before { content: "/"; margin: 0 .375rem; color: #c2c7cf; }
.app-breadcrumb a { color: inherit; text-decoration: none; }
.app-breadcrumb a:hover { color: var(--tblr-body-color, #1d273b); }
.app-breadcrumb [aria-current="page"] { font-weight: 600; color: var(--tblr-body-color, #1d273b); }

.app-navbar-end { display: flex; flex: none; align-items: center; gap: .5rem; margin-left: auto; }
.app-user { display: flex; align-items: center; gap: .625rem; padding: .25rem .5rem; font: inherit; color: var(--tblr-body-color, #1d273b); text-align: left; background: none; border: 0; border-radius: .5rem; }
.app-user:hover, .app-user[aria-expanded="true"] { background: rgba(24, 36, 51, .05); }
.app-user .avatar { font-weight: 600; color: var(--tblr-primary); background: rgba(var(--tblr-primary-rgb, 6, 111, 209), .1); }
.app-user-text { display: flex; flex-direction: column; line-height: 1.3; }
.app-user-name { display: flex; align-items: center; gap: .25rem; font-size: .8125rem; font-weight: 600; }
.app-user-name .ti { font-size: .875rem; color: var(--tblr-secondary, #667382); }
.app-user-sub { font-size: .75rem; color: var(--tblr-secondary, #667382); }

/* ---------- Content panel ---------- */

.app-panel { min-height: calc(100vh - var(--app-navbar-height) - 3.5rem); margin: 0 1rem; padding: 1.75rem 1.75rem 1.5rem; background: #fff; border-radius: 1rem; box-shadow: 0 1px 2px rgba(24, 36, 51, .04); }
.sb-page-footer { padding: 1rem 1.75rem 1.25rem; font-size: .75rem; color: var(--tblr-secondary, #667382); }

@media (max-width: 767.98px) {
  .app-navbar { position: sticky; top: 0; z-index: 1020; padding: .5rem 1rem; background: var(--tblr-body-bg, #f6f8fb); }
  .sb-hamburger { display: grid; }
  .app-user-text { display: none; }
  .app-panel { margin: 0; padding: 1.25rem 1rem; border-radius: 0; }
  .sb-page-footer { padding: 1rem; }
}

/* Message when the user has no menus at all. */
.sb-empty { padding: 1rem var(--sb-item-padding-x); font-size: .8125rem; color: var(--sb-muted); }
html.sb-rail .sb-empty { display: none; }
