/* ==========================================================================
   SELECT2 CUSTOM STYLING - Tailored for Dino Logistics Design
   ========================================================================== */

/* Color Variables - Aligned with main design system */
:root {
  --select2-primary: #0554c6;
  --select2-primary-dark: #0442a0;
  --select2-border: #e5e7eb;
  --select2-bg: #ffffff;
  --select2-text: #1f2937;
  --select2-text-muted: #6b7280;
  --select2-hover: #f3f4f6;
  --select2-focus-border: #0554c6;
  --select2-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ========================================================================== */
/* 1. SELECT2 CONTAINER - Base styling                                      */
/* ========================================================================== */
.select2-container {
  width: 100% !important;
  font-family: "Poppins", sans-serif;
}

.select2-container--default .select2-selection--single {
  background: var(--select2-bg);
  border: 1px solid var(--select2-border);
  border-radius: 6px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  box-shadow: var(--select2-shadow);
  transition: 0.3s ease;
}

.select2-container--default .select2-selection--single:focus {
  border-color: var(--select2-focus-border);
  box-shadow: 0 0 0 3px rgba(5, 84, 198, 0.1);
  outline: none;
}

/* ========================================================================== */
/* 2. DROPDOWN ARROW (Caret)                                                */
/* ========================================================================== */
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--select2-text);
  line-height: 44px;
  padding: 0 12px 0 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  width: 20px;
  height: 44px;
  top: 0;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--select2-text-muted) transparent transparent transparent;
  border-width: 6px 4px 0 4px;
  width: 0;
  height: 0;
  margin: 0;
  top: -3px;
  position: relative;
}

/* ========================================================================== */
/* 3. PLACEHOLDER STYLING                                                   */
/* ========================================================================== */
.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: var(--select2-text-muted);
  font-weight: 400;
}

/* ========================================================================== */
/* 3.5 CLEAR BUTTON (X Icon) - Scoped to Select2                            */
/* ========================================================================== */
.select2-container--default .select2-selection--single .select2-selection__clear {
  width: 20px;
  height: 44px;
  top: 0;
  right: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
  cursor: pointer;
  color: var(--select2-text-muted);
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
  color: var(--clr-accent);
}

/* Remove default styling for clear button pseudo-element */
.select2-container--default .select2-selection--single .select2-selection__clear::after {
  content: "";
  display: none;
}

/* Custom X icon using Unicode character */
.select2-container--default .select2-selection--single .select2-selection__clear::before {
  content: "×";
  font-size: 18px;
  line-height: 1;
  position: absolute;
}

/* ========================================================================== */
/* 4. DROPDOWN MENU (Results)                                                */
/* ========================================================================== */
.select2-container--default .select2-results > .select2-results__options {
  max-height: 200px;
  font-size: 14px;
}

.select2-container--default .select2-results__option {
  padding: 10px 12px;
  color: var(--select2-text);
  transition: 0.2s ease;
  line-height: 1.5;
}

.select2-container--default .select2-results__option:hover,
.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: var(--select2-hover);
  color: var(--select2-text);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--select2-primary);
  color: white;
}

.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: rgba(5, 84, 198, 0.1);
  color: var(--select2-primary);
}

/* ========================================================================== */
/* 5. DROPDOWN CONTAINER (Wrapper)                                           */
/* ========================================================================== */
.select2-dropdown {
  background: var(--select2-bg);
  border: 1px solid var(--select2-border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1051;
}

.select2-dropdown--above {
  border-radius: 6px 6px 0 0;
  border-top: 1px solid var(--select2-border);
  border-bottom: none;
}

/* ========================================================================== */
/* 6. SEARCH INPUT (Filter in dropdown)                                      */
/* ========================================================================== */
.select2-search--dropdown {
  padding: 8px;
}

.select2-search--dropdown .select2-search__field {
  background: var(--select2-bg);
  border: 1px solid var(--select2-border);
  border-radius: 4px;
  color: var(--select2-text);
  padding: 8px 12px;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  height: 36px;
}

.select2-search--dropdown .select2-search__field:focus {
  border-color: var(--select2-focus-border);
  box-shadow: 0 0 0 2px rgba(5, 84, 198, 0.1);
  outline: none;
}

.select2-search--dropdown .select2-search__field::placeholder {
  color: var(--select2-text-muted);
}

/* ========================================================================== */
/* 7. DISABLED STATE                                                         */
/* ========================================================================== */
.select2-container--disabled .select2-selection {
  background-color: #f9fafb;
  cursor: not-allowed;
  opacity: 0.6;
}

.select2-container--disabled .select2-selection--single {
  border-color: #e5e7eb;
}

/* ========================================================================== */
/* 8. NO RESULTS MESSAGE                                                     */
/* ========================================================================== */
.select2-container--default .select2-results__option--no-matches {
  color: var(--select2-text-muted);
  padding: 12px;
  text-align: center;
  font-style: italic;
}

/* ========================================================================== */
/* 9. FOCUS / ACTIVE STATE (Select element is focused)                       */
/* ========================================================================== */
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--select2-focus-border);
  box-shadow: 0 0 0 3px rgba(5, 84, 198, 0.1);
}

/* ========================================================================== */
/* 10. MULTIPLE SELECT (if needed in future)                                 */
/* ========================================================================== */
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--select2-focus-border);
  border-radius: 6px 6px 0 0;
}

/* ========================================================================== */
/* 11. MOBILE RESPONSIVE                                                     */
/* ========================================================================== */
@media (max-width: 768px) {
  .select2-container--default .select2-selection--single {
    height: 48px;
    border-radius: 8px;
  }

  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 48px;
    font-size: 16px; /* Prevent iOS zoom on focus */
    padding: 0 12px;
  }

  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 48px;
    right: 12px;
  }

  /* Mobile Clear Button - Larger for touch */
  .select2-container--default .select2-selection--single .select2-selection__clear {
    width: 24px;
    height: 48px;
    right: 40px;
    font-size: 20px;
  }

  .select2-search--dropdown .select2-search__field {
    font-size: 16px;
    height: 40px;
  }

  .select2-results__options {
    max-height: 250px;
  }

  .select2-results__option {
    padding: 12px 12px;
  }
}

/* ========================================================================== */
/* 12. INTEGRATION WITH .select-light CLASS                                  */
/* ========================================================================== */
.select-light {
  /* Base styling already in style.css */
}

/* When Select2 is applied to .select-light or .js-select2 */
.js-select2.select2-container--default .select2-selection--single {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

/* ========================================================================== */
/* 13. ANIMATION & TRANSITION                                                */
/* ========================================================================== */
.select2-container .select2-selection--single {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.select2-results__option {
  transition: background-color 0.2s ease, color 0.2s ease;
}
