/* ═══════════════════════════════════════════════════
   Diabolocom Bulk Importer — Main Stylesheet
   Aesthetic: Industrial utility × brand precision
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=Syne:wght@400;500;600;700;800&display=swap');

/* ── Variables ─────────────────────────────────── */
:root {
  --c-purple:       #4B35C8;
  --c-purple-light: #6B55E8;
  --c-purple-dim:   #2D1F80;
  --c-purple-faint: #1a1040;
  --c-bg:           #0d0d12;
  --c-bg-2:         #111118;
  --c-bg-3:         #16161f;
  --c-surface:      #1c1c28;
  --c-surface-2:    #22222f;
  --c-border:       #2a2a3a;
  --c-border-2:     #343448;
  --c-text:         #e8e8f0;
  --c-text-2:       #9898b8;
  --c-text-3:       #5a5a7a;
  --c-green:        #2dd4a0;
  --c-green-dim:    #1a7a5a;
  --c-red:          #f04060;
  --c-red-dim:      #7a1830;
  --c-orange:       #f0a030;
  --c-orange-dim:   #7a4a10;
  --c-blue:         #40a8f0;
  --c-blue-dim:     #184878;

  --font-head: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --transition: 150ms ease;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-mono);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Noise texture overlay ──────────────────────── */
.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.5;
}

/* ── Header ─────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(180deg, var(--c-bg) 0%, rgba(13,13,18,0.96) 100%);
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1600px; margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex; align-items: center; gap: 20px;
}
.logo-wrap { display: flex; align-items: center; }
.logo { height: 28px; width: auto; filter: brightness(1.05); }
.header-title {
  display: flex; flex-direction: column; gap: 0;
  border-left: 1px solid var(--c-border-2);
  padding-left: 20px;
  margin-left: 4px;
}
.title-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--c-purple-light);
  letter-spacing: 0.1em;
  line-height: 1;
}
.header-title h1 {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -0.01em;
  line-height: 1;
}
.header-meta { margin-left: auto; }
.version-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--c-text-3);
  border: 1px solid var(--c-border);
  padding: 3px 8px;
  border-radius: 20px;
}

/* ── Main layout ────────────────────────────────── */
.main {
  position: relative; z-index: 1;
  max-width: 1600px; margin: 0 auto;
  padding: 24px;
}
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .panel--config { position: static; }
}

/* ── Panels & Cards ─────────────────────────────── */
.panel, .card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel--config {
  position: sticky; top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border-2) transparent;
}
.panel--config::-webkit-scrollbar { width: 4px; }
.panel--config::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 2px; }

.panel-header, .card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: var(--c-bg-3);
  border-bottom: 1px solid var(--c-border);
}
.panel-header h2, .card-header h2 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text);
  flex: 1;
}
.panel-icon { font-size: 14px; }
.panel-toggle {
  background: none; border: none; color: var(--c-text-2);
  cursor: pointer; font-size: 18px; padding: 0 4px;
  line-height: 1; transition: color var(--transition);
}
.panel-toggle:hover { color: var(--c-text); }
.card-header-actions { display: flex; gap: 8px; margin-left: auto; }

.panel-body { padding: 18px; }
.card-body { padding: 18px; }

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

/* Step numbers */
.step-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--c-purple-light);
  border: 1px solid var(--c-purple-dim);
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: 0.05em;
}

/* ── Config form ────────────────────────────────── */
.config-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--c-border);
}
.config-section:last-child { border-bottom: none; margin-bottom: 0; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-2);
  margin-bottom: 14px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.dot--purple  { background: var(--c-purple-light); box-shadow: 0 0 6px var(--c-purple); }
.dot--blue    { background: var(--c-blue);  box-shadow: 0 0 6px var(--c-blue-dim); }
.dot--green   { background: var(--c-green); box-shadow: 0 0 6px var(--c-green-dim); }
.dot--orange  { background: var(--c-orange); box-shadow: 0 0 6px var(--c-orange-dim); }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--c-text-2);
  margin-bottom: 5px;
  letter-spacing: 0.05em;
}
.req { color: var(--c-red); }
.field-hint {
  display: block;
  font-size: 10px;
  color: var(--c-text-3);
  margin-top: 4px;
  line-height: 1.4;
}
.field-hint code {
  background: var(--c-bg-3);
  border: 1px solid var(--c-border);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--c-purple-light);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius);
  color: var(--c-text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
  border-color: var(--c-purple);
  box-shadow: 0 0 0 2px rgba(75,53,200,0.25);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a5a7a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.input-with-toggle {
  position: relative;
}
.input-with-toggle input { padding-right: 38px; }
.toggle-vis {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--c-text-3);
  padding: 2px;
  transition: color var(--transition);
}
.toggle-vis:hover { color: var(--c-text-2); }

