/* ========================================================================
   DocuTrak Component Library - Azure DevOps Inspired
   ========================================================================
   Design System:
   - Azure DevOps-style density and spacing
   - Collapsible sidebar with flyout submenus
   - 8px grid system
   - WCAG 2.1 AA Compliant
   ======================================================================== */

/* ========================================================================
   APP SHELL - Master Layout
   ======================================================================== */

#app-shell {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  background-color: var(--bs-body-bg);
}

@media (max-width: 767.98px) {
  #app-shell {
    flex-direction: column;
  }
}

/* ========================================================================
   SIDEBAR - Azure DevOps Style
   ======================================================================== */

#sidebar {
  width: var(--dt-sidebar-width);
  min-width: var(--dt-sidebar-width);
  max-width: var(--dt-sidebar-width);
  flex-shrink: 0;
  background-color: var(--bs-body-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width var(--dt-transition-sidebar),
              min-width var(--dt-transition-sidebar),
              max-width var(--dt-transition-sidebar),
              background-color var(--dt-transition-base),
              border-color var(--dt-transition-base);
  z-index: var(--dt-z-sticky);
}

/* ===== Sidebar Header ===== */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  border-bottom: none;
  transition: border-color var(--dt-transition-base);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--bs-body-color);
  text-decoration: none;
  overflow: hidden;
  transition: color var(--dt-transition-fast);
}

.sidebar-brand:hover {
  color: var(--bs-primary);
  text-decoration: none;
}

.sidebar-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.sidebar-brand-icon i {
  font-size: 28px;
}

.sidebar-logo {
  max-height: 40px;
  max-width: 140px;
  width: auto;
  object-fit: contain;
}

.sidebar-brand-text {
  font-size: clamp(0.75rem, 1.1vw, 0.9rem);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: break-word;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Sidebar Navigation ===== */
.sidebar-nav-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-secondary-bg) transparent;
}

.sidebar-nav-wrapper::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav-wrapper::-webkit-scrollbar-thumb {
  background-color: var(--bs-secondary-bg);
  border-radius: 2px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 8px;
  margin: 0;
}

/* ===== Nav Section Title ===== */
.sidebar-section-title {
  display: flex;
  align-items: center;
  padding: 16px 8px 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
  margin: 0;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--dt-transition-sidebar),
              padding var(--dt-transition-sidebar);
}

/* ===== Nav Items ===== */
.sidebar-nav .nav-item {
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  color: var(--bs-body-color);
  text-decoration: none;
  border-radius: var(--dt-radius-md);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.4;
  transition: all var(--dt-transition-fast);
  position: relative;
  overflow: hidden;
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dt-transition-fast);
}

.sidebar-nav .nav-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity var(--dt-transition-sidebar),
              margin-left var(--dt-transition-sidebar);
}

/* Hover state */
.sidebar-nav .nav-link:hover {
  background-color: var(--bs-secondary-bg);
  color: var(--bs-primary);
}

.sidebar-nav .nav-link:hover i {
  transform: scale(1.05);
}

/* Active state */
.sidebar-nav .nav-link.active {
  background-color: rgba(var(--bs-primary-rgb), 0.1);
  color: var(--bs-primary);
  font-weight: 500;
}

.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background-color: var(--bs-primary);
  border-radius: 0 2px 2px 0;
}

/* ===== Submenu Support ===== */
.nav-item-has-children > .nav-link {
  padding-right: 28px;
}

.nav-item-has-children > .nav-link::after {
  content: '\F282'; /* bi-chevron-down */
  font-family: 'bootstrap-icons';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--bs-secondary-color);
  transition: transform var(--dt-transition-base);
}

.nav-item-has-children.expanded > .nav-link::after {
  transform: translateY(-50%) rotate(180deg);
}

/* Submenu container */
.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--dt-transition-slow);
}

.nav-item-has-children.expanded > .sidebar-submenu {
  max-height: 500px;
}

.sidebar-submenu .nav-item {
  margin-bottom: 0;
}

