html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

header {
  position: relative;
  z-index: 1020;
  overflow: visible !important;
}

header > nav {
  overflow: visible !important;
}

/* Prevent horizontal scroll */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.container-fluid {
  max-width: 100%;
  overflow-x: hidden;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Responsive Navbar Styles */
.navbar {
  padding: 0.75rem 1rem;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-y: visible;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  z-index: 1020;
}

.navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: -1;
}

.navbar > .container-fluid {
  max-width: 100%;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  overflow: visible !important;
  position: static;
  min-height: 56px;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 600;
  padding: 0.5rem 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.navbar-collapse {
  flex-grow: 1;
  overflow: visible !important;
  max-width: 100%;
  min-width: 0;
  position: static;
  z-index: 1000;
}

.navbar-nav {
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
  position: static;
  overflow: visible !important;
}

.navbar-nav.me-auto {
  flex: 1;
  min-width: 0;
  overflow: visible !important;
  display: flex;
  flex-wrap: wrap;
  max-width: calc(100vw - 300px); /* Reserve space for brand, toggle, and profile */
  padding-right: 0.5rem;
  gap: 0.25rem;
  position: static;
  z-index: 1000;
}

/* Responsive text visibility */
@media (max-width: 575.98px) {
  .navbar-nav .nav-link span.d-lg-inline,
  .navbar-nav .nav-link span.d-md-inline {
    display: none !important;
  }
  
  .navbar-nav .nav-link span.d-lg-none {
    display: inline !important;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  .navbar-nav .nav-link span.d-lg-inline {
    display: none !important;
  }
  
  .navbar-nav .nav-link span.d-lg-none {
    display: inline !important;
  }
}

.navbar-nav .nav-item {
  margin: 0;
  flex-shrink: 0;
  position: static;
}

.navbar-nav .nav-item.dropdown {
  position: static;
}

@media (min-width: 992px) {
  .navbar-nav .nav-item.dropdown {
    position: relative;
  }
}

.navbar-nav .nav-link {
  padding: 0.5rem 0.4rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-size: 0.875rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navbar-nav.ms-lg-auto {
  flex-shrink: 0;
  margin-left: auto !important;
  padding-left: 0.5rem;
  max-width: 200px;
}

.navbar-nav .nav-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #0d6efd !important;
}

.navbar-nav .nav-link.active {
  background-color: rgba(13, 110, 253, 0.1);
  color: #0d6efd !important;
}

.navbar-nav .dropdown-menu {
  margin-top: 0.125rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  position: absolute;
  z-index: 1050;
  min-width: 200px;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  top: 100%;
  left: 0;
}

@media (min-width: 992px) {
  .navbar-nav .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
  }
  
  .navbar-nav .dropdown-menu-end {
    left: auto;
    right: 0;
  }
}

/* Ensure profile dropdown positions correctly */
.navbar-nav .dropdown-menu-end {
  right: 0;
  left: auto;
}

.navbar-nav .dropdown-item {
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

.navbar-nav .dropdown-item i {
  width: 20px;
  margin-right: 0.5rem;
  text-align: center;
}

.navbar-nav .dropdown-item:hover {
  background-color: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
}

/* Mobile Responsive Styles */
@media (max-width: 991.98px) {
  .navbar-collapse {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  .navbar-nav {
    flex-direction: column;
    align-items: flex-start !important;
    width: 100%;
    flex-wrap: nowrap;
  }

  .navbar-nav.me-auto {
    flex: none;
    max-width: 100%;
  }

  .navbar-nav .nav-item {
    width: 100%;
    margin: 0.25rem 0;
  }

  .navbar-nav .nav-link {
    width: 100%;
    padding: 0.75rem 1rem;
    justify-content: flex-start;
  }

  .navbar-nav .dropdown-menu {
    position: static !important;
    float: none;
    width: 100%;
    margin-top: 0;
    margin-left: 0;
    background-color: rgba(0, 0, 0, 0.02);
    border: none;
    box-shadow: none;
    right: auto !important;
    left: auto !important;
  }

  .navbar-nav .dropdown-item {
    padding-left: 2.5rem;
  }

  .navbar-nav.ms-lg-auto {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-left: 0 !important;
    width: 100%;
  }

  .navbar-nav.ms-lg-auto .dropdown-menu {
    right: auto !important;
    left: 0 !important;
  }
}

/* Tablet Styles */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .navbar-nav .nav-link {
    padding: 0.5rem 0.5rem;
    font-size: 0.9rem;
  }
}

/* Ensure proper spacing for icons */
.navbar-nav .nav-link i {
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* Vertical Sidebar Styles */
.vertical-sidebar {
  position: fixed;
  left: -280px;
  top: 0;
  width: 280px;
  height: 100vh;
  background-color: #fff;
  border-right: 1px solid #dee2e6;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  z-index: 1030;
  transition: left 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
}

.vertical-sidebar.active {
  left: 0;
  display: block;
}

/* Ensure sidebar is below navbar */
@media (min-width: 992px) {
  .vertical-sidebar {
    top: 56px;
    height: calc(100vh - 56px);
  }
}

.sidebar-header {
  position: sticky;
  top: 0;
  background-color: #fff;
  z-index: 10;
  border-bottom: 1px solid #dee2e6;
  padding-top: 1rem;
}

.sidebar-header img {
  border: 2px solid #dee2e6;
  transition: border-color 0.2s ease;
}

.sidebar-header img:hover {
  border-color: #0d6efd;
}

.sidebar-nav {
  padding: 1rem 0;
}

.sidebar-nav .nav {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 140px);
  padding-bottom: 1rem;
}

.sidebar-nav .nav-item {
  width: 100%;
}

.sidebar-nav .nav-link {
  color: #212529 !important;
  width: 100%;
}

.sidebar-link {
  padding: 0.75rem 1.5rem !important;
  color: #212529 !important;
  text-decoration: none !important;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  display: flex !important;
  align-items: center;
  width: 100%;
  font-size: 0.95rem;
}

.sidebar-link,
.sidebar-link * {
  color: #212529 !important;
}

.sidebar-link:hover {
  background-color: rgba(13, 110, 253, 0.1);
  color: #0d6efd !important;
  border-left-color: #0d6efd;
}

.sidebar-link.active {
  background-color: rgba(13, 110, 253, 0.15);
  color: #0d6efd !important;
  border-left-color: #0d6efd;
  font-weight: 600;
}

.sidebar-dropdown {
  padding-left: 1.5rem;
  margin-top: 0;
}

.sidebar-dropdown .dropdown-item {
  padding: 0.5rem 1.5rem;
  padding-left: 2.5rem;
}

.sidebar-dropdown .dropdown-item:hover {
  background-color: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
}

/* Main content adjustment for sidebar */
#mainContent {
  transition: margin-left 0.3s ease, padding-left 0.3s ease;
}

#mainContent.with-sidebar {
  margin-left: 280px;
  padding-left: 1.5rem;
}