/* Task chips */
.task-grid {
  display: flex; flex-direction: column; gap: 6px;
}
.task-chip {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 10px;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}
.task-chip:hover { border-color: var(--c-purple); }
.task-chip input { display: none; }
.task-chip span {
  font-size: 11px;
  color: var(--c-text-2);
  font-family: var(--font-mono);
}
.task-chip:has(input:checked) {
  background: rgba(75,53,200,0.12);
  border-color: var(--c-purple-dim);
}
.task-chip:has(input:checked) span { color: var(--c-purple-light); }
.task-chip::before {
  content: '○';
  font-size: 12px;
  color: var(--c-text-3);
  transition: all var(--transition);
  flex-shrink: 0;
}
.task-chip:has(input:checked)::before {
  content: '●';
  color: var(--c-purple-light);
}

/* Toggle switch */
.toggle-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.toggle-label.small { font-size: 12px; }
.toggle-label input { display: none; }
.toggle-switch {
  position: relative;
  width: 34px; height: 18px; flex-shrink: 0;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border-2);
  border-radius: 18px;
  transition: background var(--transition), border-color var(--transition);
}
.toggle-switch::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 12px; height: 12px;
  background: var(--c-text-3);
  border-radius: 50%;
  transition: left var(--transition), background var(--transition);
}
.toggle-label:has(input:checked) .toggle-switch {
  background: rgba(75,53,200,0.3);
  border-color: var(--c-purple);
}
.toggle-label:has(input:checked) .toggle-switch::after {
  left: 18px;
  background: var(--c-purple-light);
}

.field--inline { background: var(--c-bg-2); padding: 10px; border-radius: var(--radius); border: 1px solid var(--c-border); }

/* Format preview */
.format-preview {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--c-purple-faint);
  border: 1px solid var(--c-purple-dim);
  border-radius: var(--radius);
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 11px;
}
.fp-label { color: var(--c-text-3); flex-shrink: 0; }
.fp-value { color: var(--c-purple-light); word-break: break-all; font-family: var(--font-mono); }

/* Config actions */
.config-actions { display: flex; gap: 8px; padding-top: 4px; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  white-space: nowrap;
}
.btn--primary {
  background: var(--c-purple);
  color: #fff;
  border-color: var(--c-purple);
  box-shadow: 0 2px 12px rgba(75,53,200,0.4);
}
.btn--primary:hover {
  background: var(--c-purple-light);
  border-color: var(--c-purple-light);
  box-shadow: 0 4px 20px rgba(75,53,200,0.6);
  transform: translateY(-1px);
}
.btn--primary:active { transform: translateY(0); }
.btn--secondary {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: var(--c-border-2);
}
.btn--secondary:hover { border-color: var(--c-purple); color: var(--c-purple-light); }
.btn--ghost {
  background: transparent;
  color: var(--c-text-2);
  border-color: var(--c-border);
}
.btn--ghost:hover { border-color: var(--c-border-2); color: var(--c-text); background: var(--c-surface-2); }
.btn--sm { padding: 5px 10px; font-size: 11px; }
.btn--large { padding: 12px 28px; font-size: 14px; }
.btn-icon { font-size: 11px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--c-purple-light);
  font-family: inherit; font-size: inherit;
  text-decoration: underline;
  padding: 0;
  transition: color var(--transition);
}
.link-btn:hover { color: var(--c-purple-light); }
.link-btn.danger { color: var(--c-red); }
.link-btn.danger:hover { color: #ff6080; }

/* ── Dropzone ───────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--c-border-2);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  background: var(--c-bg-2);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--c-purple);
  background: rgba(75,53,200,0.06);
  box-shadow: inset 0 0 0 1px rgba(75,53,200,0.2);
}
.dropzone-inner { pointer-events: none; }
.dz-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.6; }
.dz-text {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
}
.dz-hint { font-size: 11px; color: var(--c-text-3); }

.file-count-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--c-text-2);
}

/* ── Preview table ──────────────────────────────── */
.preview-toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.search-input {
  flex: 1;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius);
  color: var(--c-text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--c-purple); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--c-border); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  background: var(--c-bg-3);
  color: var(--c-text-3);
  font-family: var(--font-head);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--c-border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(75,53,200,0.05); }
