/**
 * FilterBar Styles
 *
 * CSS styles for the GitLab-style FilterBar component.
 * Creates an inline search bar with token pills inside.
 *
 * @module core/ui-components/filtering/filter-bar.css
 * @feature 011-unified-filtering
 */

/* Main filter bar wrapper */
.filter-bar {
  width: 100%;
}

/* Form layout - horizontal flex */
.filter-bar-form {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
}

/* The main search bar container - looks like a single input */
.filter-bar-search-container {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.5rem;
  background-color: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 4px;
  cursor: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-bar-search-container:focus-within {
  border-color: #485fc7;
  box-shadow: 0 0 0 0.125em rgba(72, 95, 199, 0.25);
}

/* Reset button inside bar */
.filter-bar-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.25rem;
  font-size: 0.875rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #b5b5b5;
  text-decoration: none;
  cursor: pointer;
}

.filter-bar-reset:hover {
  background-color: #f5f5f5;
  color: #363636;
}

/* Search icon */
.filter-bar-search-icon {
  color: #7a7a7a;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

/* Token pills - inline within the search bar */
.filter-bar-tokens {
  display: contents;
}

/* Individual token pill - compact, inline */
.filter-bar-token {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  padding-right: 0.25rem;
  background-color: #485fc7;
  color: #fff;
  border-radius: 4px;
  font-size: 0.8125rem;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 200px;
}

.filter-bar-token-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-bar-token .delete {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  max-width: 16px;
  max-height: 16px;
  margin-left: 0.25rem;
  background-color: rgba(255, 255, 255, 0.3);
}

.filter-bar-token .delete:hover {
  background-color: rgba(255, 255, 255, 0.5);
}

.filter-bar-token .delete::before,
.filter-bar-token .delete::after {
  background-color: #fff;
}

/* The inline text input - grows to fill space */
.filter-bar-input-wrapper {
  flex: 1;
  min-width: 120px;
  position: relative;
}

.filter-bar-add-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.875rem;
  padding: 0.15rem 0;
  color: inherit;
}

.filter-bar-add-input::placeholder {
  color: #7a7a7a;
}

/* Dropdown menu - positioned below the entire search bar */
.filter-bar-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: auto;
  min-width: 260px;
  max-width: 360px;
  margin-top: 0.25rem;
  background: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 4px;
  box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0px 0 1px rgba(10, 10, 10, 0.02);
  z-index: 20;
  display: none;
  max-height: 300px;
  overflow-y: auto;
}

.filter-bar-dropdown.is-active {
  display: block;
}

/* Dropdown items */
.filter-bar-dropdown-item {
  display: block;
  padding: 0.5rem 0.75rem;
  color: #363636;
  cursor: pointer;
  text-decoration: none;
}

.filter-bar-dropdown-item:hover {
  background-color: #f5f5f5;
  color: #485fc7;
}

.filter-bar-dropdown-item.is-selected {
  background-color: #485fc7;
  color: #fff;
}

/* Dropdown section headers */
.filter-bar-dropdown-header {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #7a7a7a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #ededed;
  background-color: #fafafa;
}

/* Value input inside dropdown */
.filter-bar-value-wrapper {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #ededed;
}

.filter-bar-value-input,
.filter-bar-value-select {
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 1px solid #dbdbdb;
  border-radius: 3px;
  font-size: 0.875rem;
}

.filter-bar-value-input:focus,
.filter-bar-value-select:focus {
  border-color: #485fc7;
  outline: none;
  box-shadow: 0 0 0 0.125em rgba(72, 95, 199, 0.25);
}

/* Action buttons - outside the search bar */
.filter-bar-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.filter-bar-actions .button {
  white-space: nowrap;
}

/* Clear link inside actions */
.filter-bar-clear {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem;
  color: #7a7a7a;
  text-decoration: none;
  font-size: 0.875rem;
}

.filter-bar-clear:hover {
  color: #485fc7;
}

/* Hidden inputs - visually hidden */
.filter-bar-hidden-inputs {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Search container needs relative for dropdown positioning */
.filter-bar-search-wrapper {
  flex: 1;
  position: relative;
  min-width: 0;
}

/* Integrated submit button inside bar */
.filter-bar-submit {
  border: none;
  background: transparent;
  color: #7a7a7a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 0.25rem;
  cursor: pointer;
}

.filter-bar-submit:hover {
  color: #363636;
}

/* No-JS fallback */
.filter-bar-noscript-fallback {
  margin-top: 1rem;
  padding: 1rem;
  background-color: #fafafa;
  border: 1px solid #ededed;
  border-radius: 4px;
}

.filter-bar-noscript-fallback summary {
  cursor: pointer;
  font-weight: 500;
  color: #485fc7;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  .filter-bar-form {
    flex-direction: column;
  }

  .filter-bar-search-container {
    flex-wrap: wrap;
  }

  .filter-bar-token {
    max-width: 150px;
  }

  .filter-bar-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .filter-bar-search-container {
    background-color: #2b2b2b;
    border-color: #4a4a4a;
    color: #f5f5f5;
  }

  .filter-bar-search-container:focus-within {
    border-color: #7289da;
    box-shadow: 0 0 0 0.125em rgba(114, 137, 218, 0.25);
  }

  .filter-bar-token {
    background-color: #7289da;
  }

  .filter-bar-search-icon {
    color: #aaa;
  }

  .filter-bar-add-input {
    color: #f5f5f5;
  }

  .filter-bar-add-input::placeholder {
    color: #888;
  }

  .filter-bar-dropdown {
    background-color: #363636;
    border-color: #4a4a4a;
  }

  .filter-bar-dropdown-item {
    color: #f5f5f5;
  }

  .filter-bar-dropdown-item:hover {
    background-color: #4a4a4a;
  }

  .filter-bar-dropdown-header {
    background-color: #2b2b2b;
    color: #aaa;
    border-color: #4a4a4a;
  }

  .filter-bar-value-wrapper {
    border-color: #4a4a4a;
  }

  .filter-bar-value-input,
  .filter-bar-value-select {
    background-color: #2b2b2b;
    border-color: #4a4a4a;
    color: #f5f5f5;
  }

  .filter-bar-noscript-fallback {
    background-color: #363636;
    border-color: #4a4a4a;
  }
}
