html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  padding: 0;
  background-color: #f3f4f6;
  overflow-x: hidden;
}

/* Sidebar Styles */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, transform 0.3s ease;
  z-index: 1000;
}

#mobile-sidebar-toggle {
  display: none;
}

/* Ensure modals are above sidebar */
.modal {
  z-index: 1055 !important;
}

.modal-backdrop {
  z-index: 1050 !important;
}

/* Fixed modal size with scroll */
.modal-dialog {
  max-width: 800px;
  margin: 1.75rem auto;
}

.modal-dialog.modal-lg {
  max-width: 900px;
}

.modal-content {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
  border-bottom: 1px solid #dee2e6;
}

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(90vh - 120px);
  padding: 1rem;
}

.modal-footer {
  flex-shrink: 0;
  border-top: 1px solid #dee2e6;
}

/* Custom scrollbar for modal body */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#sidebar.collapsed {
  width: 4rem !important;
}

#sidebar.collapsed .sidebar-title {
  display: none;
}

#sidebar.collapsed .sidebar-text {
  display: none;
}

#sidebar.collapsed .nav-item {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  display: flex !important;
}

#sidebar.collapsed .nav-item i {
  display: inline-block !important;
  margin: 0 !important;
  margin-right: 0 !important;
  width: auto !important;
  font-size: 1.25rem;
}

#sidebar.collapsed #sidebar-toggle-btn i {
  transform: rotate(180deg);
}

#sidebar.collapsed .menu-group-header {
  display: none;
}

/* Menu group styles */
.menu-group-header {
  margin-top: 0.75rem;
}

.menu-group-toggle {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.menu-group-toggle:hover {
  background-color: #374151 !important;
}

/* Light theme hover */
#sidebar.bg-light .menu-group-toggle:hover {
  background-color: #e5e7eb !important;
}

/* Green theme hover */
#sidebar.bg-success .menu-group-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Gray theme hover */
#sidebar.bg-secondary .menu-group-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Blue theme hover */
#sidebar.bg-primary .menu-group-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.menu-group-icon {
  transition: transform 0.3s ease;
  color: #9ca3af;
}

/* Green theme menu group icon */
#sidebar.bg-success .menu-group-icon {
  color: rgba(255, 255, 255, 0.7);
}

/* Gray theme menu group icon */
#sidebar.bg-secondary .menu-group-icon {
  color: rgba(255, 255, 255, 0.7);
}

/* Blue theme menu group icon */
#sidebar.bg-primary .menu-group-icon {
  color: rgba(255, 255, 255, 0.7);
}

.menu-group-toggle.active .menu-group-icon {
  transform: rotate(180deg);
}

/* Highlight menu group header when it contains active item */
.menu-group-toggle.has-active {
  background-color: rgba(59, 130, 246, 0.1) !important;
  border-left: 2px solid #3b82f6;
}

/* Green theme highlight */
#sidebar.bg-success .menu-group-toggle.has-active {
  background-color: rgba(255, 255, 255, 0.15) !important;
  border-left: 2px solid #ffffff;
}

/* Gray theme highlight */
#sidebar.bg-secondary .menu-group-toggle.has-active {
  background-color: rgba(255, 255, 255, 0.15) !important;
  border-left: 2px solid #ffffff;
}

/* Blue theme highlight */
#sidebar.bg-primary .menu-group-toggle.has-active {
  background-color: rgba(255, 255, 255, 0.15) !important;
  border-left: 2px solid #ffffff;
}

.menu-group-items {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.menu-group-items[style*="display: block"],
.menu-group-items.show {
  max-height: 1000px;
  opacity: 1;
}

.menu-group-items li {
  margin: 0;
}

/* When collapsed, show menu group items as icon-only */
#sidebar.collapsed .menu-group-items {
  display: block !important;
  max-height: none !important;
  opacity: 1 !important;
}

#sidebar.collapsed .menu-group-items li {
  display: block !important;
}

#sidebar.collapsed .menu-group-items .nav-item {
  display: flex !important;
  visibility: visible !important;
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

#sidebar.collapsed .menu-group-toggle {
  display: none !important;
}

#sidebar.collapsed .menu-group-icon {
  display: none;
}

/* Ensure standalone nav items (like Dashboard) are visible when collapsed */
#sidebar.collapsed > nav > ul > li:not(.menu-group-header) > .nav-item {
  display: flex !important;
  visibility: visible !important;
}

/* Ensure icons are visible when sidebar is collapsed */
#sidebar.collapsed .nav-item .fas,
#sidebar.collapsed .nav-item .fa,
#sidebar.collapsed .nav-item i {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Sidebar scrollbar */
#sidebar nav::-webkit-scrollbar {
  width: 6px;
}

#sidebar nav::-webkit-scrollbar-track {
  background: #1f2937;
}

#sidebar nav::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 3px;
}

#sidebar nav::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Light theme sidebar scrollbar */
#sidebar.bg-light nav::-webkit-scrollbar-track {
  background: #f3f4f6;
}

