/* Design System Variables */
:root {
  --color-primary: #4096ff;
  --color-primary-hover: #1677ff;
  --color-primary-light: #e6f7ff;
  --color-success: #52c41a;
  --color-success-light: #f6ffed;
  --color-warning: #fa8c16;
  --color-warning-light: #fff2e8;
  --color-error: #ff4d4f;
  --color-error-light: #fff1f0;
  --color-text-primary: #262626;
  --color-text-secondary: #595959;
  --color-text-tertiary: #8c8c8c;
  --color-border: #d9d9d9;
  --color-border-light: #f0f0f0;
  --color-background: #ffffff;
  --color-background-light: #fafafa;
  --color-background-hover: #f5f5f5;

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  --spacing-3xl: 32px;

  --border-radius-sm: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 8px;
  --border-radius-xl: 12px;

  --font-size-xs: 10px;
  --font-size-sm: 12px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.2);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;
}

.enhanced-voice-selector {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-md);
  max-height: 80vh;
  overflow-y: auto;
}

/* Unified Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid transparent;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: white;
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.btn-icon {
  padding: var(--spacing-sm);
  min-width: 36px;
  background: white;
  color: var(--color-text-tertiary);
  border-color: var(--color-border);
}

.btn-icon:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-xs);
  min-height: 28px;
}

.btn-md {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  min-height: 32px;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: var(--font-size-md);
  min-height: 40px;
}

.selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-2xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 2px solid var(--color-border-light);
  position: relative;
}

.selector-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-success));
  border-radius: 1px;
}

.selector-title {
  margin: 0;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  line-height: 1.3;
}

.selector-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.search-and-filters {
  margin-bottom: 20px;
}

.search-container {
  margin-bottom: 16px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: #8c8c8c;
  font-size: 18px;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  font-size: 14px;
  background: #fafafa;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #4096ff;
  background: white;
  box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.1);
}

.search-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.clear-search-button {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: #f0f0f0;
  color: #8c8c8c;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-search-button:hover {
  background: #d9d9d9;
  color: #595959;
}

.filters-container {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-label {
  font-size: 12px;
  font-weight: 500;
  color: #595959;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  transition: all 0.2s ease;
}

.filter-select:focus {
  outline: none;
  border-color: #4096ff;
  box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.1);
}

.filter-select:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.clear-filters-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid #ff4d4f;
  border-radius: 6px;
  background: white;
  color: #ff4d4f;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-filters-button:hover:not(:disabled) {
  background: #ff4d4f;
  color: white;
}

.clear-filters-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.manual-input-section {
  margin-bottom: 20px;
  padding: 16px;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.input-mode-toggle {
  margin-bottom: 16px;
}

.toggle-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #4096ff;
  border-radius: 6px;
  background: #4096ff;
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-button:hover:not(:disabled) {
  background: #1677ff;
  border-color: #1677ff;
}

.toggle-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.manual-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-label {
  font-size: 12px;
  font-weight: 500;
  color: #595959;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.manual-input {
  padding: 10px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  transition: all 0.2s ease;
}

.manual-input:focus {
  outline: none;
  border-color: #4096ff;
  box-shadow: 0 0 0 2px rgba(64, 150, 255, 0.1);
}

.manual-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.voice-groups-container {
  max-height: 60vh;
  overflow-y: auto;
}

.loading-container,
.error-container,
.no-voices-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: #8c8c8c;
}

.loading-icon,
.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.loading-icon {
  animation: spin 1s linear infinite;
}

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

.error-container {
  color: #ff4d4f;
}

.error-container p {
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.5;
}

.retry-button {
  padding: 8px 16px;
  border: 1px solid #ff4d4f;
  border-radius: 6px;
  background: white;
  color: #ff4d4f;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-button:hover {
  background: #ff4d4f;
  color: white;
}

.no-voices-container {
  color: #8c8c8c;
}

.no-voices-container p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.voice-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.material-icons {
  font-size: 18px;
  line-height: 1;
}

/* Responsive design */
@media (max-width: 768px) {
  .enhanced-voice-selector {
    padding: 16px;
    max-height: 70vh;
  }

  .selector-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .selector-actions {
    justify-content: center;
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .manual-inputs {
    grid-template-columns: 1fr;
  }

  .voice-groups-container {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  .enhanced-voice-selector {
    padding: 12px;
  }

  .selector-title {
    font-size: 18px;
  }

  .filter-toggle-button,
  .refresh-button {
    padding: 6px 10px;
    font-size: 11px;
  }
}
