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

/* Ensure hidden attribute always works regardless of display overrides */
[hidden] { display: none !important; }

:root {
  --brand:    #1a73e8;
  --brand-dk: #1558b0;
  --bg:       #f8f9fa;
  --surface:  #ffffff;
  --border:   #dadce0;
  --text:     #202124;
  --muted:    #5f6368;
  --green:    #188038;
  --red:      #d93025;
  --radius:   12px;
  --shadow:   0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

body {
  font-family: "Google Sans", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); }

/* ─── Header ────────────────────────────────────────────────────────────── */
header {
  background: var(--brand);
  color: #fff;
  padding: 24px 20px 20px;
  text-align: center;
}
header h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -.5px; }
header .subtitle { font-size: .95rem; opacity: .9; margin-top: 6px; }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.container {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Card ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.hint { font-size: .875rem; color: var(--muted); margin-bottom: 16px; }

/* ─── Drop zone ─────────────────────────────────────────────────────────── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--muted);
}
#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--brand);
  background: #e8f0fe;
  color: var(--brand);
}
#drop-zone svg { display: block; margin: 0 auto 12px; }
#drop-zone p { font-size: .9rem; }
#drop-zone strong { color: var(--brand); }

/* ─── Preview ───────────────────────────────────────────────────────────── */
#preview-wrap {
  position: relative;
  display: inline-block;
  margin-top: 12px;
}
#preview-canvas {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
#clear-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

/* ─── Folder input ──────────────────────────────────────────────────────── */
#folder-url {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 18px;
  outline: none;
  transition: border-color .2s;
}
#folder-url:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }

/* ─── Slider ────────────────────────────────────────────────────────────── */
.slider-label {
  display: block;
  font-size: .875rem;
  margin-bottom: 8px;
  color: var(--muted);
}
.slider-label #threshold-display {
  font-weight: 700;
  color: var(--text);
}
.slider-hint { font-size: .78rem; }
#threshold-slider {
  width: 100%;
  accent-color: var(--brand);
  margin-bottom: 20px;
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  transition: background .15s, opacity .15s;
}
#search-btn {
  background: var(--brand);
  color: #fff;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  padding: 12px;
}
#search-btn:hover:not(:disabled) { background: var(--brand-dk); }
#search-btn:disabled { opacity: .45; cursor: default; }
.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  font-size: .8rem;
  margin-left: 12px;
}
.secondary:hover { background: var(--bg); }

/* ─── Progress ──────────────────────────────────────────────────────────── */
#progress-section { text-align: center; }
#progress-section h2 { justify-content: center; margin-bottom: 16px; }
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
progress {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  border: none;
  background: var(--border);
}
progress::-webkit-progress-bar { background: var(--border); border-radius: 5px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 5px; transition: width .3s; }
progress::-moz-progress-bar { background: var(--brand); border-radius: 5px; }
#progress-pct { font-size: .85rem; font-weight: 600; color: var(--brand); min-width: 36px; }
#progress-text { font-size: .875rem; color: var(--muted); }

/* ── Currently-scanning image ───────────────────────────────────────────── */
#current-image-wrap { margin-top: 14px; }
.current-label { font-size: .75rem; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.current-image-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
#current-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--border);
}
#current-filename {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Results ───────────────────────────────────────────────────────────── */
#results-section h2 {
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  margin-bottom: 16px;
  padding: 0 4px;
}
#results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.result-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.result-card a { text-decoration: none; color: inherit; display: block; }
.result-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.result-card .card-body { padding: 8px 10px 10px; }
.confidence-badge {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 4px;
}
.file-name {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#no-results-msg { color: var(--muted); font-size: .9rem; padding: 4px; }
.download-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s;
}
.download-btn:hover { background: #e8f0fe; }

/* ─── Resume banner ─────────────────────────────────────────────────────── */
.resume-banner {
  background: #e8f0fe;
  border: 1px solid #c5d8f6;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.resume-banner-text { font-size: .9rem; display: flex; flex-direction: column; gap: 2px; }
.resume-banner-text strong { color: var(--brand); }
.resume-banner-text span { font-size: .8rem; color: var(--muted); }
.resume-banner-actions { display: flex; gap: 8px; }
.resume-banner-actions button {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: .85rem;
}
.resume-banner-actions button:hover { background: var(--brand-dk); }
.resume-banner-actions .secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ─── Progress header with pause button ─────────────────────────────────── */
.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.progress-header h2 { margin-bottom: 0; }

/* ─── Paused banner ─────────────────────────────────────────────────────── */
.paused-banner {
  background: #fef7e0;
  border: 1px solid #f9d66b;
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .9rem;
  color: #7a5c00;
}
.paused-banner button {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: .85rem;
  white-space: nowrap;
}

/* ─── Error ─────────────────────────────────────────────────────────────── */
.error { font-size: .82rem; color: var(--red); margin-top: 8px; }
.error-banner {
  background: #fce8e6;
  border: 1px solid #f5c6c3;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .875rem;
  color: #c5221f;
}
.error-banner button {
  background: none;
  border: none;
  color: #c5221f;
  font-size: 1rem;
  padding: 0;
  margin-left: auto;
  cursor: pointer;
}

/* ─── Footer ────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  padding: 20px;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  header h1 { font-size: 1.4rem; }
  .card { padding: 16px; }
  #results-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
