/* Buttons */
button {
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--button-bg);
  color: var(--button-text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--text-base, 13px);
  font-family: inherit;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  line-height: var(--leading-tight, 1.25);
}

button:hover {
  background: var(--button-hover);
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
}

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

button.danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.4);
}

button.danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--input-border);
}

button.ghost:hover {
  background: var(--button-hover);
}

button i {
  display: flex;
  align-items: center;
  font-size: 0.95em;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Icon Buttons */
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-color);
  opacity: 0.6;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
}

.icon-btn:hover {
  opacity: 1;
  background: rgba(255, 140, 0, 0.15);
  color: var(--accent);
}

.icon-btn i {
  pointer-events: none;
}

/* Shared Switch (label + input + span) – used in popup and list manager */
.switch-wrapper {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.switch-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--input-border);
  transition: 0.3s;
  border-radius: 11px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.switch-input:checked + .switch-slider {
  background-color: var(--accent);
}

.switch-input:checked + .switch-slider:before {
  transform: translateX(18px);
}


/* Switch Toggle (Checkbox Style) */
input[type="checkbox"].switch {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 36px;
  height: 20px;
  background: var(--switch-bg);
  border: none;
  border-radius: 20px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

input[type="checkbox"].switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: left 0.2s;
}

input[type="checkbox"].switch:checked {
  background: var(--accent);
}

input[type="checkbox"].switch:checked::before {
  left: 18px;
}

input[type="checkbox"].switch:hover {
  opacity: 0.9;
}

input[type="checkbox"].switch::after {
  content: none !important;
}

label:has(input.switch) {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

/* Checkboxes */
input[type="checkbox"]:not(.switch) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--input-bg);
  border: 1.5px solid var(--checkbox-border);
  border-radius: 4px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

input[type="checkbox"]:not(.switch):hover {
  border-color: var(--accent);
}

input[type="checkbox"]:not(.switch):checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

input[type="checkbox"]:not(.switch):checked::before {
  content: "✓";
  position: absolute;
  top: -3px;
  left: 2px;
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--section-bg);
  border-radius: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 8px;
  min-height: 24px;
  border: 2px solid var(--section-bg);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover);
}

::-webkit-scrollbar-corner {
  background: var(--section-bg);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--section-bg);
}

/* Form Inputs */
input[type="text"],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background-color: var(--input-bg);
  color: var(--text-color);
  font-size: var(--text-base, 13px);
  box-sizing: border-box;
  font-family: inherit;
  line-height: var(--leading-normal, 1.4);
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

/* Color Inputs */
input[type="color"] {
  background: none;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
}

input[type="color"]:hover {
  border-color: var(--accent);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 0;
}

input[type="color"]::-webkit-color-swatch {
  border-radius: 0;
  border: none;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

input[type="color"]::-moz-color-swatch {
  border-radius: 0;
  border: none;
  padding: 0;
  width: 100%;
  height: 100%;
}

/* Theme Toggle Icon */
.icon-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  color: var(--accent);
  font-size: 16px;
  border: 1px solid transparent;
}

.icon-toggle:hover {
  background: var(--highlight-tag);
  border-color: var(--highlight-tag-border);
  color: var(--accent-hover);
}

.hidden-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  display: none;
}

.toggle-icon {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: inherit;
  transition: all 0.2s ease;
}

.theme-icon::before {
  content: "\f185"; /* sun icon */
}

#themeToggle:checked + .theme-icon::before {
  content: "\f186"; /* moon icon */
}

/* Word list eye toggle (active/disabled) – replaces switch in word items */
.word-item-eye-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  margin-right: 6px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  color: var(--text-color);
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.word-item-eye-toggle:hover {
  opacity: 1;
  background: var(--highlight-tag);
  color: var(--accent);
}

.word-item-eye-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.word-item-eye-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.word-item-eye-icon i {
  position: absolute;
  font-size: 14px;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

/* Active state: show eye, hide eye-slash */
.word-item-eye-input:checked ~ .word-item-eye-icon .eye-active {
  opacity: 1;
  color: var(--accent);
}

.word-item-eye-input:checked ~ .word-item-eye-icon .eye-disabled {
  opacity: 0;
  pointer-events: none;
}

/* Disabled state: show eye-slash, hide eye */
.word-item-eye-input:not(:checked) ~ .word-item-eye-icon .eye-active {
  opacity: 0;
  pointer-events: none;
}

.word-item-eye-input:not(:checked) ~ .word-item-eye-icon .eye-disabled {
  opacity: 1;
  color: var(--text-color);
}