@media (max-width: 991.98px) {
  #mainContent.with-sidebar {
    margin-left: 0;
    padding-left: 0;
  }
}

/* Menu layout toggle button */
#menuLayoutToggle {
  border: 1px solid #dee2e6;
  padding: 0.375rem 0.75rem;
}

#menuLayoutToggle:hover {
  background-color: #f8f9fa;
  border-color: #adb5bd;
}

/* Small screens (576px - 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
  .navbar-nav.me-auto {
    max-width: calc(100vw - 200px);
  }
  
  .navbar-nav .nav-link {
    padding: 0.5rem 0.3rem;
    font-size: 0.8rem;
  }
  
  .navbar-nav .nav-item {
    margin: 0;
  }
}

/* Medium screens (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  .navbar-nav.me-auto {
    max-width: calc(100vw - 250px);
  }
  
  .navbar-nav .nav-link {
    padding: 0.5rem 0.3rem;
    font-size: 0.75rem;
  }
  
  .navbar-nav .nav-item {
    margin: 0;
  }
  
  /* Hide less critical items */
  .navbar-nav .nav-item.d-none.d-md-inline {
    display: none !important;
  }
}

/* Large screens (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .navbar-nav.me-auto {
    max-width: calc(100vw - 280px);
  }
  
  .navbar-nav .nav-link {
    padding: 0.5rem 0.35rem;
    font-size: 0.8rem;
  }
  
  .navbar-nav .nav-item {
    margin: 0;
  }
  
  /* Hide less critical items on medium-large screens */
  .navbar-nav .nav-item.d-none.d-md-inline {
    display: none !important;
  }
}

/* Extra large screens (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .navbar-nav.me-auto {
    max-width: calc(100vw - 300px);
  }
  
  .navbar-nav .nav-link {
    padding: 0.5rem 0.4rem;
    font-size: 0.85rem;
  }
  
  .navbar-nav .nav-item {
    margin: 0;
  }
}

/* XXL screens (1400px+) */
@media (min-width: 1400px) {
  .navbar-nav.me-auto {
    max-width: calc(100vw - 320px);
  }
  
  .navbar-nav .nav-link {
    padding: 0.5rem 0.5rem;
    font-size: 0.9rem;
  }
  
  .navbar-nav .nav-item {
    margin: 0;
  }
}

@media (max-width: 991.98px) {
  .vertical-sidebar {
    display: none !important;
  }
  
  .vertical-sidebar.active {
    display: none !important;
  }
  
  #mainContent.with-sidebar {
    margin-left: 0;
    padding-left: 0;
  }
  
  #menuLayoutToggle {
    display: none !important;
  }
  
  /* Ensure horizontal menu is always visible on mobile */
  .navbar-nav.me-auto {
    display: flex !important;
  }
}