/* 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;
}

/* 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);
}

/* Options Header */
.advanced-search-options h2 {
  color: var(--text-color);
  font-size: 1.3rem;
  margin-bottom: 1em;
  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;
  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);
}

/* Search Field */
.search-field {
  margin-bottom: 1em;
}

.search-field label {
  display: block;
  font-size: 1.1rem;
  color: var(--text-color);
  margin-bottom: 0.5em;
}

.search-field input[type="text"] {
  width: 100%;
  padding: 0.7em;
  border: 1px solid var(--input-border-color);
  background-color: var(--input-bg-color);
  color: var(--text-secondary-color);
  border-radius: 5px;
}

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

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

.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: 2px solid var(--primary-color);
}

.filter-window {
  display: none;
  padding: 20px;
  background: var(--search-panel-bg-color);
}

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

/* Filter Sections */
.filter-section {
  margin-bottom: 1em;
}

.filter-section h3 {
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 0.5em;
}

.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;
  font-weight: bold;
  margin-bottom: 0.5em;
}

/* Logic Selector (AND/OR) */
.logic-selector {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 10px;
}

.logic-selector label {
  display: flex;
  align-items: center;
  margin-right: 15px;
  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);
}

/* Checkbox Groups */
.filter-section .checkbox-group {
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--input-border-color);
  padding: 0.5em;
  border-radius: 5px;
  transition: max-height 0.3s ease;
}

.filter-section .checkbox-group:hover {
  max-height: 300px;
}

.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: var(--checkbox-hover-bg);
  border-color: var(--checkbox-hover-border);
}

.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;
}

/* 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;
    display: flex;
    padding: 20px;
    box-sizing: border-box;
    margin-top: 4em;
    width: calc(100% - 4.4em);
  }
  
  .search-results-container {
    width: 100%;
    max-width: 100%;
  }

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

  .options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
    padding: 0.5em;
  }
  
  .toggle-button {
    display: inherit;
  }
  
  .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;
  }

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

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

@media (max-width: 769px) {
  .advanced-search-options {
    flex: none;
    width: 100%;
    margin-right: 0;
    margin-bottom: 20px;
    padding: 10px;
  }

  .options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
    padding: 0.5em 0;
  }
  
  .toggle-button {
    display: inherit;
  }
  
  .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;
  }

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