/* Sidebar and top navbar (CMS and Operator Portal) */

:root {
  --sb-blue: #152F4D;
  --sb-orange: #EF7D30;
  --sb-width: 232px;
  --sb-width-contracted: 52px;
  --sb-header-height: 48px;
}

/* ---------- Sidebar shell ---------- */

.sb-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
  width: 100%;
  max-width: 280px;
  background: var(--sb-blue);
  color: #ffffff;
  overflow-y: auto;
}

.sb-sidebar.sb-animate {
  transition: width .16s ease;
}

.sb-header {
  position: relative;
  height: var(--sb-header-height);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Trimmed artwork (no transparent padding), so it fills the header height */
.sb-logo {
  display: block;
  width: auto;
  height: 26px;
}

.sb-logo-contracted {
  display: none;
  height: 30px;
}

.sb-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 6px;
  color: rgba(255, 255, 255, .7);
  background: none;
  border: 0;
}

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

.sb-body {
  display: flex;
  flex-direction: column;
  min-height: calc(100% - var(--sb-header-height));
}

.sb-nav {
  padding: 0 8px 20px;
}

.sb-footer {
  margin-top: auto;
  padding: 6px 0 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ---------- Rows ---------- */

.sb-item {
  margin-bottom: 2px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .1s ease, color .1s ease;
}

.sb-link:focus-visible {
  outline: 2px solid var(--sb-orange);
  outline-offset: -2px;
}

.sb-level-2 > .sb-link {
  height: 30px;
  padding-left: 37px;
  font-size: 12.5px;
}

.sb-level-3 > .sb-link {
  height: 29px;
  padding-left: 51px;
  font-size: 12px;
}

.sb-icon {
  flex: none;
  width: 16px;
  font-size: 14px;
  text-align: center;
  color: rgba(255, 255, 255, .55);
}

.sb-icon-svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -.125em;
}

.sb-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-badge {
  flex: none;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--sb-orange);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 15px;
  text-align: center;
}

.sb-rail-badge {
  display: none;
}

/* Unread counts stay red in every state, so they keep reading as "action needed" */
.sb-badge.is-danger,
.sb-link:hover .sb-badge.is-danger,
.sb-item.is-active > .sb-link .sb-badge.is-danger {
  background: #e11d48;
  color: #ffffff;
}

.sb-chevron {
  flex: none;
  font-size: 9px;
  opacity: .5;
  transition: transform .16s ease;
}

.sb-toggle[aria-expanded="true"] .sb-chevron {
  transform: rotate(90deg);
}

.sb-flyout-title {
  display: none;
}

/* Hover and current page: orange row, white text, blue icon */
.sb-link:hover,
.sb-item.is-active > .sb-link {
  background: var(--sb-orange);
  color: #ffffff;
}

.sb-link:hover .sb-icon,
.sb-item.is-active > .sb-link .sb-icon {
  color: var(--sb-blue);
}

.sb-link:hover .sb-badge,
.sb-item.is-active > .sb-link .sb-badge {
  background: var(--sb-blue);
  color: #ffffff;
}

/* ---------- Desktop layout ---------- */

