/* ========================================================
   UNI STUDENT - Modern Select2 Custom Styling for All Forms
   ======================================================== */

/* Prevent original select from ever showing when Select2 is active */
select.select2-hidden-accessible,
.select2-hidden-accessible {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
  pointer-events: none !important;
}

/* Prevent duplicate Select2 containers */
.select2-container + .select2-container,
.select2-container ~ .select2-container {
  display: none !important;
}

.select2-container {
  width: 100% !important;
  display: block;
}

.select2-container .select2-selection--single {
  height: 44px !important;
  background-color: #ffffff;
  border: 1px solid #ced4da;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #1e293b;
  font-size: 14px;
  line-height: 42px;
  padding-left: 14px;
  padding-right: 36px;
  width: 100%;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #94a3b8;
  font-size: 14px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px;
  right: 12px;
  top: 0;
  width: 20px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: #64748b transparent transparent transparent;
  border-width: 5px 4px 0 4px;
  margin-top: -2px;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent #0056cc transparent;
  border-width: 0 4px 5px 4px;
}

/* Focus and Open States */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: #0056cc;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 86, 204, 0.15);
}

/* Dropdown Container */
.select2-container--open {
  z-index: 9999999 !important;
}

.select2-dropdown {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
  background-color: #ffffff;
  z-index: 9999999 !important;
  overflow: hidden;
}

.select2-container--open .select2-dropdown--below {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  margin-top: 4px;
}

.select2-container--open .select2-dropdown--above {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  margin-bottom: 4px;
}

/* Search Box */
.select2-search--dropdown {
  padding: 8px 10px;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.select2-search--dropdown .select2-search__field {
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  outline: none;
  background-color: #ffffff;
  color: #1e293b;
  width: 100% !important;
  box-sizing: border-box;
}

.select2-search--dropdown .select2-search__field:focus {
  border-color: #0056cc;
  box-shadow: 0 0 0 2px rgba(0, 86, 204, 0.15);
}

/* Dropdown Results */
.select2-results__options {
  max-height: 240px;
  padding: 4px;
}

.select2-results__option {
  padding: 8px 12px;
  font-size: 13.5px;
  border-radius: 6px;
  color: #334155;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background-color: #edf5ff;
  color: #0056cc;
  font-weight: 500;
}

.select2-container--default .select2-results__option--selected {
  background-color: #e2e8f0;
  color: #0f172a;
  font-weight: 600;
}

/* ========================================================
   Form-Specific Overrides
   ======================================================== */

/* Hero Inquiry Card on Homepage */
.hero-inquiry-field .select2-container .select2-selection--single {
  height: 42px !important;
  background-color: #f8faff;
  border-color: #e1e8f2;
  border-radius: 9px;
}

.hero-inquiry-field .select2-container .select2-selection__rendered {
  padding-left: 38px;
  line-height: 40px;
}

.hero-inquiry-field:focus-within .hero-inquiry-icon {
  color: #0056cc;
}

/* RTL (Arabic Portal) */
[dir="rtl"] .select2-container .select2-selection--single .select2-selection__rendered {
  padding-right: 14px;
  padding-left: 36px;
  text-align: right;
}

[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__arrow {
  left: 12px;
  right: auto;
}

[dir="rtl"] .hero-inquiry-field .select2-container .select2-selection__rendered {
  padding-right: 38px;
  padding-left: 14px;
}

[dir="rtl"] .select2-results__option {
  text-align: right;
}

/* ========================================================
   Bootstrap 5 Validation Integration
   ======================================================== */
.was-validated select:invalid + .select2-container .select2-selection--single,
select.is-invalid + .select2-container .select2-selection--single {
  border-color: #dc3545 !important;
  background-color: #fff9f9 !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15) !important;
}

.was-validated select:valid + .select2-container .select2-selection--single,
select.is-valid + .select2-container .select2-selection--single {
  border-color: #198754;
}

/* Scholarship and Modal Inputs */
.sch-form-select + .select2-container .select2-selection--single,
.sch-field-input + .select2-container .select2-selection--single {
  min-height: 46px;
  border-radius: 8px;
}
