/* =========================================
   GLOBAL SELECT STYLING - ATOMIC LAB THEME
   ========================================= */

/* =================
   BASE SELECT STYLES
   ================= */
   
/* Global select element styling */
select,
.filter-select,
.search-select,
.control-select,
.element-select,
#element-select,
#compound-select,
#study-set,
#category,
#phase,
#radioactive,
#discoveryPeriod,
#sort,
#period-filter,
#group-filter,
#state-filter,
#block-filter {
  /* Layout & Spacing */
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  min-height: 2.75rem;
  width: 100%;
  box-sizing: border-box;
  
  /* Background & Border */
  background: var(--color-surface-primary);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300D4FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  border: 1px solid var(--color-surface-tertiary);
  border-radius: var(--radius-md);
  
  /* Typography */
  font-family: var(--font-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-regular);
  color: var(--color-text-primary);
  letter-spacing: 0.025em;
  line-height: 1.5;
  
  /* Interaction */
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
  transition: all var(--duration-fast) var(--ease-out);
  
  /* Shadows */
  box-shadow: var(--shadow-sm);
}

/* =================
   HOVER STATES
   ================= */
select:hover,
.filter-select:hover,
.search-select:hover,
.control-select:hover,
.element-select:hover,
#element-select:hover,
#compound-select:hover,
#study-set:hover,
#category:hover,
#phase:hover,
#radioactive:hover,
#discoveryPeriod:hover,
#sort:hover,
#period-filter:hover,
#group-filter:hover,
#state-filter:hover,
#block-filter:hover {
  background-color: var(--color-surface-secondary);
  border-color: var(--color-brand-primary);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300E676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  box-shadow: 0 0 0 1px var(--color-brand-primary), var(--shadow-md);
  transform: translateY(-1px);
}

/* =================
   FOCUS STATES
   ================= */
select:focus,
.filter-select:focus,
.search-select:focus,
.control-select:focus,
.element-select:focus,
#element-select:focus,
#compound-select:focus,
#study-set:focus,
#category:focus,
#phase:focus,
#radioactive:focus,
#discoveryPeriod:focus,
#sort:focus,
#period-filter:focus,
#group-filter:focus,
#state-filter:focus,
#block-filter:focus {
  background-color: var(--color-surface-secondary);
  border-color: var(--color-brand-primary);
  color: var(--color-text-primary);
  box-shadow: 0 0 0 2px var(--color-brand-primary), var(--shadow-lg);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300E676' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* =================
   DISABLED STATES
   ================= */
select:disabled,
.filter-select:disabled,
.search-select:disabled,
.control-select:disabled,
.element-select:disabled,
#element-select:disabled,
#compound-select:disabled,
#study-set:disabled {
  background-color: var(--color-surface-primary);
  border-color: var(--color-surface-tertiary);
  color: var(--color-text-disabled);
  cursor: not-allowed;
  opacity: 0.6;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234B5563' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  transform: none;
  box-shadow: none;
}

/* =================
   OPTION STYLING
   ================= */
select option,
.filter-select option,
.search-select option,
.control-select option,
.element-select option,
#element-select option,
#compound-select option,
#study-set option,
#category option,
#phase option,
#radioactive option,
#discoveryPeriod option,
#sort option,
#period-filter option,
#group-filter option,
#state-filter option,
#block-filter option {
  /* Background & Colors */
  background-color: var(--color-surface-primary);
  color: var(--color-text-primary);
  
  /* Typography */
  font-family: var(--font-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-regular);
  line-height: 1.5;
  
  /* Spacing */
  padding: 0.75rem 1rem;
  min-height: 2.5rem;
  
  /* Interaction */
  cursor: pointer;
  
  /* Border */
  border: none;
  border-bottom: 1px solid var(--color-surface-tertiary);
}

/* Option hover and selected states */
select option:hover,
select option:focus,
.filter-select option:hover,
.search-select option:hover,
.control-select option:hover {
  background-color: var(--color-surface-hover);
  color: var(--color-brand-primary);
}

select option:checked,
select option[selected],
.filter-select option:checked,
.search-select option:checked,
.control-select option:checked {
  background-color: var(--color-brand-primary);
  color: var(--color-text-on-brand);
  font-weight: var(--font-medium);
}

/* Default/Placeholder option styling */
select option[value=""],
.filter-select option[value=""],
.search-select option[value=""],
.control-select option[value=""] {
  color: var(--color-text-secondary);
  font-style: italic;
  background-color: var(--color-surface-secondary);
}

/* =================
   CATEGORY-SPECIFIC OPTIONS
   ================= */

/* Element category options with color coding */
select option[value*="alkali"]:not([value=""]),
select option[value*="Alkali"]:not([value=""]) {
  border-left: 3px solid var(--color-alkali);
  background: linear-gradient(90deg, rgba(255, 23, 68, 0.1) 0%, var(--color-surface-primary) 5%);
}

select option[value*="alkaline"]:not([value=""]),
select option[value*="Alkaline"]:not([value=""]) {
  border-left: 3px solid var(--color-alkaline);
  background: linear-gradient(90deg, rgba(255, 107, 0, 0.1) 0%, var(--color-surface-primary) 5%);
}

