* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0f0f0f;
  color: #e0e0e0;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  padding: 40px 0;
}

header h1 {
  font-size: 2.5rem;
  color: #fff;
  margin-bottom: 8px;
}

.subtitle {
  color: #888;
  font-size: 1.1rem;
}

.user-info {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 0.9rem;
  color: #888;
}

.user-info strong {
  color: #fff;
}

.card {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid #2a2a2a;
}

.card h2 {
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2a2a2a;
}

/* Setup Steps */
.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step {
  background: #222;
  border-radius: 8px;
  overflow: hidden;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
}

.step-number {
  width: 28px;
  height: 28px;
  background: #333;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.step.completed .step-number {
  background: #22c55e;
  color: #fff;
}

.step-title {
  flex: 1;
  font-weight: 500;
}

.step-status {
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 12px;
  background: #333;
}

.step-status.done {
  background: #22c55e33;
  color: #22c55e;
}

.step-status.pending {
  background: #eab30833;
  color: #eab308;
}

.step-content {
  padding: 0 16px 16px;
}

.step-content input {
  width: 100%;
  padding: 12px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.step-content input:focus {
  outline: none;
  border-color: #3b82f6;
}

.current-value {
  font-size: 0.85rem;
  color: #888;
  margin-top: 8px;
  word-break: break-all;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary {
  background: #3b82f6;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* Trakt Auth */
.device-code {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 20px;
  background: #333;
  border-radius: 8px;
  margin: 16px 0;
  font-family: monospace;
  color: #3b82f6;
}

.polling-status {
  text-align: center;
  color: #888;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #333;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 16px auto;
}

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

.success-text {
  color: #22c55e;
}

.hidden {
  display: none !important;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-box {
  background: #222;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
}

.stat-label {
  font-size: 0.85rem;
  color: #888;
  margin-top: 4px;
}

.worker-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 12px;
  background: #222;
  border-radius: 6px;
}

.worker-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
}

.worker-indicator.running {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e55;
}

.worker-indicator.idle {
  background: #eab308;
}

/* Cache Actions */
.cache-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2a2a2a;
}

/* Sync Progress */
.sync-progress {
  margin-top: 16px;
}

.progress-bar {
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

#sync-progress-text {
  font-size: 0.85rem;
  color: #888;
}

/* Cache Start Section */
.cache-start-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #2a2a2a;
  text-align: center;
}

.btn-large {
  padding: 14px 32px;
  font-size: 1.1rem;
}

/* Lists */
.lists-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #222;
  border-radius: 6px;
  transition: opacity 0.2s;
}

.list-item.disabled {
  opacity: 0.5;
}

.list-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.list-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-count {
  font-size: 0.85rem;
  color: #888;
  background: #333;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.list-type {
  font-size: 0.75rem;
  color: #666;
  text-transform: uppercase;
  background: #1a1a1a;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #888;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #22c55e33;
}

.toggle-switch input:checked + .toggle-slider:before {
  background-color: #22c55e;
  transform: translateX(22px);
}

.empty-state {
  color: #666;
  text-align: center;
  padding: 20px;
}

/* Addon URL */
.addon-url {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #222;
  padding: 12px 16px;
  border-radius: 6px;
  overflow: hidden;
}

.addon-url code {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  color: #3b82f6;
  word-break: break-all;
}

.hint {
  font-size: 0.85rem;
  color: #666;
  margin-top: 12px;
}

/* Notifications */
.notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 0.95rem;
  animation: slideIn 0.3s ease;
  z-index: 1000;
}

.notification.success {
  background: #22c55e;
  color: #fff;
}

.notification.error {
  background: #ef4444;
  color: #fff;
}

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