/**
 * YouTube工具集 - 现代设计系统 v5.0
 * 
 * 设计理念：
 * - 简洁现代的界面
 * - 舒适的配色方案
 * - 优雅的交互体验
 * - 清晰的视觉层级
 */

:root {
  /* === 主色调 - 柔和的蓝紫色 === */
  --primary-50: #f5f7ff;
  --primary-100: #ebf0ff;
  --primary-200: #d6e0ff;
  --primary-300: #b3c7ff;
  --primary-400: #8aa3ff;
  --primary-500: #6b7fff;
  --primary-600: #5568ee;
  --primary-700: #4451d9;
  --primary-800: #3742b3;
  --primary-900: #2d368f;

  /* === 灰度系统 === */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* === 功能色彩 === */
  --success-50: #f0fdf4;
  --success-500: #22c55e;
  --success-600: #16a34a;
  
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  
  --error-50: #fef2f2;
  --error-500: #ef4444;
  --error-600: #dc2626;

  /* === 语义化颜色 === */
  --bg-base: #ffffff;
  --bg-subtle: var(--gray-50);
  --bg-muted: var(--gray-100);
  
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-tertiary: var(--gray-500);
  --text-disabled: var(--gray-400);
  
  --border-light: var(--gray-200);
  --border-medium: var(--gray-300);
  --border-strong: var(--gray-400);

  /* === 间距系统 (8px grid) === */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* === 圆角 === */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* === 阴影 === */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* === 字体 === */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  
  /* 字重 */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* 字号 */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* === 过渡动画 === */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* === 布局 === */
  --container-max: 1400px;
}

/* === 全局样式 === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-subtle);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  padding: var(--space-6);
}

/* === 容器 === */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  background: var(--bg-base);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

/* === 头部 === */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--space-10) var(--space-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.header h1 {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

.header p {
  font-size: var(--text-base);
  opacity: 0.95;
  font-weight: var(--font-normal);
  position: relative;
  z-index: 1;
}

/* === 区块 === */
.config-section,
.filter-section,
.stats-section,
.results-section,
.toolbar,
.selection-toolbar,
.channel-links-section {
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-8);
}

.filter-section h3,
.section-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-6);
}

/* === 表单元素 === */
.input-group {
  margin-bottom: var(--space-6);
}

.input-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.input-group input,
.input-group select,
.filter-item input,
.filter-item select,
textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
}

.input-group input:hover,
.filter-item input:hover,
.input-group select:hover,
.filter-item select:hover {
  border-color: var(--border-medium);
}

.input-group input:focus,
.filter-item input:focus,
.input-group select:focus,
.filter-item select:focus,
textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(107, 127, 255, 0.1);
}

.input-group input::placeholder,
textarea::placeholder {
  color: var(--text-disabled);
}

/* === 按钮系统 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: var(--font-sans);
  line-height: 1;
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

.btn-secondary {
  background: var(--bg-base);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

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

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

.btn-danger {
  background: var(--error-500);
  color: white;
  border-color: var(--error-500);
}

.btn-danger:hover:not(:disabled) {
  background: var(--error-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

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

.button-group {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* === 筛选区域 === */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.filter-item {
  display: flex;
  flex-direction: column;
}

.filter-item label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  font-weight: var(--font-medium);
}

/* === 统计卡片 === */
.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-6);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
}

.stat-card {
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
  transition: all var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-200);
}

.stat-card .number {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  color: var(--primary-600);
  margin-bottom: var(--space-2);
  line-height: 1;
}

.stat-card .label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

/* === 视频卡片 === */
.results-section {
  padding: var(--space-8);
  background: var(--bg-subtle);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
}

.video-card {
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
  position: relative;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2xl);
  border-color: var(--primary-200);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: var(--gray-900);
  overflow: hidden;
}

.video-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.video-card:hover .video-thumbnail img {
  transform: scale(1.05);
}

.video-badge {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: rgba(239, 68, 68, 0.95);
  backdrop-filter: blur(8px);
  color: white;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  box-shadow: var(--shadow-lg);
}

.video-checkbox {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  width: 24px;
  height: 24px;
  cursor: pointer;
  z-index: 10;
  accent-color: var(--primary-600);
  display: none;
}

.select-mode .video-checkbox {
  display: block;
}

.video-card.selected {
  outline: 3px solid var(--primary-600);
  box-shadow: 0 0 0 3px rgba(107, 127, 255, 0.2);
}

.video-info {
  padding: var(--space-4);
}

.video-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.channel-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.channel-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gray-200);
  object-fit: cover;
  border: 2px solid var(--border-light);
}

.channel-details {
  flex: 1;
  min-width: 0;
}

.channel-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-stats {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.video-stats {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* === 标签 === */
.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  background: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
}

.tag.hot {
  background: var(--warning-50);
  color: var(--warning-600);
  border-color: var(--warning-200);
}

/* === 选择工具栏 === */
.selection-toolbar {
  padding: var(--space-5) var(--space-8);
  background: var(--primary-50);
  border-bottom: 1px solid var(--primary-200);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.selection-info {
  font-size: var(--text-sm);
  color: var(--primary-700);
  font-weight: var(--font-semibold);
}

.selection-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* === 博主链接区域 === */
.channel-links-section {
  padding: var(--space-8);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-light);
  display: none;
}

.channel-links-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.channel-link-item {
  background: var(--bg-base);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.channel-link-info {
  flex: 1;
  min-width: 0;
}

.channel-link-name {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.channel-link-url {
  color: var(--primary-600);
  font-size: var(--text-sm);
  word-break: break-all;
}

.btn-copy {
  background: var(--primary-600);
  color: white;
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.btn-copy:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* === 加载动画 === */
.loading {
  text-align: center;
  padding: var(--space-16);
  color: var(--text-tertiary);
}

.loading-spinner {
  border: 3px solid var(--border-light);
  border-top: 3px solid var(--primary-500);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === 消息提示 === */
.error,
.success,
.warning,
.message {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
  border: 1px solid;
}

.success {
  background: var(--success-50);
  color: var(--success-600);
  border-color: var(--success-500);
}

.error {
  background: var(--error-50);
  color: var(--error-600);
  border-color: var(--error-500);
}

.warning {
  background: var(--warning-50);
  color: var(--warning-600);
  border-color: var(--warning-500);
}

/* === 响应式 === */
@media (max-width: 768px) {
  body {
    padding: var(--space-4);
  }

  .container {
    border-radius: var(--radius-xl);
  }

  .header {
    padding: var(--space-8) var(--space-6);
  }

  .header h1 {
    font-size: var(--text-3xl);
  }

  .config-section,
  .filter-section,
  .stats-section,
  .results-section,
  .toolbar {
    padding: var(--space-6);
  }

  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
  }

  .selection-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .selection-actions {
    flex-direction: column;
  }

  .selection-actions .btn {
    width: 100%;
  }
}

/* === 滚动条 === */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-subtle);
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-subtle);
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) var(--bg-subtle);
}

/* === 可访问性 === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

*:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

