.sidebar {
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 .5em 1.5em rgba(0,0,0,0.1), 0 .125em .5em rgba(0,0,0,0.06);
  width: 220px !important;
  height: 100vh;
  position: sticky;
  top: 0;
  background: #fbf9f9;
  border-right: 1px solid #e2e8f0;
}

.container-grid {
  display: grid;
  grid-template-columns: 220px 1fr !important;
  min-height: 100vh;
  grid-template-rows: 1fr;
}

.touchterminal-container {
  max-width: 30vw;
}

@media (max-width: 768px) {
  .container-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
  }

  .touchterminal-container {
    max-width: 90vw;
    margin-left: 5vw !important;
  }
}

.nav-divider {
  height: 1px;
  background-color: #e2e8f0;
  margin: 0.75rem 0;
  opacity: 1;
}

/* Search form styling */
.search-section {
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.search-form .form-control {
  font-size: 13px;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid #e2e8f0;
  background: white;
  transition: all 0.2s ease;
}

.search-form .form-control:focus {
  border-color: #1e40af;
  box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.1);
  outline: none;
}

.search-form .btn {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 13px;
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
  transition: all 0.2s ease;
}

.search-form .btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

/* Basic nav link styling */
.sidebar .nav-link {
  --bs-nav-link-color: #5e5e74 !important;
  font-size: 13px !important;
  line-height: 1.5;
  display: flex;
  align-items: center;
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem;
  margin: 0.125rem 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 40px;
  font-weight: 500;
}

.sidebar .nav-link:hover {
  background-color: #f1f5f9;
  color: #334155 !important;
  transform: translateX(2px);
}

.sidebar .nav-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  color: #5e5e74;
  margin-right: 0.5rem;
}

.sidebar .nav-link span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

/* Active state - most important */
.sidebar .nav-link.active {
  background-color: #dbeafe !important;
  color: #1e40af !important;
  font-weight: 600 !important;
  border-left: 4px solid #1e40af;
  padding-left: 0.625rem;
  margin-left: 0.75rem;
  border-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(30, 64, 175, 0.1);
}

.sidebar .nav-link.active i {
  color: #1e40af !important;
}

.sidebar .nav-link.active:hover {
  background-color: #dbeafe !important;
  color: #1e40af !important;
  transform: translateX(0);
}

/* Bootstrap Accordion Styling for Sidebar */
.sidebar .accordion {
  --bs-accordion-bg: transparent;
  --bs-accordion-border-width: 0;
  --bs-accordion-border-color: transparent;
  margin-bottom: 0.5rem !important;
}

.sidebar .accordion-button {
  background-color: #f8fafc !important;
  color: #5e5e74 !important;
  font-weight: 600;
  font-size: 13px;
  padding: 0.625rem 0.75rem;
  border-radius: 0.375rem !important;
  border: none !important;
  box-shadow: none !important;
  transition: all 0.2s ease;
  min-height: 40px;
  letter-spacing: 0.025em;
}

.sidebar .accordion-button::after {
  display: none !important;
}

.sidebar .accordion-button:hover {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
  transform: translateX(2px);
}

.sidebar .accordion-button:not(.collapsed) {
  background-color: #f8fafc !important;
  color: #334155 !important;
  box-shadow: none !important;
}

.sidebar .accordion-button:focus {
  box-shadow: none !important;
  border-color: transparent !important;
}

.sidebar .accordion-button.active {
  background-color: #e0f2fe !important;
  color: #0c4a6e !important;
  border-left: 3px solid #0284c7;
  padding-left: 0.625rem;
}

.sidebar .accordion-button.active i {
  color: #0284c7 !important;
}

.sidebar .accordion-button i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  color: #64748b;
  margin-right: 0.5rem;
}

.sidebar .accordion-button .accordion-chevron {
  font-size: 13px !important;
  width: 12px !important;
  color: #94a3b8 !important;
  margin-right: 0 !important;
  transition: transform 0.2s ease;
}

.sidebar .accordion-button:not(.collapsed) .accordion-chevron {
  transform: rotate(180deg);
}

.sidebar .accordion-button.active .accordion-chevron {
  color: #0284c7 !important;
}

.sidebar .accordion-body {
  padding: 0.25rem 0;
}

.nav-submenu .nav-link {
  font-size: 13px !important;
  padding: 0.5rem 0.75rem 0.5rem 1.5rem;
  margin: 0.0625rem 0.5rem;
  min-height: 36px;
  font-weight: 600;
  color: #64748b !important;
}

