/**
 * SelectInput Component Styles
 * Optisch ähnlich wie Select-Komponente, aber mit direktem Input-Feld
 * Household Management App
 */

.custom-select-input {
  position: relative;
  width: 100%;
}

.custom-select-input__input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.custom-select-input__input {
  width: 100%;
  padding: var(--spacing-2) var(--spacing-4);
  padding-right: 2.5rem;
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  font-family: inherit;
  min-height: 40px;
  height: 40px;
  box-sizing: border-box;
  outline: none;
}

/* Match form-input styling exactly */
.custom-select-input__input:focus {
  border-color: var(--color-primary);
  background-color: var(--bg-primary);
}

.custom-select-input--has-value .custom-select-input__input,
.custom-select-input__input.has-value {
  color: var(--text-primary);
  font-weight: 500;
  background-color: var(--bg-primary);
}

/* Floating label support - match form-input padding */
.form-group--floating .custom-select-input__input {
  padding-top: var(--spacing-3);
  padding-bottom: var(--spacing-2);
  min-height: 40px;
  height: 40px;
}

.custom-select-input__icon {
  position: absolute;
  right: var(--spacing-3);
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

.custom-select-input__clear {
  position: absolute;
  right: var(--spacing-3);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  transition: color var(--transition-fast);
  z-index: 1;
}

.custom-select-input__clear:hover {
  color: var(--text-primary);
}

.custom-select-input__dropdown {
  position: fixed;
  background: var(--bg-primary);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  max-height: 200px;
  display: none;
  overflow: hidden;
  width: auto;
  min-width: 200px;
}

.custom-select-input__options {
  max-height: 200px;
  overflow-y: auto;
}

.custom-select-input__option {
  padding: var(--spacing-2) var(--spacing-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background-color var(--transition-fast);
}

.custom-select-input__option:hover,
.custom-select-input__option--highlighted {
  background-color: var(--bg-secondary);
}

.custom-select-input__option-label {
  flex: 1;
  text-align: left;
}

/* Floating label support */
.form-group--floating .custom-select-input__input {
  padding-top: var(--spacing-3);
  padding-bottom: var(--spacing-2);
  min-height: 40px;
}

/* Floating label states - support for custom-select-input wrapper */
.form-group--floating .custom-select-input:has(.custom-select-input__input:focus) ~ .form-label,
.form-group--floating .custom-select-input:has(.custom-select-input__input.has-value) ~ .form-label,
.form-group--floating .custom-select-input--has-value ~ .form-label,
.form-group--floating:has(.custom-select-input .custom-select-input__input:focus) .form-label,
.form-group--floating:has(.custom-select-input .custom-select-input__input.has-value) .form-label,
.form-group--floating:has(.custom-select-input--has-value) .form-label {
  top: 0;
  transform: translateY(-50%);
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  background-color: var(--bg-primary);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius-md);
}

.form-group--floating .custom-select-input__input:focus {
  border-color: var(--color-primary);
}

/* Ensure input is properly aligned */
.custom-select-input__input {
  text-align: left;
  vertical-align: middle;
  line-height: 1.5;
}

/* Clear button positioning - must be to the left of dropdown icon */
.form-group--floating .custom-select-input ~ .form-input__clear {
  right: 2.5rem; /* Position to the left of dropdown icon */
}

/* Adjust padding when clear button is present */
.form-group--floating .custom-select-input:has(~ .form-input__clear[style*="display: flex"]) .custom-select-input__input {
  padding-right: 4rem; /* Space for both clear button and dropdown icon */
}

