/* MAIN CONTAINER */
.advanced-search-container {
  display: flex;
  padding: 20px;
  box-sizing: border-box;
  width: calc(100% - 4.4em);
  margin-left: 4.4em;
  margin-top: 4.4em;
  transition: all 0.3s ease;
}

/* ADVANCED SEARCH OPTIONS PANEL */
.advanced-search-options {
  flex: 0 0 300px;
  background-color: var(--search-panel-bg-color);
  padding: 20px;
  border-radius: 15px;
  margin-right: 20px;
  box-shadow: var(--search-panel-shadow);
  transition: all 0.3s ease;
}

.advanced-search-options:hover {
  box-shadow: var(--search-panel-hover-shadow);
}

.advanced-search-options.folded {
  flex: 0 0 auto;
  width: auto;
  padding: 10px;
}

.advanced-search-options.folded .options-header {
  margin-bottom: 0;
}

.advanced-search-options.folded > *:not(.options-header) {
  display: none;
}

/* OPTIONS HEADER */
.options-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.advanced-search-options h2 {
  color: var(--text-color);
  font-size: 1.3rem;
  margin-bottom: 0;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
}

.toggle-button {
  display: none;
  background-color: var(--primary-color);
  color: var(--text-dark-light-color);
  border: none;
  align-items: baseline;
  border-radius: 5px;
  padding: 0.5em 1em;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.3s ease;
}

.toggle-button:hover {
  background-color: var(--primary-hover-color);
}

/* CURRENT FILTERS SUMMARY */
.current-filters-summary {
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem 1rem;
  background-color: var(--search-panel-bg-color);
  border: 1px solid var(--input-border-color);
  border-radius: 8px;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--input-border-color);
  padding-bottom: 0.6rem;
}

.clear-all-btn {
  font-weight: 500;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  background: #333;
  border: 1px solid #555;
  border-radius: 25px;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-all-btn:hover {
  background: #444;
  border-color: #666;
  color: #fff;
}

.clear-all-btn i {
  font-size: 12px;
}

.filters-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-tag {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.2;
}

.filter-tag.exclude {
  background-color: #dc3545;
}

.no-filters {
  color: var(--text-muted-color);
  font-style: italic;
  font-size: 0.9rem;
}

/* MAIN SEARCH QUERY FIELD */
.search-field label {
  display: block;
  color: var(--text-color);
  margin-bottom: 0.5em;
}

.search-field input[type="text"] {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--input-border-color);
  background-color: var(--input-bg-color);
  color: var(--text-secondary-color);
  border-radius: 5px;
  transition: all 0.3s ease;
}

.search-field input[type="text"]:focus {
  outline: none;
  opacity: 0.9;
}

/* TRANSLATED SERIES FILTER */
.translated-filter-section {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.translated-filter-section h3 {
  display: block;
  color: var(--text-color);
}

.translated-logic-selector {
  position: relative;
  background-color: var(--checkbox-bg-color);
  border: 2px solid var(--input-border-color);
  border-radius: 25px;
  padding: 4px;
  width: 120px;
  height: 32px;
  transition: all 0.3s ease;
}

.translated-logic-selector:hover {
  border-color: var(--checkbox-hover-border);
}

.translated-logic-selector label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 2;
  pointer-events: auto;
  transition: color 0.3s ease;
  cursor: pointer;
  user-select: none;
}

.translated-logic-selector label:first-child {
  left: 14px;
}

.translated-logic-selector label:last-child {
  right: 16px;
}

.translated-logic-selector input[type="radio"] {
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.translated-logic-selector::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 46px;
  height: 22px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover-color) 100%);
  border-radius: 20px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.translated-logic-selector:has(input[value="no"]:checked)::before {
  transform: translateX(58px);
}