.nav-submenu .nav-link:hover {
  background-color: #f8fafc;
  color: #334155 !important;
  transform: translateX(2px);
}

.nav-submenu .nav-link.active {
  background-color: #eff6ff !important;
  color: #1e40af !important;
  border-left: 3px solid #3b82f6;
  padding-left: 1.375rem;
}

.nav-submenu .nav-link i {
  font-size: 14px !important;
  width: 16px !important;
  color: #64748b !important;
}

.nav-submenu .nav-link.active i {
  color: #1e40af !important;
}

/* Dropdown styling */
.sidebar .dropdown-toggle::after {
  margin-left: auto;
  margin-right: 0;
}

.sidebar .dropdown-menu {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  margin-left: 0.5rem;
  margin-right: 0.5rem;
}

.sidebar .dropdown-item {
  font-size: 13px;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  color: #2E3440;
  min-height: 40px;
}

.sidebar .dropdown-item:hover {
  background-color: #f1f5f9;
  color: #1e40af;
}

.sidebar .dropdown-item i {
  font-size: 14px;
  width: 18px;
  text-align: center;
  margin-right: 0.5rem;
}

.sidebar .mt-auto {
  margin-top: auto !important;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.75rem;
}

/* ===================== Dark Mode ===================== */

[data-bs-theme="dark"] .sidebar {
  background: #0f172a !important;
  border-right-color: #1e293b;
}

[data-bs-theme="dark"] .nav-divider {
  background-color: #1e293b;
}

[data-bs-theme="dark"] .search-form .form-control {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .search-form .form-control::placeholder {
  color: #64748b;
}

[data-bs-theme="dark"] .search-form .btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

[data-bs-theme="dark"] .search-form .btn:hover {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .sidebar .nav-link {
  --bs-nav-link-color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
  background-color: #1e293b;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .sidebar .nav-link i {
  color: #94a3b8;
}

[data-bs-theme="dark"] .sidebar .nav-link.active {
  background-color: #1d3a63 !important;
  color: #93c5fd !important;
  border-left-color: #3b82f6;
  box-shadow: none;
}

[data-bs-theme="dark"] .sidebar .nav-link.active i {
  color: #93c5fd !important;
}

[data-bs-theme="dark"] .sidebar .nav-link.active:hover {
  background-color: #1d3a63 !important;
  color: #93c5fd !important;
}

[data-bs-theme="dark"] .sidebar .accordion-button {
  background-color: #1e293b !important;
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .sidebar .accordion-button:hover {
  background-color: #334155 !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .sidebar .accordion-button:not(.collapsed) {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .sidebar .accordion-button i {
  color: #94a3b8;
}

[data-bs-theme="dark"] .sidebar .accordion-button .accordion-chevron {
  color: #64748b !important;
}

[data-bs-theme="dark"] .sidebar .accordion-button.active {
  background-color: #1d3a63 !important;
  color: #93c5fd !important;
  border-left-color: #3b82f6;
}

[data-bs-theme="dark"] .sidebar .accordion-button.active i,
[data-bs-theme="dark"] .sidebar .accordion-button.active .accordion-chevron {
  color: #93c5fd !important;
}

[data-bs-theme="dark"] .nav-submenu .nav-link {
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .nav-submenu .nav-link:hover {
  background-color: #1e293b;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .nav-submenu .nav-link i {
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .nav-submenu .nav-link.active {
  background-color: #1d3a63 !important;
  color: #93c5fd !important;
  border-left-color: #3b82f6;
}

[data-bs-theme="dark"] .nav-submenu .nav-link.active i {
  color: #93c5fd !important;
}

[data-bs-theme="dark"] .sidebar .dropdown-menu {
  background: #1e293b;
  border-color: #334155;
}

[data-bs-theme="dark"] .sidebar .dropdown-item {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .sidebar .dropdown-item:hover {
  background-color: #334155;
  color: #f1f5f9;
}

[data-bs-theme="dark"] .sidebar .mt-auto {
  border-top-color: #1e293b;
}

[data-bs-theme="dark"] .navbar.navbar-light {
  background-color: #0f172a !important;
}

[data-bs-theme="dark"] .offcanvas {
  background-color: #0f172a;
  color: #e2e8f0;
}

/* Responsive design
@media (max-width: 768px) {
  .container-grid {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    width: 100% !important;
    height: auto;
    position: relative;
  }

  .sidebar .nav-link span {
    display: inline;
  }
}
*/