/* Shared component styles for popup and options pages.
 * Loaded after tokens.css, before page-specific stylesheets.
 * Page-specific overrides live in popup.css / options.css.
 */

/* ---- Toggle switch ---- */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-toggle);
  border-radius: 99px;
  transition: background 0.25s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  background: var(--toggle-thumb-bg);
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--bg-toggle-active);
}

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

/* ---- Currency picker ---- */

.currency-picker {
  position: relative;
  flex: 1;
  min-width: 0;
}

.currency-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--db-font);
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.currency-picker-trigger:hover {
  border-color: var(--text-tertiary);
}

.currency-picker-trigger.active {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.currency-picker-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.currency-picker-text.placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.currency-picker-chevron {
  font-size: 10px;
  opacity: 0.4;
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform 0.2s;
}

.currency-picker-trigger.active .currency-picker-chevron {
  transform: rotate(180deg);
  opacity: 0.7;
}

.currency-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  background: var(--bg-section);
  border: 1px solid var(--border-default);
  border-radius: var(--db-radius);
  box-shadow: var(--shadow-dropdown-lg);
  overflow: hidden;
}

.currency-picker-dropdown.open {
  display: block;
}

.currency-picker-search {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-family: var(--db-font);
  background: var(--bg-section);
  color: var(--text-primary);
  outline: none;
}

.currency-picker-search::placeholder {
  color: var(--text-tertiary);
}

.currency-picker-list {
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.currency-picker-group-label {
  position: sticky;
  top: 0;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-section);
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
}

.currency-picker-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.currency-picker-item:hover {
  background: var(--bg-card);
}

.currency-picker-item.selected {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-muted);
}

.currency-picker-item.empty {
  color: var(--text-tertiary);
  font-style: italic;
  cursor: default;
}

.currency-picker-item.empty:hover {
  background: transparent;
}

/* ---- Rate source picker ---- */

.rate-source-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: var(--db-font);
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.rate-source-picker:hover {
  border-color: var(--accent);
  color: var(--text-secondary);
}

.rate-source-picker.active {
  border-color: var(--accent);
  z-index: 50;
}

.rate-source-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--bg-app);
  border: 1px solid var(--border-default);
  border-radius: var(--db-radius);
  box-shadow: var(--shadow-dropdown);
  overflow: hidden;
  z-index: var(--z-dropdown);
}

.rate-source-picker-dropdown.open {
  display: block;
}

.rate-source-picker-search {
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-family: var(--db-font);
  background: var(--bg-app);
  color: var(--text-primary);
  outline: none;
}

.rate-source-picker-search::placeholder {
  color: var(--text-tertiary);
}

.rate-source-picker-list {
  max-height: 150px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rate-source-picker-list::-webkit-scrollbar {
  width: 4px;
}

.rate-source-picker-list::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.rate-source-picker-list::-webkit-scrollbar-track {
  background: transparent;
}

.rate-source-picker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.rate-source-picker-item:hover {
  background: var(--bg-card);
}

.rate-source-picker-item.active {
  color: var(--accent);
  font-weight: 600;
}

.rate-source-picker-item-check {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1.5px solid var(--border-default);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.rate-source-picker-item.active .rate-source-picker-item-check {
  border-color: var(--accent);
  background: var(--accent);
}

.rate-source-picker-item.active .rate-source-picker-item-check::after {
  content: '';
  width: 3px;
  height: 5px;
  border: solid var(--text-on-accent);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  margin-top: -1px;
}

.rate-source-picker-item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-source-picker-item-rate {
  margin-left: auto;
  font-family: var(--db-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* ---- Animations ---- */

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