.translated-logic-selector:has(input[value="yes"]:checked) label:first-child,
.translated-logic-selector:has(input[value="no"]:checked) label:last-child {
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.translated-logic-selector:has(input[value="yes"]:checked) label:last-child,
.translated-logic-selector:has(input[value="no"]:checked) label:first-child {
  color: var(--text-muted-color);
}

/* FILTER WINDOWS CONTAINER */
.filter-windows-container {
  border: 1px solid var(--input-border-color);
  border-radius: 8px;
  margin: 1rem 0;
  overflow: hidden;
  background-color: var(--search-panel-bg-color);
}

/* FILTER TABS */
.filter-tabs {
  display: flex;
  border-bottom: 1px solid var(--input-border-color);
  background: var(--filter-tab-bg);
}

.filter-tab {
  padding: 12px 24px;
  border: none;
  background: none;
  text-wrap: nowrap;
  font-size: 1rem;
  cursor: pointer;
  flex: 1;
  font-weight: 500;
  color: var(--text-muted-color);
  transition: all 0.3s ease;
}

.filter-tab:hover {
  background: var(--filter-tab-hover-bg);
}

.filter-tab.active {
  background: var(--filter-tab-hover-bg);
  color: var(--primary-color);
  border-bottom: 1px solid var(--primary-color);
}

/* FILTER WINDOWS */
.filter-window {
  display: none;
  padding: 1rem;
  background: var(--search-panel-bg-color);
}

.filter-window.active {
  display: block;
}

/* FILTER SECTIONS */
.filter-section {
  margin-bottom: 1rem;
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-section h3,
.range-filter-item h3 {
  color: var(--text-color);
  font-size: 1rem;
}

.filter-section label[for="sort_by"],
.filter-section label[for="sort_order"], 
.filter-section label[for="status_filter"],
.filter-section label[for="fandom_category"], 
.filter-section label[for="story_origin"] {
  display: block;
  color: var(--text-color);
  font-size: 1em;
  margin-bottom: 0.5em;
}

/* LABEL HOLDER */
.label-holder {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 12px;
  border-bottom: 1px solid #ff8c00;
}

.label-holder h3 {
  background: linear-gradient(135deg, #ff8c00 0%, #ff7300 100%);
  border-radius: 6px 6px 0 0;
  padding: 6px 12px;
  box-shadow: 0 2px 4px rgba(255, 140, 0, 0.15);
  border-left: 3px solid #ff6600;
  flex-shrink: 0;
  color: #ffffff;
  font-size: 0.9rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* LOGIC SELECTOR */
.logic-selector {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.5rem;
}

.logic-selector label {
  display: flex;
  align-items: center;
  color: var(--text-muted-color);
  cursor: pointer;
}

.logic-selector input[type="radio"] {
  margin-right: 5px;
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  outline: none;
  transition: border-color 0.3s ease;
}

.logic-selector input[type="radio"]:checked {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  box-shadow: inset 0 0 0 3px var(--search-panel-bg-color);
}

.logic-selector input[type="radio"]:hover {
  border-color: var(--radio-hover-color);
}

/* ADVANCED SEARCH BAR CONTAINER */
.advanced-search-bar-container {
  margin-bottom: 12px;
}

.advanced-filter-search-bar {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--input-border-color);
  background-color: var(--input-bg-color);
  color: var(--text-secondary-color);
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.advanced-filter-search-bar:focus {
  outline: none;
  opacity: 0.9;
}

.advanced-filter-search-bar::placeholder {
  color: var(--text-muted-color);
  opacity: 0.7;
}

/* CHECKBOX GROUPS */
.filter-section .checkbox-group {
  height: 250px;
  overflow-y: auto;
  border-bottom: 2px solid var(--input-border-color);
  border-radius: 5px;
}

.filter-section .checkbox-group::-webkit-scrollbar {
  width: 8px;
}

.filter-section .checkbox-group::-webkit-scrollbar-track {
  background: var(--scrollbar-track-bg);
  border-radius: 10px;
}

.filter-section .checkbox-group::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb-bg);
  border-radius: 10px;
  border: 2px solid var(--scrollbar-track-bg);
}

.filter-section .checkbox-group::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover-bg);
}

