/* =============================================
   M3U8 诊断工具 - 设计系统
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(99, 102, 241, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #6366f1;
  --accent-blue-light: #818cf8;
  --accent-cyan: #22d3ee;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a78bfa;

  --gradient-hero: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-card: linear-gradient(145deg, rgba(99, 102, 241, 0.08), rgba(6, 182, 212, 0.04));
  --gradient-success: linear-gradient(135deg, #10b981, #34d399);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #fbbf24);
  --gradient-error: linear-gradient(135deg, #ef4444, #f87171);
  --gradient-info: linear-gradient(135deg, #6366f1, #818cf8);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 50% 60% at 50% 50%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Layout ---------- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  padding: 48px 0 32px;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: var(--gradient-hero);
  margin-bottom: 20px;
  font-size: 28px;
  box-shadow: var(--shadow-glow), 0 4px 12px rgba(99, 102, 241, 0.3);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.app-title {
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- Input Section ---------- */
.input-section {
  margin-bottom: 32px;
}

.input-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-normal);
}

.input-card:focus-within {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.input-group {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.url-input {
  flex: 1;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.95rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-normal);
}

.url-input::placeholder {
  color: var(--text-muted);
}

.url-input:focus {
  border-color: var(--accent-blue);
  background: rgba(99, 102, 241, 0.04);
}

.btn-diagnose {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--gradient-hero);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-diagnose:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-diagnose:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-diagnose .btn-icon {
  font-size: 1.1rem;
}

.input-hint {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Progress Section ---------- */
.progress-section {
  margin-bottom: 32px;
  display: none;
}

.progress-section.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.progress-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-counter {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.progress-bar-track {
  height: 4px;
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  margin-bottom: 24px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-hero);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.5s ease;
}

/* ---------- Check Items ---------- */
.check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
}

.check-item.running {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.06);
}

.check-item.pass {
  border-color: rgba(16, 185, 129, 0.2);
}

.check-item.warn {
  border-color: rgba(245, 158, 11, 0.2);
}

.check-item.fail {
  border-color: rgba(239, 68, 68, 0.2);
}

.check-item.skip {
  opacity: 0.5;
}

.check-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.check-item.pending .check-icon {
  background: var(--bg-glass);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.check-item.running .check-icon {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-blue-light);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.check-item.pass .check-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}

.check-item.warn .check-icon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

.check-item.fail .check-icon {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

.check-item.skip .check-icon {
  background: var(--bg-glass);
  color: var(--text-muted);
}

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

.check-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.check-detail {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.check-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.check-item.pass .check-badge {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.check-item.warn .check-badge {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
}

.check-item.fail .check-badge {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

.check-item.skip .check-badge {
  background: var(--bg-glass);
  color: var(--text-muted);
}

/* ---------- Results Section ---------- */
.results-section {
  display: none;
}

.results-section.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  transition: transform var(--transition-normal);
}

.summary-card:hover {
  transform: translateY(-2px);
}

.summary-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.summary-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-card.total .stat-value { color: var(--accent-blue-light); }
.summary-card.passed .stat-value { color: var(--accent-emerald); }
.summary-card.warnings .stat-value { color: var(--accent-amber); }
.summary-card.failed .stat-value { color: var(--accent-red); }

/* Report Card */
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.report-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.report-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action:hover {
  color: var(--text-primary);
  border-color: var(--border-glow);
  background: rgba(99, 102, 241, 0.06);
}

.report-body {
  padding: 0;
}

.report-item {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

.report-item:last-child {
  border-bottom: none;
}

.report-item:hover {
  background: var(--bg-glass);
}

.report-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.report-item-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.report-item-status.pass { background: var(--accent-emerald); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.report-item-status.warn { background: var(--accent-amber); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.report-item-status.fail { background: var(--accent-red); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.report-item-status.skip { background: var(--text-muted); }

.report-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.report-item-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  padding-left: 18px;
}

.report-item-suggestions {
  margin-top: 8px;
  padding-left: 18px;
}

.suggestion-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 3px 10px;
  margin: 2px 4px 2px 0;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-blue-light);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

/* Overall Score */
.overall-score {
  text-align: center;
  padding: 32px;
  background: var(--gradient-card);
  border-bottom: 1px solid var(--border-color);
}

.score-ring {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  position: relative;
}

.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring .track {
  fill: none;
  stroke: var(--bg-glass);
  stroke-width: 6;
}

.score-ring .fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease, stroke 0.5s ease;
}

.score-ring .score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.score-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .app-container {
    padding: 16px 12px 40px;
  }

  .app-header {
    padding: 32px 0 24px;
  }

  .app-title {
    font-size: 1.5rem;
  }

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

  .btn-diagnose {
    justify-content: center;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-blue-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: #fff;
  z-index: 1000;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  box-shadow: var(--shadow-lg);
}

.toast.success { background: var(--accent-emerald); }
.toast.error { background: var(--accent-red); }
.toast.warning { background: var(--accent-amber); color: #1a1a1a; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
