/* ── Streamlit-like theme matching the original Blood Smear Classifier ──── */
:root {
  --bg: #ffffff;
  --text: #31333f;
  --muted: #808495;
  --border: #e6e9ef;
  --light-bg: #f8f9fb;
  --primary: #ff4b4b;
  --font: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.97);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s;
}
#loading-overlay.done { opacity: 0; pointer-events: none; }
.loader-box { text-align: center; color: var(--muted); }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 10px;
}
.spinner.small { width: 20px; height: 20px; display: inline-block; vertical-align: middle; margin: 0 8px 0 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page ─────────────────────────────────────────────────────────────────── */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}
header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.emoji { font-size: 30px; }
.header-sub {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}
.logo { width: 56px; height: auto; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Upload ───────────────────────────────────────────────────────────────── */
.upload-section { margin-bottom: 12px; }
.field-label {
  font-size: 14px;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}
.upload-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  transition: border-color 0.2s;
}
.upload-box:hover { border-color: var(--primary); }
.upload-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}
.upload-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-icon { font-size: 24px; opacity: 0.5; }
.upload-main-text { font-size: 14px; color: var(--text); }
.upload-sub-text { font-size: 12px; color: var(--muted); }

.browse-btn {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 18px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.2s;
  white-space: nowrap;
}
.browse-btn:hover { border-color: var(--primary); color: var(--primary); }
.browse-btn input { display: none; }

/* File info row */
.file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--light-bg);
}
.file-icon { font-size: 16px; opacity: 0.5; }
.file-name { color: var(--text); }
.file-size { color: var(--muted); font-size: 12px; }
.file-remove {
  margin-left: auto;
  background: none; border: none;
  color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 0 4px;
}
.file-remove:hover { color: var(--primary); }

.hidden { display: none !important; }

/* ── Accordion ────────────────────────────────────────────────────────────── */
.accordion {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}
.accordion summary {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  list-style: none;
}
.accordion summary::before {
  content: "›";
  display: inline-block;
  margin-right: 8px;
  font-weight: bold;
  transition: transform 0.2s;
}
.accordion[open] summary::before { transform: rotate(90deg); }
.accordion-body { padding: 0 16px 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Preprocessing grid */
.prep-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.prep-item { text-align: center; }
.prep-item canvas {
  width: 100%; aspect-ratio: 1;
  border-radius: 4px; border: 1px solid var(--border);
  display: block;
}
.prep-item-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Run spinner ──────────────────────────────────────────────────────────── */
.run-spinner { padding: 16px 0; color: var(--muted); font-size: 14px; }

/* ── Main grid: images left, prediction right ─────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 700px) { .main-grid { grid-template-columns: 1fr; } }

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* Image cards */
.image-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.img-card {
  background: var(--bg);
}
.img-card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.img-card canvas {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #0a0a0a;
}

/* Prediction panel */
.prediction-panel {
  border-left: 1px solid var(--border);
  padding-left: 24px;
}
.pred-class {
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 4px;
}
.pred-confidence {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.export-btn {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 18px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.2s;
}
.export-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Center dot */
.center-dot {
  text-align: center;
  color: var(--primary);
  font-size: 16px;
  margin: 12px 0;
}

/* ── Class confidences ────────────────────────────────────────────────────── */
.confidences-section { margin-top: 4px; }
.conf-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.conf-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.conf-item {}
.conf-label {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 2px;
}
.conf-value {
  font-size: 32px;
  font-weight: 300;
  color: var(--text);
}