/* CUSTOM CHECKBOXES */
.custom-checkbox {
  display: flex;
  align-items: center;
  border: 1px solid var(--checkbox-border-color);
  border-radius: 5px;
  margin-bottom: 0.5em;
  background-color: var(--checkbox-bg-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  cursor: pointer;
  padding: 0.5em;
}

.custom-checkbox:hover {
  background-color: rgba(128, 128, 128, 0.1);
  border-color: rgba(128, 128, 128, 0.3);
}

.custom-checkbox input[type="checkbox"] {
  display: none;
}

.custom-checkbox .checkbox-label {
  color: var(--text-secondary-color);
  margin-left: 0.5em;
  flex-grow: 1;
}

.custom-checkbox .checkbox-custom {
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-color);
  border-radius: 3px;
  flex-shrink: 0;
  background-color: var(--checkbox-bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.custom-checkbox input[type="checkbox"]:checked + .checkbox-label + .checkbox-custom {
  background-color: var(--primary-color);
}

.custom-checkbox input[type="checkbox"]:checked + .checkbox-label + .checkbox-custom::after {
  content: "✔";
  color: var(--checkbox-checkmark-color);
  font-size: 14px;
  line-height: 1;
}

.custom-checkbox.hidden {
  display: none;
}

/* NO RESULTS MESSAGE */
.no-results-message {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted-color);
  font-style: italic;
  font-size: 0.9rem;
  gap: 8px;
}

.no-results-message i {
  opacity: 0.6;
  font-size: 1rem;
}

/* STORY TYPES GRID */
.story-types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

/* STORY TYPE BUTTONS */
.story-type-button {
  display: flex;
  align-items: baseline;
  padding: 12px 16px;
  border: 2px solid var(--input-border-color);
  border-radius: 8px;
  background-color: var(--checkbox-bg-color);
  color: var(--text-secondary-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.95rem;
  font-weight: 500;
  user-select: none;
}

.story-type-button:hover {
  border-color: rgba(128, 128, 128, 0.3);
  background-color: rgba(128, 128, 128, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.story-type-icon {
  margin-right: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.story-type-button.include-type[data-selected="true"] {
  background-color: #ff8c00;
  border-color: #ff8c00;
  color: white;
  box-shadow: 0 2px 8px rgba(255, 140, 0, 0.3);
}

.story-type-button.include-type[data-selected="true"] .story-type-icon {
  opacity: 1;
  color: white;
}

.story-type-button.include-type[data-selected="true"]:hover {
  background-color: #e67e00;
  border-color: #e67e00;
}

.story-type-button.exclude-type[data-selected="true"] {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.story-type-button.exclude-type[data-selected="true"] .story-type-icon {
  opacity: 1;
  color: white;
}

.story-type-button.exclude-type[data-selected="true"]:hover {
  background-color: #c82333;
  border-color: #c82333;
}

/* RANGE FILTERS */
.advanced-search-range-filters {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #333;
  padding: 1rem 0;
  border-top: 2px solid #333;
}

.advanced-label-clear-holder {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.chapter-count-filter,
.word-count-filter,
.views-filter,
.rating-filter {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.chapter-count-input-group,
.word-count-input-group,
.views-input-group,
.rating-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chapter-count-input-group label,
.word-count-input-group label,
.views-input-group label,
.rating-input-group label {
  font-size: 12px;
  color: #ccc;
  font-weight: 500;
}

.chapter-count-input-group input,
.word-count-input-group input,
.views-input-group input,
.rating-input-group input {
  width: 100px;
  padding: 8px 12px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2a2a2a;
  color: #fff;
  font-size: 14px;
  transition: opacity 0.3s ease;
}

.chapter-count-input-group input[type="number"]::-webkit-outer-spin-button,
.chapter-count-input-group input[type="number"]::-webkit-inner-spin-button,
.word-count-input-group input[type="number"]::-webkit-outer-spin-button,
.word-count-input-group input[type="number"]::-webkit-inner-spin-button,
.views-input-group input[type="number"]::-webkit-outer-spin-button,
.views-input-group input[type="number"]::-webkit-inner-spin-button,
.rating-input-group input[type="number"]::-webkit-outer-spin-button,
.rating-input-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.chapter-count-input-group input[type="number"],
.word-count-input-group input[type="number"],
.views-input-group input[type="number"],
.rating-input-group input[type="number"] {
  -moz-appearance: textfield;
}

.chapter-count-input-group input:focus,
.word-count-input-group input:focus,
.views-input-group input:focus,
.rating-input-group input:focus {
  outline: none;
  opacity: 0.9;
}

.chapter-count-separator,
.word-count-separator,
.views-separator,
.rating-separator {
  font-size: 18px;
  align-self: center;
  color: #ccc;
  font-weight: bold;
}

/* PRESET BUTTON */
.preset-btn {
  padding: 6px 12px;
  background: #333;
  border: 1px solid #555;
  border-radius: 25px;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.preset-btn:hover {
  background: #444;
  border-color: #666;
  color: #fff;
}

.preset-btn.active {
  background: #ff6b35;
  border-color: #ff6b35;
  color: #fff;
}

/* SELECT DROPDOWNS */
select {
  width: 100%;
  padding: 0.5em;
  border: 1px solid var(--input-border-color);
  background-color: var(--input-bg-color);
  color: var(--text-secondary-color);
  border-radius: 5px;
  background-image: var(--select-gradient);
  transition: background-image 0.3s ease;
}

select:hover {
  background-image: var(--select-hover-gradient);
}

/* SEARCH BUTTON */
.search-button {
  width: 100%;
  padding: 0.7em;
  background-color: var(--primary-color);
  color: var(--text-color);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s ease-in-out;
}

.search-button:hover {
  background-color: var(--primary-hover-color);
}

/* RESPONSIVE STYLES */
@media (max-width: 1500px) {
  .advanced-search-container {
    flex-direction: column;
    margin-top: 4em;
    width: calc(100% - 4.4em);
  }

  .advanced-search-options {
    flex: none;
    width: 100%;
    margin-right: 0;
    margin-bottom: 20px;
    padding: 10px;
  }

  .translated-logic-selector:has(input[value="no"]:checked)::before {
    transform: translateX(62px);
  }

  .options-header {
    padding: 0.5rem 0.5rem 0;
  }
  
  .toggle-button {
    display: inherit;
  }
}

@media (max-width: 1024px) {
  .advanced-search-container {
    flex-direction: column;
    padding: 0;
    width: 100%;
    margin-left: 0;
    margin-top: 4em;
  }
}

@media (max-width: 769px) {
  .options-header {
    padding: 0.5em 0 0;
  }

  .advanced-search-options h2 {
    font-size: 1.250rem;
  }

  .story-types-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filter-section .checkbox-group {
    height: 270px;
  }
  
  .story-type-button {
    font-size: 0.9rem;
  }
  
  .story-type-icon {
    margin-right: 6px;
    font-size: 0.8rem;
  }
  
  .chapter-count-input-group input {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .filter-window {
    padding: 1rem 0.5rem;
  }

  .story-types-grid {
    grid-template-columns: 1fr;
  }
}