.sidebar-submenu .nav-link {
  padding-left: 34px;
  font-size: 12px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.sidebar-submenu .nav-link::before {
  display: none;
}

.sidebar-submenu .nav-link.active {
  background-color: rgba(var(--bs-primary-rgb), 0.08);
}

.sidebar-submenu .nav-link.active::before {
  display: block;
  left: 18px;
  height: 12px;
  width: 2px;
}

/* ========================================================================
   MAIN CONTENT AREA
   ======================================================================== */

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bs-body-bg);
}

/* ========================================================================
   TOP NAVBAR - Azure DevOps Style
   ======================================================================== */

.top-navbar {
  height: var(--dt-topbar-height);
  min-height: var(--dt-topbar-height);
  background-color: var(--bs-body-bg);
  border-bottom: none;
  padding: 0 16px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: var(--dt-z-sticky);
  transition: background-color var(--dt-transition-base),
              border-color var(--dt-transition-base),
              box-shadow var(--dt-transition-base);
}

.top-navbar.scrolled {
  box-shadow: none;
}

[data-bs-theme="dark"] .top-navbar.scrolled {
  box-shadow: none;
}

/* ===== Navbar Brand ===== */
.navbar-brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--dt-radius-md);
  transition: background-color var(--dt-transition-fast);
}

.navbar-brand-wrapper:hover {
  background-color: var(--bs-secondary-bg);
}

.navbar-brand-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--bs-body-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.navbar-brand-logo {
  height: 32px;
  width: auto;
  border-radius: var(--dt-radius-sm);
}

/* ===== Navbar Brand Icon (mobile/tablet — replaces hamburger) ===== */
.navbar-brand-icon-link {
  width: 36px;
  height: 36px;
  border-radius: var(--dt-radius-md);
  text-decoration: none;
  color: var(--bs-body-color);
  transition: background-color var(--dt-transition-fast);
  flex-shrink: 0;
}

.navbar-brand-icon-link:hover {
  background-color: var(--bs-secondary-bg);
}

.navbar-brand-icon-img {
  max-height: 28px;
  max-width: 28px;
  width: auto;
  object-fit: contain;
  border-radius: var(--dt-radius-sm);
}

/* Hide brand name on smaller screens to save space */
@media (max-width: 768px) {
  .navbar-brand-text {
    display: none;
  }

  .navbar-brand-wrapper {
    padding: 6px;
  }
}

/* ===== Global Search ===== */
.global-search-container {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
}

.global-search-input {
  width: 100%;
  height: 36px;
  padding: 0 16px 0 36px;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--dt-radius-full);
  font-size: 13px;
  background-color: var(--bs-secondary-bg);
  color: var(--bs-body-color);
  box-shadow: var(--dt-shadow-xs);
  transition: all var(--dt-transition-fast);
}

.global-search-input::placeholder {
  color: var(--bs-secondary-color);
}

.global-search-input:hover {
  background-color: var(--bs-tertiary-bg);
}

.global-search-input:focus {
  outline: none;
  background-color: var(--bs-body-bg);
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 2px var(--dt-focus-ring-color), var(--dt-shadow-sm);
}

.global-search-icon {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
  font-size: 14px;
  transition: color var(--dt-transition-fast);
}

.global-search-input:focus + .global-search-icon,
.global-search-container:focus-within .global-search-icon {
  color: var(--bs-primary);
}

/* Search Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: var(--bs-white);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--dt-radius-xl);
  box-shadow: var(--dt-shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: var(--dt-z-dropdown);
}

.search-section {
  padding: 8px 0;
}

.search-section:not(:last-child) {
  border-bottom: 1px solid var(--bs-border-color);
}

.search-section-title {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color var(--dt-transition-fast);
}

.search-result-item:hover,
.search-result-item.active {
  background-color: var(--bs-secondary-bg);
}

.search-result-item i {
  color: var(--bs-secondary-color);
  font-size: 16px;
  width: 16px;
  text-align: center;
}

.search-result-name {
  font-size: 13px;
  color: var(--bs-body-color);
}

.search-result-name mark {
  background-color: rgba(255, 193, 7, 0.3);
  font-weight: 500;
  padding: 0 2px;
  border-radius: 2px;
}

.search-result-meta {
  font-size: 11px;
  color: var(--bs-secondary-color);
  margin-top: 2px;
}

/* ===== Action Center (Right side of navbar) ===== */
.action-center {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.action-center-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: var(--dt-radius-md);
  color: var(--bs-body-color);
  transition: all var(--dt-transition-fast);
  cursor: pointer;
  border: none;
  background: transparent;
}