select option[value*="transition"]:not([value=""]),
select option[value*="Transition"]:not([value=""]) {
  border-left: 3px solid var(--color-transition);
  background: linear-gradient(90deg, rgba(0, 188, 212, 0.1) 0%, var(--color-surface-primary) 5%);
}

select option[value*="noble"]:not([value=""]),
select option[value*="Noble"]:not([value=""]) {
  border-left: 3px solid var(--color-brand-secondary);
  background: linear-gradient(90deg, rgba(189, 0, 255, 0.1) 0%, var(--color-surface-primary) 5%);
}

select option[value*="halogen"]:not([value=""]),
select option[value*="Halogen"]:not([value=""]) {
  border-left: 3px solid var(--color-brand-tertiary);
  background: linear-gradient(90deg, rgba(0, 255, 136, 0.1) 0%, var(--color-surface-primary) 5%);
}

select option[value*="lanthanide"]:not([value=""]),
select option[value*="Lanthanide"]:not([value=""]),
select option[value*="actinide"]:not([value=""]),
select option[value*="Actinide"]:not([value=""]) {
  border-left: 3px solid var(--color-brand-accent);
  background: linear-gradient(90deg, rgba(255, 107, 0, 0.1) 0%, var(--color-surface-primary) 5%);
}

/* =================
   RESPONSIVE DESIGN
   ================= */
@media (max-width: 768px) {
  select,
  .filter-select,
  .search-select,
  .control-select {
    font-size: var(--font-size-base);
    padding: 0.875rem 2.75rem 0.875rem 1.125rem;
    min-height: 3rem;
    background-size: 1.25rem;
    background-position: right 1rem center;
  }
  
  select option,
  .filter-select option,
  .search-select option,
  .control-select option {
    font-size: var(--font-size-base);
    padding: 1rem 1.25rem;
    min-height: 3rem;
  }
}

@media (max-width: 480px) {
  select,
  .filter-select,
  .search-select,
  .control-select {
    font-size: var(--font-size-sm);
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    min-height: 2.75rem;
  }
}

/* =================
   ACCESSIBILITY
   ================= */
@media (prefers-reduced-motion: reduce) {
  select,
  .filter-select,
  .search-select,
  .control-select {
    transition: none;
  }
  
  select:hover,
  .filter-select:hover,
  .search-select:hover,
  .control-select:hover {
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  select,
  .filter-select,
  .search-select,
  .control-select {
    border-width: 2px;
    border-color: var(--color-text-primary);
  }
  
  select:focus,
  .filter-select:focus,
  .search-select:focus,
  .control-select:focus {
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 3px var(--color-brand-primary);
  }
  
  select option,
  .filter-select option,
  .search-select option,
  .control-select option {
    border-bottom-width: 2px;
  }
}

/* =================
   WEBKIT SPECIFIC FIXES
   ================= */
@supports (-webkit-appearance: none) {
  select::-webkit-scrollbar,
  .filter-select::-webkit-scrollbar,
  .search-select::-webkit-scrollbar,
  .control-select::-webkit-scrollbar {
    width: 8px;
  }
  
  select::-webkit-scrollbar-track,
  .filter-select::-webkit-scrollbar-track,
  .search-select::-webkit-scrollbar-track,
  .control-select::-webkit-scrollbar-track {
    background: var(--color-surface-primary);
  }
  
  select::-webkit-scrollbar-thumb,
  .filter-select::-webkit-scrollbar-thumb,
  .search-select::-webkit-scrollbar-thumb,
  .control-select::-webkit-scrollbar-thumb {
    background: var(--color-surface-tertiary);
    border-radius: var(--radius-sm);
  }
  
  select::-webkit-scrollbar-thumb:hover,
  .filter-select::-webkit-scrollbar-thumb:hover,
  .search-select::-webkit-scrollbar-thumb:hover,
  .control-select::-webkit-scrollbar-thumb:hover {
    background: var(--color-brand-primary);
  }
}

/* =================
   FIREFOX SPECIFIC FIXES
   ================= */
@-moz-document url-prefix() {
  select,
  .filter-select,
  .search-select,
  .control-select {
    padding-right: 1.5rem;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300D4FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  }
}

/* =================
   DARK THEME OVERRIDES
   ================= */
.dark-theme select,
.dark-theme .filter-select,
.dark-theme .search-select,
.dark-theme .control-select,
[data-theme="dark"] select,
[data-theme="dark"] .filter-select,
[data-theme="dark"] .search-select,
[data-theme="dark"] .control-select {
  background-color: var(--color-surface-primary);
  border-color: var(--color-surface-tertiary);
  color: var(--color-text-primary);
}

.dark-theme select option,
.dark-theme .filter-select option,
.dark-theme .search-select option,
.dark-theme .control-select option,
[data-theme="dark"] select option,
[data-theme="dark"] .filter-select option,
[data-theme="dark"] .search-select option,
[data-theme="dark"] .control-select option {
  background-color: var(--color-surface-primary);
  color: var(--color-text-primary);
}