@media (min-width: 992px) {
  .sb-sidebar {
    width: var(--sb-width);
    max-width: none;
  }

  .sb-sidebar ~ .content {
    margin-left: var(--sb-width);
  }

  .sb-sidebar.sb-animate ~ .content {
    transition: margin-left .16s ease;
  }

  .sb-close {
    display: none;
  }

  /* ---------- Contracted rail ---------- */

  .sb-sidebar.contracted {
    width: var(--sb-width-contracted);
    overflow: visible;
  }

  .sb-sidebar.contracted ~ .content {
    margin-left: var(--sb-width-contracted);
  }

  .sb-sidebar.contracted .sb-logo {
    display: none;
  }

  .sb-sidebar.contracted .sb-logo-contracted {
    display: block;
  }

  .sb-sidebar.contracted .sb-nav:not(.sb-footer) {
    padding-top: 6px;
  }

  .sb-sidebar.contracted .sb-level-1 {
    position: relative;
  }

  .sb-sidebar.contracted .sb-level-1 > .sb-link {
    justify-content: center;
    height: 36px;
    padding: 0;
  }

  .sb-sidebar.contracted .sb-level-1 > .sb-link .sb-icon {
    font-size: 16px;
    width: 18px;
  }

  .sb-sidebar.contracted .sb-level-1 > .sb-link .sb-label,
  .sb-sidebar.contracted .sb-level-1 > .sb-link .sb-chevron,
  .sb-sidebar.contracted .sb-level-1 > .sb-link .sb-badge {
    display: none;
  }

  .sb-sidebar.contracted .sb-level-1 > .sb-link .sb-rail-badge {
    display: block;
    position: absolute;
    top: -3px;
    right: -5px;
    min-width: 14px;
    padding: 0 3px;
    font-size: 8.5px;
    line-height: 14px;
  }

  /* A parent of the current page reads as selected on the rail */
  .sb-sidebar.contracted .sb-level-1.is-open-path > .sb-link {
    background: var(--sb-orange);
  }

  .sb-sidebar.contracted .sb-level-1.is-open-path > .sb-link .sb-icon {
    color: var(--sb-blue);
  }

  .sb-sidebar.contracted .sb-level-1.is-open-path > .sb-link .sb-rail-badge {
    background: var(--sb-blue);
    color: #ffffff;
  }

  .sb-sidebar.contracted .sb-level-1 > .sb-link .sb-rail-badge.is-danger {
    background: #e11d48;
    color: #ffffff;
  }

  /* ---------- Hover sub-menu (contracted only) ---------- */

  .sb-sidebar.contracted .sb-sub {
    display: none !important;
  }

  .sb-sidebar.contracted .sb-level-1.is-flyout > .sb-sub {
    display: block !important;
    position: fixed;
    left: var(--sb-width-contracted);
    z-index: 1031;
    width: 239px;
    height: auto !important;
    /* transparent gap that keeps the pointer inside the item */
    padding-left: 7px;
  }

  .sb-sidebar.contracted .sb-sub .collapse {
    display: block !important;
    height: auto !important;
  }

  .sb-sidebar.contracted .sb-sub-inner {
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 6px;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(12, 26, 44, .24);
  }

  .sb-sidebar.contracted .sb-flyout-title {
    display: block;
    margin-bottom: 5px;
    padding: 7px 10px 8px;
    border-bottom: 1px solid #EEF1F4;
    color: var(--sb-blue);
    font-size: 12.5px;
    font-weight: 600;
  }

  .sb-sidebar.contracted .sb-sub .sb-link {
    height: 31px;
    padding: 0 9px 0 10px;
    border-radius: 7px;
    color: #4B5563;
    font-size: 12.5px;
    font-weight: 400;
  }

  .sb-sidebar.contracted .sb-sub .sb-level-3 > .sb-link {
    padding-left: 18px;
  }

  /* A 2nd-level group becomes a header over its items */
  .sb-sidebar.contracted .sb-sub .sb-toggle {
    height: auto;
    padding: 11px 10px 4px;
    background: none;
    color: #A3ACB8;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    pointer-events: none;
  }

  .sb-sidebar.contracted .sb-sub .sb-toggle .sb-chevron {
    display: none;
  }

  .sb-sidebar.contracted .sb-sub .sb-link:not(.sb-toggle):hover,
  .sb-sidebar.contracted .sb-sub .sb-item.is-active > .sb-link {
    background: var(--sb-orange);
    color: #ffffff;
  }

  .sb-sidebar.contracted .sb-sub .sb-badge {
    background: rgba(239, 125, 48, .16);
    color: #B4551A;
    font-weight: 700;
  }

  .sb-sidebar.contracted .sb-sub .sb-link:not(.sb-toggle):hover .sb-badge,
  .sb-sidebar.contracted .sb-sub .sb-item.is-active > .sb-link .sb-badge {
    background: var(--sb-blue);
    color: #ffffff;
    font-weight: 600;
  }
}

/* ---------- Top navbar ---------- */

.sb-navbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  margin: 0 -1rem 1rem;
  padding: 0 18px 0 12px;
  background: #ffffff;
  border-bottom: 1px solid #E5E7EB;
}

.sb-navbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: #F2F4F6;
  color: #374151;
  transition: background .12s ease;
}

.sb-navbar-toggle:hover {
  background: #E9EDF1;
}

.sb-navbar-confidential {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: #6B7280;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .08em;
}

.sb-navbar-spacer {
  flex: 1;
}

.sb-chips {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sb-chip {
  padding: 4px 11px;
  border: 1px solid #E5E7EB;
  border-radius: 999px;
  color: #4B5563;
  font-size: 11.5px;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.sb-chip:hover {
  border-color: #D1D5DB;
  color: var(--sb-blue);
}

.sb-chip.is-current {
  border-color: var(--sb-orange);
  color: #B4551A;
  font-weight: 600;
}

.sb-navbar-divider {
  width: 1px;
  height: 20px;
  margin: 0 3px;
  background: #E5E7EB;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 7px 3px 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  transition: background .12s ease;
}

.sb-user:hover,
.sb-user[aria-expanded="true"] {
  background: #E9EDF1;
}

.sb-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sb-orange);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
}

.sb-user-name {
  color: var(--sb-blue);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.sb-user-chevron {
  color: #9CA3AF;
  font-size: 9px;
}