.action-center-item:hover {
  background-color: var(--bs-secondary-bg);
}

.action-center-item i {
  font-size: 16px;
}

.action-center-item .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--dt-radius-full);
}

/* ===== User Menu Trigger ===== */
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: none;
  background: transparent;
  border-radius: var(--dt-radius-full);
  color: var(--bs-body-color);
  cursor: pointer;
  transition: background-color var(--dt-transition-fast);
  height: 36px;
}

.user-menu-trigger:hover {
  background-color: var(--bs-secondary-bg);
}

.user-menu-trigger .user-badge {
  pointer-events: none;
  flex-shrink: 0;
}

.user-menu-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--bs-body-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.user-menu-chevron {
  font-size: 10px;
  color: var(--bs-secondary-color);
  transition: transform var(--dt-transition-fast);
}

.user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
  transform: rotate(180deg);
}

/* Suppress Bootstrap's default dropdown caret */
.user-menu-trigger.dropdown-toggle::after {
  display: none;
}

/* On tablet/mobile, make trigger look like other action-center items */
@media (max-width: 991.98px) {
  .user-menu-trigger {
    padding: 4px;
    gap: 0;
    width: 44px;
    height: 44px;
    justify-content: center;
    border-radius: var(--dt-radius-md);
  }
}

/* Quick Action Button (retained for DirectoryV3 toolbar use) */

/* Upload button (alias) */
.btn-upload {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 32px;
  background-color: var(--bs-primary);
  color: white;
  border: none;
  border-radius: var(--dt-radius-md);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--dt-transition-fast);
  white-space: nowrap;
}

.btn-upload:hover {
  filter: brightness(1.1);
}

.btn-upload i {
  font-size: 14px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--dt-radius-md);
  border: none;
  background: transparent;
  color: var(--bs-body-color);
  cursor: pointer;
  transition: all var(--dt-transition-fast);
}

.theme-toggle:hover {
  background-color: var(--bs-secondary-bg);
}

.theme-toggle i {
  font-size: 16px;
}

.theme-toggle .bi-sun-fill {
  display: none;
}

.theme-toggle .bi-moon-fill {
  display: inline-block;
}

[data-bs-theme="dark"] .theme-toggle .bi-sun-fill {
  display: inline-block;
}

[data-bs-theme="dark"] .theme-toggle .bi-moon-fill {
  display: none;
}

/* ========================================================================
   CARDS & SURFACES
   ======================================================================== */

.card,
.card-surface {
  background-color: var(--bs-white);
  border-radius: var(--dt-radius-lg);
  border: 1px solid var(--bs-border-color);
  transition: all var(--dt-transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--dt-shadow-md);
}

.card-header {
  background-color: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--bs-body-color);
}

.card-body {
  padding: 16px;
}

.card-body-compact {
  padding: 12px;
}

.card-footer {
  background-color: var(--bs-secondary-bg);
  border-top: 1px solid var(--bs-border-color);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--bs-secondary-color);
}

/* ========================================================================
   TABLES - Azure DevOps Style
   ======================================================================== */

.table-modern {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table-modern thead {
  position: sticky;
  top: 0;
  background-color: var(--bs-white);
  z-index: 10;
}

.table-modern thead th {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--bs-border-color);
  color: var(--bs-body-color);
  white-space: nowrap;
  background-color: var(--bs-secondary-bg);
}

.table-modern tbody tr {
  transition: background-color var(--dt-transition-fast);
}

