/* Hotwire Combobox Consolidated Styles */

/* =============================================================================
   1. Core Layout & Positioning
   ============================================================================= */

.hw-combobox {
  position: relative !important;
  flex: 1;
  min-width: 0;
}

/* Override default width when using flex-1 class */
.flex-1 .hw-combobox {
  --hw-combobox-width: 100% !important;
}

/* =============================================================================
   2. Main Wrapper - Remove all borders/outlines since parent card has border
   ============================================================================= */

.hw-combobox__main__wrapper {
  /* Remove all borders and outlines - the parent card provides the border */
  border: none !important;
  outline: none !important;
  box-shadow: none !important;

  /* Ensure wrapper displays as flex to allow input to expand */
  display: flex !important;
  align-items: center !important;

  /* Full width in flex containers */
  width: 100% !important;
  min-width: 0 !important;

  /* Transparent background - let parent card handle it */
  background-color: transparent !important;

  /* Minimal padding - the card provides the padding */
  padding: 0 2.25rem 0 0 !important; /* Right padding for the dropdown caret */
}

.hw-combobox__main__wrapper:focus-within {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Remove focus ring and all visual indicators when expanded or focused */
.hw-combobox__main__wrapper[aria-expanded="true"],
.hw-combobox__main__wrapper:focus,
.hw-combobox__main__wrapper:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background-color: transparent !important;
}

