@import '../common-vars.css';

body {
  font-family: var(--font-family);
  background-color: var(--surface);
  margin: 0;
  padding: var(--spacing-2) var(--spacing-4);
  color: var(--on-surface);
  min-width: 320px;
  max-width: 320px;
  box-sizing: border-box;
  overflow: hidden;
}

.card {
  background-color: var(--surface-container);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--outline-variant);
}

.card-header {
  padding: var(--spacing-4);
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.card-body {
  padding: var(--spacing-2);
}

h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.15px;
}

.setting-group {
  margin-bottom: var(--spacing-2);
}

.setting-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: var(--spacing-2);
  font-weight: 500;
  font-size: 14px;
  color: var(--on-surface);
  letter-spacing: 0.1px;
}

select, button {
  width: 100%;
  padding: var(--spacing-3) var(--spacing-4);
  border-radius: var(--border-radius);
  border: 1px solid var(--outline);
  background: var(--surface-container-low);
  color: var(--on-surface);
  font-size: 14px;
  font-family: var(--font-family);
  transition: all 0.2s cubic-bezier(0.2, 0.0, 0, 1.0);
  box-sizing: border-box;
}

select {
  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='currentColor' 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 var(--spacing-3) center;
  background-size: 16px;
  padding-right: calc(var(--spacing-4) + 20px);
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
}

select:focus, button:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-container);
}

select:hover {
  background-color: var(--surface-container);
  border-color: var(--on-surface-variant);
}

/* 让浏览器自动处理下拉选项的颜色方案 */
select {
  color-scheme: light dark;
}

/* 在暗色模式下强制使用暗色方案并改善对比度 */
@media (prefers-color-scheme: dark) {
  select {
    color-scheme: dark;
  }
  
  select option {
    background-color: #2d2d2d !important;
    color: #ffffff !important;
  }
}

/* 强制暗色主题时 */
:root.dark select {
  color-scheme: dark;
}

:root.dark select option {
  background-color: #2d2d2d !important;
  color: #ffffff !important;
}

/* 强制浅色主题时 */
:root.light select {
  color-scheme: light;
}

:root.light select option {
  background-color: #ffffff !important;
  color: #000000 !important;
}

button {
  background-color: var(--primary-container);
  color: var(--on-primary-container);
  border: none;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: var(--spacing-2);
  border-radius: var(--border-radius-xl);
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

button:hover {
  background-color: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

.whitelist-section {
  margin-top: var(--spacing-2);
  padding-top: var(--spacing-2);
  border-top: 1px solid var(--outline-variant);
}

.whitelist-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-2);
  padding: var(--spacing-2) 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface-variant);
  transition: all 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
  border-radius: 16px;
  border: 2px solid var(--outline);
}

.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: var(--outline);
  transition: all 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

input:checked + .slider:before {
  background-color: var(--surface);
  transform: translateX(20px);
}

.slider:hover {
  box-shadow: 0 0 0 8px rgba(var(--primary), 0.08);
}

.whitelist-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
}

.whitelist-buttons button {
  margin-bottom: 0;
  font-size: 13px;
  padding: var(--spacing-2) var(--spacing-3);
  background-color: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: var(--border-radius);
  min-height: 36px;
}

.whitelist-buttons button:hover {
  background-color: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

#open-settings {
  margin-top: var(--spacing-2);
  background-color: var(--primary-container);
  color: var(--on-primary-container);
}

#open-settings:hover {
  background-color: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

#extension-footer {
  text-align: center;
  margin-top: var(--spacing-2);
  font-size: 11px;
  color: var(--on-surface-variant);
  padding: var(--spacing-1) 0;
}

#extension-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

#extension-footer a:hover {
  text-decoration: underline;
}