.table-modern tbody tr:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.04);
}

.table-modern tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--bs-border-color);
  vertical-align: middle;
}

.table-row-actions {
  display: flex;
  gap: 4px;
  transition: opacity var(--dt-transition-fast);
}

/* Show row actions on hover for mouse users; always visible on touch */
@media (pointer: fine) {
  .table-row-actions {
    opacity: 0;
  }
  .table-modern tbody tr:hover .table-row-actions {
    opacity: 1;
  }
}

@media (pointer: coarse) {
  .table-row-actions {
    opacity: 1;
  }
}

/* ========================================================================
   STATUS BADGES
   ======================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--dt-radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.status-badge-draft {
  background-color: rgba(108, 117, 125, 0.12);
  color: #6c757d;
}

.status-badge-review {
  background-color: rgba(255, 193, 7, 0.15);
  color: #997404;
}

.status-badge-approved {
  background-color: rgba(25, 135, 84, 0.12);
  color: #198754;
}

.status-badge-published {
  background-color: rgba(13, 110, 253, 0.12);
  color: #0d6efd;
}

.status-badge-archived {
  background-color: rgba(108, 117, 125, 0.12);
  color: #495057;
}

/* Mobile status badge size increase for readability */
@media (max-width: 767.98px) {
  .status-badge {
    font-size: 12px;
    padding: 3px 10px;
  }
}

/* ========================================================================
   FOOTER
   ======================================================================== */

.footer {
  height: var(--dt-footer-height);
  min-height: var(--dt-footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background-color: var(--bs-white);
  border-top: 1px solid var(--bs-border-color);
  font-size: 12px;
  color: var(--bs-secondary-color);
  transition: background-color var(--dt-transition-base),
              border-color var(--dt-transition-base);
}

/* Hide footer on mobile — bottom nav provides navigation, recovers 32px */
@media (max-width: 767.98px) {
  .footer {
    display: none;
  }
}

/* ========================================================================
   MOBILE BOTTOM NAV
   ======================================================================== */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bs-white);
  border-top: 1px solid var(--bs-border-color);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-around;
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: var(--dt-z-fixed);
  transition: background-color var(--dt-transition-base),
              border-color var(--dt-transition-base);
}

[data-bs-theme="dark"] .mobile-bottom-nav {
  background-color: var(--bs-body-bg);
  border-top-color: var(--bs-border-color);
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.3);
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  min-height: 48px;
  justify-content: center;
  text-decoration: none;
  color: var(--bs-secondary-color);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--dt-transition-fast);
  border: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item i {
  font-size: 22px;
  transition: transform var(--dt-transition-fast);
}

.mobile-nav-item.active {
  color: var(--bs-primary);
  position: relative;
}

/* Active indicator: colored bar at top */
.mobile-nav-item.active::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background-color: var(--bs-primary);
}

.mobile-nav-item.active i {
  transform: scale(1.1);
}

.mobile-nav-item:hover {
  color: var(--bs-primary);
}

/* Tap feedback animation */
.mobile-nav-item:active {
  transform: scale(0.92);
  transition: transform 50ms ease;
}

/* ========================================================================
   OFFCANVAS (Mobile Sidebar)
   ======================================================================== */

.offcanvas {
  background-color: var(--bs-white);
  border-color: var(--bs-border-color);
}

.offcanvas-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bs-border-color);
}

.offcanvas-body {
  padding: 8px 0;
}

/* Mobile sidebar nav styling */
.offcanvas .sidebar-nav {
  padding: 0 12px;
}

.offcanvas .sidebar-nav .nav-item {
  margin-bottom: 2px;
}

.offcanvas .sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--bs-body-color);
  text-decoration: none;
  border-radius: var(--dt-radius-md);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.4;
  transition: all var(--dt-transition-fast);
}

