/* =========================================================
   LinkSequencer — Main Stylesheet
   Design system: tokens → base → components → layout
   ========================================================= */

/* ── Google Fonts ───────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design tokens ──────────────────────────────────────── */
:root {
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  /* Neutral palette */
  --gray-50:  #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;

  /* Accent — refined teal/slate blue */
  --accent-50:  #eff8ff;
  --accent-100: #dbeefe;
  --accent-200: #bfe0fd;
  --accent-300: #91cbfc;
  --accent-400: #5caef8;
  --accent-500: #3b8ef3;
  --accent-600: #2570e8;
  --accent-700: #1d5bd4;
  --accent-800: #1e4bac;
  --accent-900: #1e3f88;

  /* Semantic colors */
  --success-400: #34d399;
  --success-500: #10b981;
  --success-600: #059669;
  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --danger-400:  #f87171;
  --danger-500:  #ef4444;
  --danger-600:  #dc2626;
  --info-400:    #60a5fa;
  --info-500:    #3b82f6;

  /* Light theme surface colors */
  --surface-bg:      #f4f6f8;
  --surface-card:    #ffffff;
  --surface-card-2:  #f9fafc;
  --surface-border:  #e4e8ef;
  --surface-hover:   #f0f4f8;
  --surface-input:   #ffffff;

  /* Light theme text */
  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --text-accent:    var(--accent-600);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.08), 0 8px 10px rgba(0,0,0,.05);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:  cubic-bezier(0.4, 0, 1, 1);
  --transition: 180ms var(--ease-out);
  --transition-slow: 350ms var(--ease-out);

  /* Layout */
  --max-width: 1200px;
  --sidebar-w: 360px;
}

/* ── Dark theme ─────────────────────────────────────────── */
[data-theme="dark"] {
  --surface-bg:      #0d1117;
  --surface-card:    #161b22;
  --surface-card-2:  #1c2128;
  --surface-border:  #2a3140;
  --surface-hover:   #1f2733;
  --surface-input:   #1c2128;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;
  --text-accent:    var(--accent-400);

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.25);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.4), 0 4px 6px rgba(0,0,0,.3);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.45), 0 8px 10px rgba(0,0,0,.3);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--surface-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ── Focus ring ─────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-500);
  outline-offset: 2px;
}

/* ========================================================= */
/* LAYOUT                                                     */
/* ========================================================= */

.app-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 28px;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-500), var(--accent-700));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,142,243,.35);
}

.header-logo svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.header-text h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-text p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Main grid ──────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--surface-border);
  gap: 12px;
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-50);
  color: var(--accent-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .card-icon {
  background: rgba(59,142,243,.12);
  color: var(--accent-400);
}

.card-icon svg { width: 16px; height: 16px; }

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.card-body {
  padding: 20px;
}

/* ── Section stack ──────────────────────────────────────── */
.section-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========================================================= */
/* FORM ELEMENTS                                              */
/* ========================================================= */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-label .badge {
  font-size: 0.68rem;
  background: var(--accent-100);
  color: var(--accent-700);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

[data-theme="dark"] .form-label .badge {
  background: rgba(59,142,243,.15);
  color: var(--accent-300);
}

.form-control {
  width: 100%;
  background: var(--surface-input);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-400);
  box-shadow: 0 0 0 3px rgba(59,142,243,.15);
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control {
  resize: vertical;
  min-height: 220px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
}

.form-helper {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

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

/* ── Interval selector ──────────────────────────────────── */
.interval-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.interval-tab {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--surface-border);
  background: var(--surface-card-2);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.interval-tab:hover {
  border-color: var(--accent-400);
  color: var(--accent-600);
  background: var(--accent-50);
}

[data-theme="dark"] .interval-tab:hover {
  background: rgba(59,142,243,.08);
  color: var(--accent-400);
}

.interval-tab.active {
  background: var(--accent-600);
  border-color: var(--accent-600);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,142,243,.35);
}

.interval-custom-fields {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  margin-top: 8px;
  animation: slideDown 200ms var(--ease-out) both;
}

.interval-custom-fields.visible { display: flex; }

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

/* ── Toggle switch ──────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.toggle-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.toggle-sublabel {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-xs);
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent-500); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-slider { outline: 2px solid var(--accent-500); outline-offset: 2px; }

/* ========================================================= */
/* BUTTONS                                                    */
/* ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

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

/* Primary */
.btn-primary {
  background: var(--accent-600);
  color: #fff;
  border-color: var(--accent-600);
  box-shadow: 0 1px 3px rgba(37,112,232,.25);
}
.btn-primary:hover {
  background: var(--accent-700);
  border-color: var(--accent-700);
  box-shadow: 0 4px 12px rgba(37,112,232,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* Success */
.btn-success {
  background: var(--success-600);
  color: #fff;
  border-color: var(--success-600);
  box-shadow: 0 1px 3px rgba(5,150,105,.25);
}
.btn-success:hover {
  background: #047857;
  border-color: #047857;
  box-shadow: 0 4px 12px rgba(5,150,105,.35);
  transform: translateY(-1px);
}

/* Warning */
.btn-warning {
  background: var(--warning-500);
  color: #fff;
  border-color: var(--warning-500);
}
.btn-warning:hover { background: #d97706; }

/* Danger */
.btn-danger {
  background: var(--danger-500);
  color: #fff;
  border-color: var(--danger-500);
}
.btn-danger:hover { background: var(--danger-600); }

/* Ghost / outline */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--surface-border);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--gray-400);
}

/* Small */
.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}
.btn-sm svg { width: 13px; height: 13px; }

/* Icon-only */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Control strip */
.controls-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ========================================================= */
/* PROGRESS / STATUS                                          */
/* ========================================================= */

.progress-section { display: flex; flex-direction: column; gap: 14px; }

.progress-bar-wrap {
  position: relative;
  height: 8px;
  background: var(--surface-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-400));
  border-radius: var(--radius-full);
  transition: width 600ms var(--ease-out);
  box-shadow: 0 0 10px rgba(59,142,243,.4);
}

