:root {
  --sidebar-width: 260px;
  --transition-speed: 0.3s;
}

/* Theme Variables */
[data-bs-theme="dark"] {
  --body-bg: #0b0e14;
  --card-bg: #161b22;
  --border-color: rgba(255, 255, 255, 0.08);
  --text-muted: #8b949e;
  --bs-body-color: #ffffff;
}

[data-bs-theme="light"] {
  --body-bg: #f4f7f9;
  --card-bg: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --text-muted: #6c757d;
  --bs-body-color: #0b0e14;
}

body {
  font-family: "Plus Jakarta Sans", sans-serif;
  background-color: var(--body-bg);
  transition: background var(--transition-speed);
}

/* Sidebar Styling */
#sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  border-right: 1px solid var(--border-color);
  transition: all var(--transition-speed);
  z-index: 1040;
}

.nav-link {
  color: var(--text-muted);
  padding: 0.8rem 1.5rem;
  margin: 0.2rem 1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  transition: 0.2s;
}

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

.nav-link i {
  font-size: 1.2rem;
  margin-right: 12px;
}

/* Top Bar glass effect */
.top-bar {
  background: rgba(var(--card-bg), 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.action-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-muted);
  transition: 0.2s;
}

.action-btn:hover {
  background: #0d6efd;
  color: white;
  border-color: #0d6efd;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  transition: transform 0.3s ease;
}

@media (max-width: 991px) {
  #sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
    position: fixed;
    height: 100vh;
  }

  #sidebar.show {
    margin-left: 0;
  }
}

/* Add this to your header or style section */
.form-control,
.form-select,
.input-group-text {
  background-color: var(--card-bg) !important;
  color: var(--bs-body-color) !important;
  border: 1px solid var(--border-color) !important;
  transition: all 0.2s ease;
}

.form-control:focus {
  background-color: var(--card-bg) !important;
  border-color: #0d6efd !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

/* Ensure placeholder text is visible but muted */
.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.custom-check:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.form-check-input {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.permission-table th {
  background: rgba(var(--accent-color-rgb), 0.03);
}

.icon-box-sm {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
}

.x-small {
  font-size: 0.75rem;
}

.table tbody tr:hover {
  background-color: rgba(var(--accent-color-rgb), 0.02) !important;
}

.btn-group .btn-light {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--bs-body-color);
}

.border-dashed {
  border-style: dashed !important;
}

.removeRow {
  transition: all 0.2s;
  opacity: 0.5;
}

.removeRow:hover {
  opacity: 1;
  transform: scale(1.2);
  color: #ff4b5c !important;
}

/* --- Select2 Universal Theme Fix --- */

/* 1. The Main Selection Box */
.select2-container--bootstrap-5 .select2-selection {
  background-color: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--bs-body-color) !important;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* 2. Text Inside the Box */
.select2-container--bootstrap-5
  .select2-selection--single
  .select2-selection__rendered {
  color: var(--bs-body-color) !important;
}

/* 3. The Dropdown Menu */
.select2-container--bootstrap-5 .select2-dropdown {
  background-color: var(--card-bg) !important;
  border-color: var(--border-color) !important;
  color: var(--bs-body-color) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* 4. Individual Options (Results) */
.select2-container--bootstrap-5 .select2-results__option {
  color: var(--bs-body-color) !important;
  background-color: transparent;
}

/* 5. Hover / Highlighted State */
/* We use your "Info" color for the hover state */
.select2-container--bootstrap-5 .select2-results__option--highlighted {
  background-color: var(--bs-info) !important;
  color: #000 !important; /* Keep text dark on bright info color */
}

/* 6. Selected State */
.select2-container--bootstrap-5 .select2-results__option--selected {
  background-color: rgba(var(--bs-info-rgb), 0.2) !important;
  color: var(--bs-info) !important;
}

/* 7. Search Input inside Dropdown */
.select2-container--bootstrap-5 .select2-search__field {
  background-color: rgba(var(--bs-body-color-rgb), 0.05) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--bs-body-color) !important;
}

/* 8. Clear Button & Arrows */
.select2-container--bootstrap-5 .select2-selection__clear,
.select2-container--bootstrap-5 .select2-selection__arrow b {
  filter: invert(0.5); /* Makes the arrow visible in both modes */
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: #0d6efd !important; /* Your custom color */
  box-shadow: 0 0 0 0.25rem rgba(40, 53, 167, 0.25) !important; /* Glow effect */
}

.select2-container--bootstrap-5
  .select2-results__option--highlighted[aria-selected] {
  background-color: #0d6efd !important;
  color: white !important;
}

.select2-container--bootstrap-5
  .select2-selection--multiple
  .select2-selection__choice {
  background-color: #0d6efd !important;
  color: white !important;
  border-color: #0d6efd !important;
}

/* Change the 'x' close button color */
.select2-container--bootstrap-5
  .select2-selection--multiple
  .select2-selection__choice__remove {
  color: white !important;
}

/* Allow the selected text to wrap in the table cell */
.select2-container--bootstrap-5 .select2-selection--single {
  height: auto !important;
  min-height: 38px !important;
  padding: 5px 5px;
}

.select2-container--bootstrap-5 .select2-selection__rendered {
  white-space: normal !important;
  word-wrap: break-word !important;
  line-height: 1.5 !important;
  display: block !important;
}

/* Vertical alignment for the table */
#itemsTable td {
  vertical-align: top !important;
}