#sidebar.bg-light nav::-webkit-scrollbar-thumb {
  background: #d1d5db;
}

#sidebar.bg-light nav::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Green theme sidebar scrollbar */
#sidebar.bg-success nav::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

#sidebar.bg-success nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
}

#sidebar.bg-success nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Gray theme sidebar scrollbar */
#sidebar.bg-secondary nav::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

#sidebar.bg-secondary nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
}

#sidebar.bg-secondary nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Blue theme sidebar scrollbar */
#sidebar.bg-primary nav::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

#sidebar.bg-primary nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
}

#sidebar.bg-primary nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Nav item hover */
.nav-item.hover-bg-secondary:hover,
.nav-item.hover-bg-secondary:focus {
  background-color: #374151;
}

.nav-item.hover-bg-light:hover,
.nav-item.hover-bg-light:focus {
  background-color: #e5e7eb;
}

.nav-item.hover-bg-success-subtle:hover,
.nav-item.hover-bg-success-subtle:focus {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.hover-bg-secondary-subtle:hover,
.nav-item.hover-bg-secondary-subtle:focus {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.hover-bg-primary-subtle:hover,
.nav-item.hover-bg-primary-subtle:focus {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Active nav item */
.nav-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  border-left: 3px solid #ffffff;
}

.nav-item.active i {
  color: #ffffff;
}

/* Green theme active state */
#sidebar.bg-success .nav-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  border-left: 3px solid #ffffff;
}

#sidebar.bg-success .nav-item.active i {
  color: #ffffff;
}

/* Gray theme active state */
#sidebar.bg-secondary .nav-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  border-left: 3px solid #ffffff;
}

#sidebar.bg-secondary .nav-item.active i {
  color: #ffffff;
}

/* Blue theme active state */
#sidebar.bg-primary .nav-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  border-left: 3px solid #ffffff;
}

#sidebar.bg-primary .nav-item.active i {
  color: #ffffff;
}

/* Main content */
.main-content {
  transition: margin-left 0.3s ease;
  padding: 0;
  margin-top: 0;
}

#sidebar.collapsed ~ .main-content {
  margin-left: 4rem !important;
}

/* Table styles */
.data-table {
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  border-right: 1px solid #dee2e6;
  border-left: 1px solid #dee2e6;
  background-color: #f8f9fa;
}

.data-table tbody td {
  border-right: 1px solid #e9ecef;
  border-left: 1px solid #e9ecef;
}

.data-table tbody tr:hover td {
  background-color: #f8f9fa;
}

/* Status badges */
.status-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Statistics cards */
.stat-card {
  border-radius: 0.5rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.stat-card-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.stat-card-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.stat-card-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.stat-card-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.stat-card-secondary {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: white;
}

.stat-card-info {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: white;
}

.stat-card-icon {
  font-size: 2rem;
  opacity: 0.8;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: bold;
  margin: 0;
}

.stat-card-label {
  font-size: 0.875rem;
  opacity: 0.9;
  margin: 0;
}

/* Responsive */
@media (max-width: 767.98px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  #sidebar.mobile-open {
    transform: translateX(0);
    width: 16rem !important;
    z-index: 1050;
  }
  
  .main-content {
    margin-left: 0 !important;
    position: relative;
  }
  
  /* Overlay when sidebar is open on mobile */
  body.sidebar-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
  }
  
  #mobile-sidebar-toggle {
    display: block !important;
  }
}

/* Form styles */
.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Detail divider */
.detail-divider {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 1rem 0;
}

.section-divider {
  border: 0;
  border-top: 2px solid #d1d5db;
  margin: 2rem 0;
}

/* Improved badge contrast */
.badge.bg-info {
  background-color: #0dcaf0 !important;
  color: #fff !important;
  font-weight: 600;
}

.badge.bg-warning {
  background-color: #ffc107 !important;
  color: #000 !important;
  font-weight: 600;
}

.badge.bg-secondary {
  background-color: #6c757d !important;
  color: #fff !important;
  font-weight: 600;
}

.badge.bg-success {
  background-color: #198754 !important;
  color: #fff !important;
  font-weight: 600;
}

.badge.bg-danger {
  background-color: #dc3545 !important;
  color: #fff !important;
  font-weight: 600;
}

.badge.bg-primary {
  background-color: #0d6efd !important;
  color: #fff !important;
  font-weight: 600;
}

.badge.bg-dark {
  background-color: #212529 !important;
  color: #fff !important;
  font-weight: 600;
}

/* Enhanced badge styling for detail pages */
.detail-badge,
.card-body .badge,
dl .badge {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.375rem;
  letter-spacing: 0.025em;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* SPA Navigation Styles */
.spa-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(2px);
}

.spa-loading-content {
  text-align: center;
}

.spa-loading-content .spinner-border {
  width: 3rem;
  height: 3rem;
}

#sidebar .nav-item.active {
  background-color: rgba(13, 110, 253, 0.2) !important;
  border-left: 3px solid #0d6efd;
}

#sidebar .nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Custom button size - Medium */
.btn-mm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 0.25rem;
}