tbody td {
  padding: 9px 12px;
  color: var(--c-text);
  font-family: var(--font-mono);
  font-size: 11px;
  vertical-align: middle;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-check { width: 36px; text-align: center; }

/* Status badges */
.badge, .status-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-head);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge { background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); }
.status-ok     { background: rgba(45,212,160,0.12); color: var(--c-green); border: 1px solid var(--c-green-dim); }
.status-error  { background: rgba(240,64,96,0.12);  color: var(--c-red);   border: 1px solid var(--c-red-dim); }
.status-warn   { background: rgba(240,160,48,0.12); color: var(--c-orange); border: 1px solid var(--c-orange-dim); }
.status-dry    { background: rgba(64,168,240,0.12); color: var(--c-blue);  border: 1px solid var(--c-blue-dim); }
.status-skip   { background: var(--c-surface-2);   color: var(--c-text-3); border: 1px solid var(--c-border); }
.status-pending { background: rgba(75,53,200,0.12); color: var(--c-purple-light); border: 1px solid var(--c-purple-dim); }

/* Preview footer */
.preview-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--c-border);
  gap: 12px;
}
.parse-errors {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: rgba(240,160,48,0.08);
  border: 1px solid var(--c-orange-dim);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--c-orange);
  flex: 1;
}
.warn-icon { font-size: 14px; }

/* ── Progress & Stats ───────────────────────────── */
.progress-wrap {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
.progress-info {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--c-text-2);
  margin-bottom: 8px;
}
.progress-bar-outer {
  background: var(--c-bg-3);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--c-purple), var(--c-purple-light));
  border-radius: 20px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(107,85,232,0.5);
}

.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.stat-card {
  text-align: center; padding: 14px;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
.stat-num {
  display: block;
  font-family: var(--font-head);
  font-size: 26px; font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  display: block; font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--c-text-3);
}
.stat-card--total   .stat-num { color: var(--c-text); }
.stat-card--success .stat-num { color: var(--c-green); }
.stat-card--error   .stat-num { color: var(--c-red); }
.stat-card--skipped .stat-num { color: var(--c-text-3); }

/* Results row actions */
.row-action {
  background: none; border: none; cursor: pointer;
  color: var(--c-purple-light); font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background var(--transition);
  text-decoration: underline;
}
.row-action:hover { background: rgba(75,53,200,0.15); }

/* ── Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  align-items: flex-end;
}
.toast {
  min-width: 260px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  border: 1px solid var(--c-border-2);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast--success { background: #0d1f18; border-color: var(--c-green-dim); color: var(--c-green); }
.toast--error   { background: #1f0d12; border-color: var(--c-red-dim);   color: var(--c-red); }
.toast--info    { background: var(--c-surface); border-color: var(--c-purple-dim); color: var(--c-purple-light); }
.toast--warn    { background: #1f1205; border-color: var(--c-orange-dim); color: var(--c-orange); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border-2);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 680px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
}
.modal-header h3 {
  font-family: var(--font-head); font-size: 14px; font-weight: 700;
}
.modal-close {
  background: none; border: none; color: var(--c-text-2);
  font-size: 16px; cursor: pointer; padding: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--c-text); }
.modal-body { overflow-y: auto; padding: 18px; }
.code-block {
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--c-green);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
}

/* ── Dry run banner ─────────────────────────────── */
.dry-run-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(64,168,240,0.08);
  border: 1px solid var(--c-blue-dim);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--c-blue);
  margin-bottom: 14px;
}

/* ── Scrollbar global ───────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-3); }

/* ── Animated spinner ───────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Utility ────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--c-text-3); }
.text-success { color: var(--c-green); }
.text-error   { color: var(--c-red); }
.hidden { display: none !important; }
