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

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --bg-main: #090d16;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(24, 33, 53, 0.85);
  --bg-input: #0f172a;
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;

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

  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --accent-sky: #0284c7;

  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-emerald: linear-gradient(135deg, #10b981, #059669);
  --gradient-dark: linear-gradient(180deg, rgba(15,23,42,0.6), rgba(9,13,22,0.9));

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.05);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.06) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ──────────────────────────────────────────────── */
.app { position: relative; z-index: 1; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ──────────────────────────────────────────────── */
.header {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 13, 22, 0.88);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.logo-title {
  display: flex;
  flex-direction: column;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.logo-sub {
  font-size: 0.7rem;
  color: var(--accent-indigo);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav { display: flex; gap: 6px; }

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  background: none;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.nav-link.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}

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

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse 2s infinite;
}

.status-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-emerald);
}

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  padding: 40px 0 24px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-indigo);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 0.03em;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(16px);
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.2);
}

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

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

.icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.icon-box.violet { background: rgba(139, 92, 246, 0.15); }
.icon-box.blue { background: rgba(99, 102, 241, 0.15); }
.icon-box.green { background: rgba(16, 185, 129, 0.15); }

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

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Forms & Input Components ────────────────────────────── */
.form-card {
  margin-bottom: 32px;
}

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

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

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

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.required-star { color: var(--accent-rose); font-weight: 700; }
.label-optional { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.label-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-indigo);
  font-weight: 600;
}

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

.input-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.7;
}

.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.input-icon-wrapper .form-input {
  padding-left: 44px;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-textarea {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

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

.form-help code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-sky);
  font-family: 'JetBrains Mono', monospace;
}

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

/* ── Tabs inside Label ───────────────────────────────────── */
.label-with-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tab-pills {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 3px;
  border-radius: 20px;
  border: 1px solid var(--border-glass);
}

.tab-pill {
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.tab-pill.active {
  background: var(--accent-indigo);
  color: #fff;
}

/* ── Hugging Face Repo Chips & Provider Styling ─────────── */
.repo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.repo-chip {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #c084fc;
  cursor: pointer;
  transition: var(--transition);
}

.repo-chip:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: #c084fc;
  color: #fff;
}

.provider-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeInUp 0.3s ease-out both;
}


/* ── Upload Zone & Badges ────────────────────────────────── */
.upload-dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.6);
  transition: var(--transition);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.06);
}

.drop-icon { font-size: 2rem; margin-bottom: 8px; opacity: 0.7; }
.drop-title { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); margin-bottom: 4px; }
.drop-sub { font-size: 0.8rem; color: var(--text-muted); }

.file-loaded-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.file-name { font-size: 0.85rem; font-weight: 600; color: var(--accent-emerald); }
.file-remove { background: none; border: none; font-size: 1.2rem; color: var(--text-muted); cursor: pointer; }
.file-remove:hover { color: var(--accent-rose); }

/* ── Buttons ─────────────────────────────────────────────── */
.form-actions {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-glass);
}

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--accent-indigo);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-ghost:hover { text-decoration: underline; }

.btn-lg { padding: 14px 28px; font-size: 0.95rem; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon { background: none; border: 1px solid var(--border-glass); padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; }

/* ── Collapsible Existing Files Section ──────────────────── */
.collapsible-section {
  margin-top: 24px;
  border-top: 1px dashed var(--border-glass);
  padding-top: 16px;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}

.collapsible-header:hover { color: var(--accent-indigo); }
.collapsible-body { margin-top: 16px; }

/* ── Progress Card & Stepper ─────────────────────────────── */
.progress-card {
  margin-bottom: 32px;
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(15, 23, 42, 0.9);
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.spinner-ring {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

.progress-title { font-size: 1.1rem; font-weight: 700; }
.progress-subtitle { font-size: 0.85rem; color: var(--text-muted); }

.stepper-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.step-item {
  text-align: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-glass);
  transition: var(--transition);
}

.step-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-indigo);
}

.step-item.done {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--accent-emerald);
}

.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 auto 6px;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-item.done .step-icon { background: var(--accent-emerald); color: #fff; }
.step-item.active .step-icon { background: var(--accent-indigo); color: #fff; }

.step-label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }

.progress-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Stats Grid ──────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.01em; }
.section-subtitle { font-size: 0.85rem; color: var(--text-muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-icon-wrapper {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 20px;
  opacity: 0.6;
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.stat-value.blue { color: var(--accent-indigo); }
.stat-value.green { color: var(--accent-emerald); }
.stat-value.red { color: var(--accent-rose); }
.stat-value.amber { color: var(--accent-amber); }
.stat-value.purple { color: var(--accent-violet); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

/* ── Table Controls & Data Table ─────────────────────────── */
.table-controls {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.search-input, .filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
}

.search-input { flex: 1; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  padding: 14px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.table-wrapper {
  max-height: 520px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

/* ── Tool Call Code Box ──────────────────────────────────── */
.tool-code-box {
  background: rgba(15, 23, 42, 0.8);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--accent-sky);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  border: 1px solid rgba(255,255,255,0.05);
}

/* ── Modals & Settings ───────────────────────────────────── */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  z-index: 1001;
  background: #0f172a;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-card-lg {
  max-width: 820px;
}

/* ── Detail Modal Specifics ────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.detail-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.detail-item-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-item-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.detail-code-block {
  background: #070d19;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #38bdf8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}

.reason-alert-box {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.reason-alert-box.fail {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.reason-alert-box.pass {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.reason-alert-box.skip {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.2s ease;
}

.clickable-row:hover {
  background: rgba(99, 102, 241, 0.08) !important;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}


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

.modal-close { background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; }
.modal-body { display: flex; flex-direction: column; gap: 16px; }
.modal-footer { margin-top: 24px; display: flex; justify-content: flex-end; }
.input-with-action { display: flex; gap: 8px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

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

.page-btn.active { background: var(--accent-indigo); color: #fff; }

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border-glass);
  padding: 28px 0;
  margin-top: 60px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-indigo); }

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.animate-in { animation: fadeInUp 0.4s ease-out both; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .stepper-grid { grid-template-columns: repeat(2, 1fr); }
  .nav { display: none; }
  .header-actions { display: none; }
}
