/* Hide original select elements */
select.custom-select-hidden {
  display: none !important;
}

/* Custom Select Container */
.custom-select-container {
  position: relative;
  display: block;
  width: 100%;
  box-sizing: border-box;
}

/* Standard Trigger style (looks like standard input field) */
.custom-select-trigger {
  width: 100%;
  padding: 10px 16px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.92rem;
  color: #0f172a;
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  transition: all 0.2s ease;
  user-select: none;
}

.custom-select-trigger:hover {
  border-color: #cbd5e1;
}

.custom-select-container.open .custom-select-trigger {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.custom-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Custom dropdown menu styling */
.custom-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  z-index: 1050; /* Higher than table controls and layout sidebar */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  box-sizing: border-box;
}

.custom-select-container.open .custom-select-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Custom Scrollbar */
.custom-select-menu::-webkit-scrollbar {
  width: 6px;
}
.custom-select-menu::-webkit-scrollbar-track {
  background: transparent;
}
.custom-select-menu::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}
.custom-select-menu::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Custom Options */
.custom-select-option {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}

.custom-select-option:hover {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary);
}

.custom-select-option.selected {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.custom-select-option.selected::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.75rem;
  margin-left: 8px;
}

/* Chevron arrow adjustments & animations */
.custom-select-arrow {
  transition: transform 0.25s ease, color 0.25s ease;
  color: #64748b;
  font-size: 0.75rem;
  margin-left: auto;
}

.custom-select-container.open .custom-select-arrow {
  transform: rotate(180deg);
  color: var(--primary) !important;
}

/* Override rules for special contexts */

/* 1. Quick Filter Buttons on Homepage */
.filter-dropdown-btn .custom-select-container {
  display: flex;
  align-items: center;
  width: 100%;
  position: static !important;
}
.filter-dropdown-btn .custom-select-trigger {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}
.filter-dropdown-btn .custom-select-arrow {
  margin-left: 10px;
}
.filter-dropdown-btn .select-arrow {
  display: none !important;
}
.filter-dropdown-btn .custom-select-label {
  font-weight: 600;
  color: #1e293b;
  margin-right: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
  display: inline-block;
  vertical-align: middle;
}
.filter-dropdown-btn .custom-select-menu {
  width: 220px;
  left: 0;
  transform: translateY(-8px);
}
.filter-dropdown-btn.open .custom-select-menu {
  transform: translateY(0);
}

/* 2. City Selector on Homepage */
.city-selector .custom-select-container {
  display: inline-block;
  width: auto;
}
.city-selector .custom-select-trigger {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 700;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
}
.city-selector .custom-select-arrow {
  font-size: 0.7rem;
  margin-left: 4px;
}
.city-selector .custom-select-menu {
  min-width: 140px;
  left: 0;
  right: auto;
}

/* 3. Popup modal select wrap */
.popup-select-wrap.custom-select-wrap-active::after {
  display: none !important;
}

/* Table z-index & Responsive overflow fixes */
.table-responsive:has(.custom-select-container.open) {
  overflow: visible !important;
}
.table-responsive-md:has(.custom-select-container.open) {
  overflow: visible !important;
}
.table-responsive-lg:has(.custom-select-container.open) {
  overflow: visible !important;
}
.card:has(.custom-select-container.open) {
  overflow: visible !important;
}
.card-body:has(.custom-select-container.open) {
  overflow: visible !important;
}
.modal-body:has(.custom-select-container.open) {
  overflow: visible !important;
}