.offcanvas .sidebar-nav .nav-link i {
  font-size: 18px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.offcanvas .sidebar-nav .nav-link:hover {
  background-color: var(--bs-secondary-bg);
  color: var(--bs-primary);
}

.offcanvas .sidebar-nav .nav-link.active {
  background-color: rgba(var(--bs-primary-rgb), 0.1);
  color: var(--bs-primary);
  font-weight: 500;
}

.offcanvas .sidebar-section-title {
  display: flex;
  align-items: center;
  padding: 16px 12px 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
  margin: 0;
  list-style: none;
}

/* ========================================================================
   RESPONSIVE BREAKPOINTS
   ======================================================================== */

/* Tablet and above - sidebar visible, bottom nav hidden */
@media (min-width: 768px) {
  #sidebar {
    display: flex;
  }

  .mobile-bottom-nav {
    display: none;
  }
}

/* Tablet and below */
@media (max-width: 991px) {
  .top-navbar {
    padding: 0 16px;
  }

  .top-navbar .container-fluid {
    padding: 0;
    gap: 8px;
  }

  .global-search-container {
    margin: 0;
    padding: 0 12px;
    max-width: none;
    flex: 1;
  }

  .global-search-icon {
    left: 24px;
  }

  .btn-upload span {
    display: none;
  }

  .btn-upload {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: var(--dt-radius-xl);
  }

  /* Enlarge action center touch targets on tablet and below */
  .action-center {
    gap: 8px;
  }

  .action-center-item,
  .theme-toggle {
    width: 44px;
    height: 44px;
  }

  .action-center-item i,
  .theme-toggle i {
    font-size: 20px;
  }
}

/* Mobile */
@media (max-width: 767.98px) {
  #sidebar {
    display: none;
  }

  main {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); /* Space for bottom nav + safe area */
  }

  /* Mobile top bar: just hamburger + brand on left, actions on right */
  .top-navbar {
    padding: 0 12px;
    height: 56px;
    min-height: 56px;
  }

  .navbar-brand-text {
    font-size: 15px;
    max-width: 160px;
  }

  /* ===== Full-Screen Modals on Mobile ===== */
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .modal-content {
    border-radius: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    background-color: var(--bs-white);
    border-top: 1px solid var(--bs-border-color);
    z-index: 1;
  }

  /* ===== Full-Screen Notification Panel on Mobile ===== */
  .notification-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    transform: none !important;
  }
}

/* ========================================================================
   ACCESSIBILITY
   ======================================================================== */

/* Focus States */
*:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Skip to Main Content */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background-color: var(--bs-primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 9999;
  font-weight: 500;
}

.skip-to-main:focus {
  top: 0;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Enhanced Focus Ring on Mobile (harder to see on small bright screens) */
@media (max-width: 767.98px) {
  *:focus-visible {
    outline-width: 3px;
    outline-offset: 3px;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .sidebar-nav .nav-link.active::before {
    width: 4px;
  }

  .card,
  .card-surface {
    border-width: 2px;
  }
}

/* ========================================================================
   UTILITIES
   ======================================================================== */

.text-semibold {
  font-weight: 600;
}

.text-medium {
  font-weight: 500;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Page transition animation */
main.is-transitioning {
  opacity: 0.6;
  transition: opacity 0.1s ease;
}

/* NProgress customization */
#nprogress .bar {
  height: 2px;
  background: var(--bs-primary);
}

#nprogress .spinner-icon {
  border-top-color: var(--bs-primary);
  border-left-color: var(--bs-primary);
}

/* ── Org Breadcrumb Trail ─────────────────────────── */
.org-breadcrumb {
  font-size: 0.8rem;
}

.org-crumb-link {
  color: var(--bs-secondary-color);
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.org-crumb-link:hover {
  color: var(--bs-primary);
  background-color: rgba(var(--bs-primary-rgb), 0.07);
}

.org-crumb-divider {
  color: var(--bs-tertiary-color, #adb5bd);
  font-size: 0.6rem;
  line-height: 1;
}

.org-crumb-current {
  color: var(--bs-body-color);
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  background-color: rgba(var(--bs-primary-rgb), 0.08);
  border-radius: 6px;
}