.progress-bar-fill.complete {
  background: linear-gradient(90deg, var(--success-500), var(--success-400));
  box-shadow: 0 0 10px rgba(16,185,129,.4);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-value.accent { color: var(--accent-600); }
[data-theme="dark"] .stat-value.accent { color: var(--accent-400); }
.stat-value.success { color: var(--success-500); }

/* Countdown */
.countdown-display {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.countdown-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-50);
  color: var(--accent-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

[data-theme="dark"] .countdown-icon {
  background: rgba(59,142,243,.12);
  color: var(--accent-400);
}

.countdown-icon svg { width: 18px; height: 18px; }

.countdown-label { font-size: 0.75rem; color: var(--text-muted); }
.countdown-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Current URL display */
.current-url-display {
  padding: 12px 14px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-left: 3px solid var(--accent-500);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.current-url-label { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.current-url-text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-url-link {
  color: inherit;
  text-decoration: none;
}

.current-url-link:hover { text-decoration: underline; }

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-idle    { background: var(--gray-100); color: var(--gray-600); }
.status-running { background: #dcfce7; color: #15803d; }
.status-paused  { background: #fef9c3; color: #854d0e; }
.status-stopped { background: #fee2e2; color: #b91c1c; }
.status-done    { background: #dcfce7; color: #15803d; }

[data-theme="dark"] .status-idle    { background: rgba(255,255,255,.06); color: var(--gray-400); }
[data-theme="dark"] .status-running { background: rgba(52,211,153,.12); color: var(--success-400); }
[data-theme="dark"] .status-paused  { background: rgba(251,191,36,.10); color: var(--warning-400); }
[data-theme="dark"] .status-stopped { background: rgba(248,113,113,.10); color: var(--danger-400); }
[data-theme="dark"] .status-done    { background: rgba(52,211,153,.12); color: var(--success-400); }

.status-badge.status-running::before { animation: pulse-dot 1s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.7); }
}

/* ========================================================= */
/* URL LIST PREVIEW                                           */
/* ========================================================= */

.url-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.url-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

.pill-success { background: #dcfce7; color: #15803d; }
.pill-danger  { background: #fee2e2; color: #b91c1c; }

[data-theme="dark"] .pill-success { background: rgba(52,211,153,.12); color: var(--success-400); }
[data-theme="dark"] .pill-danger  { background: rgba(248,113,113,.10); color: var(--danger-400); }

.url-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.url-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.url-item:hover { background: var(--surface-hover); }

.url-item-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.url-item-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-decoration: none;
}

.url-item-text:hover { text-decoration: underline; }

.url-item.active-url {
  border-color: var(--accent-400);
  background: var(--accent-50);
}

[data-theme="dark"] .url-item.active-url {
  background: rgba(59,142,243,.08);
  border-color: var(--accent-600);
}

.url-item.opened-url {
  opacity: .55;
}

.url-item.opened-url .url-item-text {
  text-decoration: line-through;
}

.invalid-list {
  padding: 10px 12px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
}

[data-theme="dark"] .invalid-list {
  background: rgba(239,68,68,.06);
  border-color: rgba(239,68,68,.2);
}

.invalid-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--danger-600);
  margin-bottom: 6px;
}

[data-theme="dark"] .invalid-list-title { color: var(--danger-400); }

.invalid-item {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--danger-500);
  padding: 2px 0;
}

/* ========================================================= */
/* HISTORY PANEL                                              */
/* ========================================================= */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}

.history-item {
  padding: 12px 14px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item:hover {
  border-color: var(--accent-400);
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
}

.history-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.history-item-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.history-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.meta-chip svg { width: 12px; height: 12px; }

.favorite-btn.is-fav svg { color: #f59e0b; fill: #f59e0b; }

/* Load More / Pagination */
.load-more-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
}

.load-more-btn svg { width: 13px; height: 13px; }

.load-more-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg { width: 36px; height: 36px; opacity: .4; }
.empty-state p { font-size: 0.82rem; }

/* History search */
.history-search {
  position: relative;
}

.history-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.history-search .form-control { padding-left: 32px; }

/* ========================================================= */
/* MODAL                                                      */
/* ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(.95) translateY(8px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

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

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

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--surface-border);
}

/* ========================================================= */
/* TOAST NOTIFICATIONS                                        */
/* ========================================================= */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 340px;
  pointer-events: all;
  animation: toastIn 300ms var(--ease-out) both;
}

.toast.toast-out { animation: toastOut 250ms var(--ease-in) both; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(.95); }
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-icon svg { width: 12px; height: 12px; }

.toast-success .toast-icon { background: #dcfce7; color: #15803d; }
.toast-error   .toast-icon { background: #fee2e2; color: #b91c1c; }
.toast-info    .toast-icon { background: var(--accent-100); color: var(--accent-700); }
.toast-warning .toast-icon { background: #fef9c3; color: #854d0e; }

[data-theme="dark"] .toast-success .toast-icon { background: rgba(52,211,153,.15); color: var(--success-400); }
[data-theme="dark"] .toast-error   .toast-icon { background: rgba(248,113,113,.12); color: var(--danger-400); }
[data-theme="dark"] .toast-info    .toast-icon { background: rgba(59,142,243,.15); color: var(--accent-400); }
[data-theme="dark"] .toast-warning .toast-icon { background: rgba(251,191,36,.12); color: var(--warning-400); }

.toast-content { flex: 1; }
.toast-title   { font-size: 0.83rem; font-weight: 600; color: var(--text-primary); }
.toast-message { font-size: 0.77rem; color: var(--text-secondary); margin-top: 2px; line-height: 1.4; }

/* ========================================================= */
/* THEME PICKER (segmented control)                           */
/* ========================================================= */

.theme-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

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

.theme-toggle svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* Hide all icons by default, show based on active theme */
.theme-icon { display: none; }

.theme-toggle[data-active-theme="system"] .theme-icon--system,
.theme-toggle[data-active-theme="light"] .theme-icon--light,
.theme-toggle[data-active-theme="dark"] .theme-icon--dark {
  display: block;
}

/* Fallback: show system icon if no data-active-theme attribute */
.theme-toggle:not([data-active-theme]) .theme-icon--system {
  display: block;
}

/* ========================================================= */
/* KEYBOARD SHORTCUTS HINT                                    */
/* ========================================================= */

.kbd-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ========================================================= */
/* ALERTS / BANNERS                                           */
/* ========================================================= */

.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.5;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-warning {
  background: #fef9c3;
  border: 1px solid #fde047;
  color: #854d0e;
}

[data-theme="dark"] .alert-warning {
  background: rgba(251,191,36,.08);
  border-color: rgba(251,191,36,.2);
  color: var(--warning-400);
}

.alert-info {
  background: var(--accent-50);
  border: 1px solid var(--accent-200);
  color: var(--accent-800);
}

[data-theme="dark"] .alert-info {
  background: rgba(59,142,243,.06);
  border-color: rgba(59,142,243,.2);
  color: var(--accent-300);
}

/* ========================================================= */
/* MISC UTILITIES                                             */
/* ========================================================= */

.hidden { display: none !important; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success-500); }
.text-danger   { color: var(--danger-500); }
.text-accent   { color: var(--text-accent); }
.text-sm       { font-size: 0.82rem; }
.font-mono     { font-family: var(--font-mono); }
.font-bold     { font-weight: 700; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mb-2  { margin-bottom: 8px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }

.divider {
  height: 1px;
  background: var(--surface-border);
}

/* Loading spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* ========================================================= */
/* ESTIMATED RUNTIME CHIP                                     */
/* ========================================================= */

.runtime-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--surface-card-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.runtime-chip svg { width: 13px; height: 13px; color: var(--text-muted); }

/* ========================================================= */
/* RESPONSIVE TWEAKS                                          */
/* ========================================================= */

@media (max-width: 640px) {
  .app-header { padding: 14px 0 18px; }
  .header-text p { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .controls-strip { gap: 6px; }
  .toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}

@media (max-width: 400px) {
  .interval-tabs { gap: 4px; }
  .interval-tab { padding: 6px 10px; font-size: 0.75rem; }
}

/* ========================================================= */
/* CONFIRM DELETE ANIMATION                                   */
/* ========================================================= */

.confirm-delete-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  animation: slideDown 180ms var(--ease-out) both;
}

[data-theme="dark"] .confirm-delete-row {
  background: rgba(239,68,68,.06);
  border-color: rgba(239,68,68,.2);
}

.confirm-delete-row span {
  font-size: 0.78rem;
  color: var(--danger-600);
  flex: 1;
}

[data-theme="dark"] .confirm-delete-row span { color: var(--danger-400); }

/* ========================================================= */
/* BATCH DETAIL MODAL URLS                                    */
/* ========================================================= */

.modal-url-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.modal-url-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-card-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
}

.modal-url-item .num {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.modal-url-item .url {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.modal-url-item .url:hover { text-decoration: underline; }

/* ========================================================= */
/* SUMMARY SECTION                                            */
/* ========================================================= */

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--surface-border);
  font-size: 0.82rem;
}

.summary-row:last-child { border-bottom: none; }
.summary-key { color: var(--text-muted); }
.summary-val { color: var(--text-primary); font-weight: 500; }
