:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --border: #2a2a3d;
  --accent: #7c6cfc;
  --accent2: #fc6c8f;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --text: #e8e8f0;
  --muted: #6b6b8a;
  --font: "Syne", sans-serif;
  --mono: "DM Mono", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding: 20px 16px 60px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(
    circle,
    rgba(124, 108, 252, 0.12) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  bottom: -200px;
  right: -200px;
  width: 500px;
  height: 500px;
  background: radial-gradient(
    circle,
    rgba(252, 108, 143, 0.08) 0%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.wrap {
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ── Header ── */
header {
  text-align: center;
  padding: 32px 0 28px;
}

.logo-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  box-shadow: 0 0 40px rgba(124, 108, 252, 0.4);
}

h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 400;
  font-family: var(--mono);
}

/* ── Layout Grid ── */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

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

.column-left,
.column-right {
  max-height: 70vh;
  overflow-y: auto;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 0;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(124, 108, 252, 0.4);
}

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

.card-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.icon-purple {
  background: rgba(124, 108, 252, 0.15);
}

.icon-green {
  background: rgba(74, 222, 128, 0.12);
}

.icon-yellow {
  background: rgba(251, 191, 36, 0.12);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
}

.card-badge {
  margin-left: auto;
  font-size: 10px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid;
}

.badge-required {
  color: var(--accent2);
  border-color: rgba(252, 108, 143, 0.3);
  background: rgba(252, 108, 143, 0.08);
}

.badge-optional {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

/* ── Drop zones ── */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  background: var(--surface2);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 108, 252, 0.06);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.drop-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.drop-hint {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 3px;
  display: block;
}

.file-chosen {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--green);
  word-break: break-all;
}

.file-chosen.visible {
  display: flex;
}

/* ── Run button ── */
#run-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 0;
  box-shadow: 0 4px 24px rgba(124, 108, 252, 0.35);
}

#run-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124, 108, 252, 0.5);
}

#run-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ── Log ── */
#log-card {
  display: none;
}

#log-card.visible {
  display: block;
}

#log {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.8;
  background: #08080e;
  border-radius: 10px;
  padding: 14px;
  max-height: 260px;
  overflow-y: auto;
  color: #b0b0cc;
  border: 1px solid var(--border);
}

.log-ok {
  color: var(--green);
}

.log-warn {
  color: var(--yellow);
}

.log-err {
  color: var(--red);
}

.log-info {
  color: var(--accent);
}

.log-plain {
  color: #b0b0cc;
}

/* ── Download ── */
#dl-card {
  display: none;
}

#dl-card.visible {
  display: block;
}

#dl-btn {
  width: 100%;
  padding: 16px;
  border: 1.5px solid var(--green);
  border-radius: 14px;
  background: rgba(74, 222, 128, 0.08);
  color: var(--green);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

#dl-btn:hover {
  background: rgba(74, 222, 128, 0.15);
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.2);
}

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
  flex-shrink: 0;
}

.spinning .spinner {
  display: block;
}

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

/* ── Loading overlay ── */
#pyodide-status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 40px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 100;
  min-width: 200px;
  margin: 0;
}

#pyodide-status.hidden {
  display: none;
}

.progress-bar {
  position: fixed;
  top: calc(50% + 80px);
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  z-index: 100;
}

.pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

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

  50% {
    opacity: 0.4;
  }
}

/* ── Progress bar ── */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.4s ease;
}

/* ── Summary stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.stat-label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
}

.stat-value.green {
  color: var(--green);
}

/* ── Preview Panels ── */
.preview-panel {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 20px 10px;
  font-family: var(--mono);
  font-size: 11px;
}

.summary-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-item-label {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.summary-item-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 8px;
}

.summary-table th {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  font-weight: 700;
  color: var(--accent);
  font-size: 10px;
}

.summary-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  color: var(--text);
}

.summary-table tbody tr:nth-child(even) {
  background: rgba(124, 108, 252, 0.03);
}

.summary-table tbody tr:hover {
  background: rgba(124, 108, 252, 0.08);
}

/* ── Full-screen Drop Zone ── */
.drop-zone-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.drop-zone-overlay.active {
  display: flex;
}

.drop-zone-content {
  text-align: center;
  pointer-events: none;
}

.drop-zone-icon {
  font-size: 72px;
  margin-bottom: 20px;
  animation: bounce 1s ease-in-out infinite;
}

.drop-zone-text {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
}

.drop-zone-hint {
  font-size: 14px;
  color: var(--muted);
  font-family: var(--mono);
}

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

/* ── Files List ── */
.file-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.file-item-name {
  font-family: var(--mono);
  color: var(--text);
  flex: 1;
  word-break: break-all;
}

.file-item-type {
  font-size: 10px;
  font-family: var(--mono);
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.file-type-pesanan {
  background: rgba(124, 108, 252, 0.2);
  color: var(--accent);
  border: 1px solid rgba(124, 108, 252, 0.3);
}

.file-type-database {
  background: rgba(251, 191, 36, 0.2);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.file-type-analiser {
  background: rgba(74, 222, 128, 0.2);
  color: var(--green);
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.file-item-remove {
  margin-left: 8px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.file-item-remove:hover {
  background: rgba(248, 113, 113, 0.2);
}

/* ── Icon accent ── */
.icon-accent {
  background: rgba(168, 85, 247, 0.15);
}

/* ── Responsive ── */
@media (max-width: 1400px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .column-left,
  .column-right {
    max-height: none;
  }
}
