/* ==========================================================================
   controls.css — Search, filter, sort, pagination, buttons, theme toggle
   ========================================================================== */

/* --------------------------------------------------------------------------
   Geography switch
   -------------------------------------------------------------------------- */

.geography-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.geography-switch__label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.geography-switch__select {
  min-width: 5.5rem;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-family: var(--font-family-base);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

.geography-switch__select:hover {
  background-color: var(--surface-hover);
}

.geography-switch__select:focus-visible {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

@media (max-width: 480px) {
  .geography-switch__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* --------------------------------------------------------------------------
   Search input
   -------------------------------------------------------------------------- */

.search-input {
  position: relative;
  width: 100%;
}

.search-input__icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input__field {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-8);
  font-family: var(--font-family-base);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
}

.search-input__field::placeholder {
  color: var(--text-muted);
}

.search-input__field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

[data-theme="dark"] .search-input__field:focus {
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.15);
}

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.filter-bar__row {
  display: flex;
  gap: var(--space-2);
}

.filter-bar__label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.filter-bar__select {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-family-base);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.filter-bar__select:focus {
  border-color: var(--border-focus);
}

/* --------------------------------------------------------------------------
   KPI bar items
   -------------------------------------------------------------------------- */

.kpi-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.kpi-item__value {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-item__label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.pagination__info {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.pagination__controls {
  display: flex;
  gap: var(--space-2);
}

.pagination__btn {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-family-base);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  color: var(--text-secondary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.pagination__btn:hover:not(:disabled) {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination__btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Theme toggle button
   -------------------------------------------------------------------------- */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Back button
   -------------------------------------------------------------------------- */

.back-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  font-family: var(--font-family-base);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
  color: var(--text-brand);
  cursor: pointer;
  padding: 0;
  margin-bottom: var(--space-6);
  transition: color var(--transition-fast);
}

.back-button:hover {
  color: var(--interactive-hover);
}

.back-button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Section heading
   -------------------------------------------------------------------------- */

.section-heading {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
}

.sidebar__heading {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.sidebar__count {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------------------
   Empty state (inline)
   -------------------------------------------------------------------------- */

.empty-state-inline {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