/* Additional specificity for flex-1 containers */
.flex-1 .hw-combobox__main__wrapper {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

/* Even more specific override targeting the exact width constraint */
.flex-1 > .hw-combobox > .hw-combobox__main__wrapper {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
}

/* Override any inline styles */
.flex-1 .hw-combobox__main__wrapper[style*="width"] {
  width: 100% !important;
}

/* =============================================================================
   3. Input - Remove all borders/outlines and ensure full width
   ============================================================================= */

.hw-combobox__input {
  /* Remove all borders and outlines */
  border: none !important;
  outline: none !important;
  box-shadow: none !important;

  /* Transparent background */
  background-color: transparent !important;

  /* Inherit color from parent */
  color: inherit !important;

  /* Full width expansion */
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  flex: 1 !important;

  /* Remove padding - parent wrapper handles it */
  padding: 0 !important;

  /* Override text truncation */
  text-overflow: clip !important;
  overflow: visible !important;
}

.hw-combobox__input:focus {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.hw-combobox__input::placeholder {
  color: rgb(156 163 175) !important;
}

/* Ensure proper input sizing when parent has flex-1 */
.flex-1 .hw-combobox__input {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  flex: 1 !important;
  text-overflow: clip !important;
  overflow: visible !important;
}

/* =============================================================================
   4. Dropdown Handle/Caret
   ============================================================================= */

.hw-combobox__handle {
  position: absolute !important;
  flex: none !important;
}

.flex-1 .hw-combobox__main__wrapper .hw-combobox__handle {
  position: absolute !important;
  flex: none !important;
}

/* =============================================================================
   5. Listbox/Dropdown - Light Mode
   ============================================================================= */

.hw-combobox__listbox {
  background: white !important;
  border: 1px solid rgb(209 213 219) !important;
  color: rgb(17 24 39) !important;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;

  /* Essential positioning */
  position: absolute !important;
  top: calc(100% + 0.2rem) !important;
  left: 0 !important;
  z-index: 10 !important;
  width: 100% !important;

  /* Flowbite-inspired styling */
  border-radius: 0.5rem !important;
  padding: 0.25rem !important;
}

.hw-combobox__option {
  color: rgb(17 24 39) !important;
  background-color: rgb(255 255 255) !important;

  /* Flowbite-inspired styling */
  border-radius: 0.375rem !important;
  padding: 0.5rem 1rem !important;
  margin: 0.125rem !important;
  transition: all 0.15s ease-in-out !important;
}

.hw-combobox__option:hover,
.hw-combobox__option--selected,
.hw-combobox__option--navigated {
  background-color: rgb(239 246 255) !important;
  color: rgb(17 24 39) !important;
}

/* =============================================================================
   6. Dark Mode - Manual .dark class
   ============================================================================= */

.dark .hw-combobox__input::placeholder {
  color: rgb(156 163 175) !important;
}

.dark .hw-combobox__listbox {
  background: rgb(55 65 81) !important;
  border-color: rgb(75 85 99) !important;
  color: rgb(249 250 251) !important;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.25), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;

  /* Ensure positioning is preserved in dark mode */
  position: absolute !important;
  top: calc(100% + 0.2rem) !important;
  left: 0 !important;
  z-index: 10 !important;
  width: 100% !important;
}

.dark .hw-combobox__option {
  color: rgb(249 250 251) !important;
  background-color: rgb(55 65 81) !important;
}

.dark .hw-combobox__option:hover,
.dark .hw-combobox__option--selected,
.dark .hw-combobox__option--navigated {
  background-color: rgb(99 102 241) !important;
  color: rgb(255 255 255) !important;
}

.dark .hw-combobox__handle::before {
  filter: brightness(0) saturate(100%) invert(62%) sepia(98%) saturate(12%) hue-rotate(317deg) brightness(98%) contrast(96%);
}

/* Dark mode dialog styles */
.dark .hw-combobox__dialog {
  background: rgb(55 65 81) !important;
  border-color: rgb(107 114 128) !important;
}

.dark .hw-combobox__dialog__input {
  background: rgb(75 85 99) !important;
  border-color: rgb(107 114 128) !important;
  color: rgb(249 250 251) !important;
}

.dark .hw-combobox__dialog__input::placeholder {
  color: rgb(156 163 175) !important;
}

/* =============================================================================
   7. Dark Mode - prefers-color-scheme fallback
   ============================================================================= */

@media (prefers-color-scheme: dark) {
  .hw-combobox__input::placeholder {
    color: rgb(156 163 175) !important;
  }

  .hw-combobox__listbox {
    background: rgb(55 65 81) !important;
    border-color: rgb(75 85 99) !important;
    color: rgb(249 250 251) !important;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.25), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;

    /* Ensure positioning is preserved */
    position: absolute !important;
    top: calc(100% + 0.2rem) !important;
    left: 0 !important;
    z-index: 10 !important;
    width: 100% !important;
  }

  /* Target the listbox more specifically */
  ul.hw-combobox__listbox {
    background: rgb(55 65 81) !important;
    border: 1px solid rgb(107 114 128) !important;

    /* Ensure positioning is preserved for specific selector */
    position: absolute !important;
    top: calc(100% + 0.2rem) !important;
    left: 0 !important;
    z-index: 10 !important;
    width: 100% !important;
  }

  .hw-combobox__option,
  li.hw-combobox__option {
    color: rgb(249 250 251) !important;
    background-color: rgb(55 65 81) !important;
  }

  .hw-combobox__option:hover,
  .hw-combobox__option--selected,
  .hw-combobox__option--navigated,
  li.hw-combobox__option:hover,
  li.hw-combobox__option--selected,
  li.hw-combobox__option--navigated {
    background-color: rgb(99 102 241) !important;
    color: rgb(255 255 255) !important;
  }

  .hw-combobox__dialog {
    background: rgb(55 65 81) !important;
    border-color: rgb(107 114 128) !important;
  }

  .hw-combobox__dialog__input {
    background: rgb(75 85 99) !important;
    border-color: rgb(107 114 128) !important;
    color: rgb(249 250 251) !important;
  }

  .hw-combobox__dialog__input::placeholder {
    color: rgb(156 163 175) !important;
  }
}

/* =============================================================================
   8. CSS Variables for dark mode
   ============================================================================= */

:root.dark,
.dark {
  --hw-component-bg-color: #374151 !important;
  --hw-option-bg-color: #374151 !important;
  --hw-active-bg-color: #6366f1 !important;
  --hw-border-color: #4b5563 !important;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hw-component-bg-color: #374151 !important;
    --hw-option-bg-color: #374151 !important;
    --hw-active-bg-color: #6366f1 !important;
    --hw-border-color: #4b5563 !important;
  }
}
