/* ═══════════════════════════════════════════════════════════════════════════
   Universal Scraper — style.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg:          #080b0e;
  --surface:     #0e1318;
  --surface-2:   #141a20;
  --border:      #1c2530;
  --border-2:    #243040;
  --accent:      #00dda0;
  --accent-dim:  rgba(0, 221, 160, 0.12);
  --accent-glow: rgba(0, 221, 160, 0.25);
  --blue:        #3b9eff;
  --blue-dim:    rgba(59, 158, 255, 0.1);
  --warn:        #ff6b35;
  --warn-dim:    rgba(255, 107, 53, 0.1);
  --text:        #b8c8d8;
  --text-2:      #7a90a4;   /* was #6a7f90 — lifted for readability */
  --text-3:      #4a5f70;   /* was #394855 — lifted for readability */
  --mono:        'IBM Plex Mono', monospace;
  --sans:        'IBM Plex Sans', sans-serif;
  --r:           6px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Background grid ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(28, 37, 48, 0.7) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 37, 48, 0.7) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  top: -15%; left: 50%; transform: translateX(-50%);
  width: 760px; height: 500px;
  background: radial-gradient(ellipse at center, rgba(0, 221, 160, 0.04) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ── Scan overlay ── */
.scan-overlay {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  overflow: hidden;
  opacity: 0; transition: opacity 0.3s;
}
.scan-overlay.on { opacity: 1; }
.scan-beam {
  position: absolute; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  opacity: 0.5;
  animation: sweep 2.6s linear infinite;
}
@keyframes sweep {
  0%   { transform: translateY(-4px); }
  100% { transform: translateY(100vh); }
}

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(4, 6, 9, 0.92);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.lightbox.open { opacity: 1; pointer-events: all; }

.lb-close {
  position: absolute; top: 20px; right: 24px;
  background: var(--surface); border: 1px solid var(--border-2);
  color: var(--text-2); font-size: 22px; line-height: 1;
  width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; display: grid; place-items: center;
  transition: all 0.15s;
}
.lb-close:hover { background: var(--warn); border-color: var(--warn); color: #fff; }

.lb-inner {
  display: flex; flex-direction: column;
  max-width: min(92vw, 1100px);
  max-height: 92vh;
  gap: 0;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.lb-img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 52px);
  object-fit: contain;
  background: var(--bg);
}

.lb-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.lb-url {
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.lb-dl-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--accent); color: #000;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 7px 14px; border: none; border-radius: 5px;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: opacity 0.15s;
}
.lb-dl-btn:hover { opacity: 0.85; }

/* ── App shell ── */
.app {
  position: relative; z-index: 2;
  max-width: 1000px; margin: 0 auto;
  padding: 36px 24px 64px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ── Header ── */
.app-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.wordmark { display: flex; align-items: center; gap: 10px; }
.wordmark-icon { color: var(--accent); flex-shrink: 0; }
.wordmark-name {
  font-family: var(--mono); font-size: 15px; font-weight: 600;
  color: var(--accent); letter-spacing: -0.3px;
}
.wordmark-sep { color: var(--text-3); font-family: var(--mono); font-size: 13px; }
.wordmark-sub { font-family: var(--mono); font-size: 11px; color: var(--text-2); }

/* ── Control panel ── */
.control-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.url-row { display: flex; align-items: center; gap: 10px; }
.url-field {
  flex: 1; display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--r); overflow: hidden; transition: border-color 0.2s;
}
.url-field:focus-within { border-color: var(--accent); }
.url-prompt {
  font-family: var(--mono); font-size: 13px; color: var(--accent);
  padding: 0 10px 0 12px; user-select: none; flex-shrink: 0;
}
.url-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--mono); font-size: 12px;
  padding: 10px 12px 10px 0; min-width: 0;
}
.url-input::placeholder { color: var(--text-3); }
.btn-analyze {
  background: var(--accent); color: #000;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 10px 18px; border: none; border-radius: var(--r);
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; transition: opacity 0.15s, transform 0.1s;
}
.btn-analyze:hover  { opacity: 0.85; }
.btn-analyze:active { transform: scale(0.97); }
.btn-analyze:disabled { opacity: 0.3; cursor: not-allowed; }

.panel-footer {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.options { display: flex; gap: 18px; flex-wrap: wrap; }
.opt { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.opt span { font-family: var(--mono); font-size: 11px; color: var(--text-2); transition: color 0.15s; }
.opt:hover span { color: var(--text); }
.opt input[type="checkbox"] {
  appearance: none; width: 13px; height: 13px;
  border: 1px solid var(--border-2); border-radius: 3px;
  background: var(--bg); cursor: pointer; position: relative;
  flex-shrink: 0; transition: all 0.15s;
}
.opt input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.opt input[type="checkbox"]:checked::after {
  content: ''; position: absolute;
  left: 2px; top: 5px; width: 7px; height: 4px;
  border-left: 1.5px solid #000; border-bottom: 1.5px solid #000;
  transform: rotate(-45deg) translateY(-2px);
}
.proxy-control { display: flex; align-items: center; gap: 8px; }
.proxy-label { font-family: var(--mono); font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; }
.proxy-select {
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: 5px; color: var(--text-2);
  font-family: var(--mono); font-size: 11px;
  padding: 5px 8px; outline: none; cursor: pointer; transition: border-color 0.2s;
}
.proxy-select:focus { border-color: var(--accent); color: var(--text); }

/* ── Status bar ── */
.status-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 14px;
  font-family: var(--mono); font-size: 11px;
  min-height: 38px; transition: border-color 0.3s;
}
.status-bar.running { border-color: var(--accent); }
.status-bar.error   { border-color: var(--warn); }
.status-bar.done    { border-color: var(--accent); }
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3); flex-shrink: 0; transition: background 0.3s;
}
.status-bar.running .status-dot { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.status-bar.error   .status-dot { background: var(--warn); }
.status-bar.done    .status-dot { background: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
.status-msg { flex: 1; color: var(--text-2); transition: color 0.2s; }
.status-bar.running .status-msg { color: var(--text); }
.status-bar.error   .status-msg { color: var(--warn); }
.status-bar.done    .status-msg { color: var(--accent); }
.progress-steps { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.pstep { font-family: var(--mono); font-size: 10px; color: var(--text-3); transition: color 0.2s; }
.pstep.active { color: var(--accent); }
.pstep.done   { color: var(--text-2); }
.pstep-sep    { color: var(--text-3); font-size: 10px; }

/* ── Results area ── */
#results { display: flex; flex-direction: column; gap: 10px; }

/* Meta strip */
.meta-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.meta-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; }
.meta-val { font-family: var(--mono); font-size: 24px; font-weight: 600; color: var(--accent); line-height: 1; margin-bottom: 5px; }
.meta-val.blue { color: var(--blue); }
.meta-val.warn { color: var(--warn); }
.meta-key { font-family: var(--mono); font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; }

/* Container info */
.container-box {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 2px solid var(--accent); border-radius: var(--r);
  padding: 12px 16px; display: grid;
  grid-template-columns: auto 1fr; gap: 4px 16px; align-items: start;
}
.cb-label { font-family: var(--mono); font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; padding-top: 2px; }
.cb-sel   { font-family: var(--mono); font-size: 12px; color: var(--accent); word-break: break-all; }
.cb-notes { display: flex; flex-wrap: wrap; gap: 5px; }
.note-chip {
  font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 3px;
  background: var(--accent-dim); border: 1px solid rgba(0, 221, 160, 0.2); color: var(--accent);
}
.note-chip.blue { background: var(--blue-dim); border-color: rgba(59, 158, 255, 0.2); color: var(--blue); }

/* ── Download toolbar ── */
.dl-toolbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 14px;
  flex-wrap: wrap;
}
.dl-info {
  font-family: var(--mono); font-size: 11px; color: var(--text-2); flex: 1;
}
.dl-info strong { color: var(--accent); }
.btn-dl {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 8px 16px; border: none; border-radius: 5px;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s; white-space: nowrap;
}
.btn-dl:active { transform: scale(0.97); }
.btn-dl.primary { background: var(--accent); color: #000; }
.btn-dl.primary:hover { opacity: 0.85; }
.btn-dl.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); }
.btn-dl.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-dl:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.btn-select-all {
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
  background: none; border: 1px solid var(--border-2); border-radius: 5px;
  padding: 7px 12px; cursor: pointer; transition: all 0.15s;
}
.btn-select-all:hover { color: var(--accent); border-color: var(--accent); }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border); gap: 0; }
.tab-btn {
  font-family: var(--mono); font-size: 11px; padding: 8px 16px;
  cursor: pointer; color: var(--text-2);
  background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; user-select: none;
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 16px; padding: 0 5px; border-radius: 8px;
  background: var(--surface-2); font-size: 9px; color: var(--text-3); transition: all 0.15s;
}
.tab-btn.active .tab-count { background: var(--accent-dim); color: var(--accent); }

/* ── Image grid ── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* ── Image card ── */
.img-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  transition: border-color 0.2s, transform 0.18s, box-shadow 0.2s;
  cursor: pointer;
  position: relative;
}
.img-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
/* selected state */
.img-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow), 0 4px 20px rgba(0,221,160,0.1);
}
.img-card.excl { opacity: 0.5; cursor: default; }
.img-card.excl:hover { transform: none; border-color: var(--warn); box-shadow: none; }

/* checkbox overlay */
.img-checkbox {
  position: absolute; top: 9px; left: 9px; z-index: 3;
  width: 20px; height: 20px;
  background: rgba(8, 11, 14, 0.75);
  border: 1.5px solid var(--border-2);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  cursor: pointer;
}
.img-card.selected .img-checkbox {
  background: var(--accent);
  border-color: var(--accent);
}
.img-checkbox svg { display: none; }
.img-card.selected .img-checkbox svg { display: block; }

/* action buttons overlay (fullscreen + download) */
.img-actions {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  display: flex; gap: 5px;
  opacity: 0; transition: opacity 0.15s;
}
.img-card:hover .img-actions { opacity: 1; }
.img-action-btn {
  width: 30px; height: 30px;
  background: rgba(8, 11, 14, 0.80);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--text-2);
  transition: all 0.15s;
}
.img-action-btn:hover { background: var(--accent); border-color: var(--accent); color: #000; }

/* thumbnail */
.img-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;   /* bigger and squarer than 16/10 */
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.img-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  opacity: 0; transition: opacity 0.4s;
  position: relative; z-index: 1;
}
.img-thumb img.loaded { opacity: 1; }
.img-thumb .img-ph {
  position: absolute; inset: 0; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);       /* lifted for visibility */
  font-size: 10px; font-family: var(--mono); letter-spacing: 1px;
}

/* card body */
.img-body { padding: 10px 12px; }
.img-url {
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  word-break: break-all; line-height: 1.5; margin-bottom: 7px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.img-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.img-size { font-family: var(--mono); font-size: 10px; color: var(--accent); }
.img-source-tag {
  font-family: var(--mono); font-size: 9px; color: var(--blue);
  background: var(--blue-dim); border: 1px solid rgba(59, 158, 255, 0.2);
  border-radius: 3px; padding: 1px 6px; white-space: nowrap;
}
.img-reason {
  margin-top: 5px; font-family: var(--mono); font-size: 10px;
  color: var(--text-2); line-height: 1.4; font-style: italic;
}
.img-reason.excl-reason { color: var(--warn); font-style: normal; }

/* ── Log view ── */
.log-view {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px; font-family: var(--mono); font-size: 11px; line-height: 1.85;
  max-height: 440px; overflow-y: auto;
}
.log-entry { display: flex; gap: 8px; }
.log-ts  { color: var(--text-3); flex-shrink: 0; width: 48px; text-align: right; }
.log-cat { flex-shrink: 0; width: 86px; }
.log-msg { color: var(--text); flex: 1; overflow-wrap: anywhere; }
.log-cat.cat-scraper    { color: var(--blue); }
.log-cat.cat-heuristics { color: #b48bff; }
.log-cat.cat-filter     { color: var(--accent); }
.log-cat.cat-extractor  { color: #f5b942; }
.log-cat.cat-network    { color: var(--text-3); }

/* ── JSON view ── */
.json-view {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px; font-family: var(--mono); font-size: 11px; line-height: 1.7;
  overflow: auto; max-height: 520px; white-space: pre; tab-size: 2; color: var(--text);
}
.jk { color: var(--blue); }
.js { color: #7ddc9e; }
.jn { color: #f5b942; }
.jb { color: var(--warn); }
.jl { color: var(--text-3); }

/* copy button */
.copy-btn {
  font-family: var(--mono); font-size: 11px; background: var(--surface-2);
  color: var(--text-2); border: 1px solid var(--border-2); border-radius: 5px;
  padding: 5px 12px; cursor: pointer; transition: all 0.15s;
  float: right; margin-bottom: 8px;
}
.copy-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }

/* ── Warn / info boxes ── */
.warn-box {
  background: var(--warn-dim); border: 1px solid rgba(255, 107, 53, 0.3);
  border-left: 2px solid var(--warn); border-radius: var(--r);
  padding: 12px 16px; font-family: var(--mono); font-size: 11px;
  color: var(--warn); line-height: 1.7;
}
.info-box {
  background: var(--blue-dim); border: 1px solid rgba(59, 158, 255, 0.25);
  border-left: 2px solid var(--blue); border-radius: var(--r);
  padding: 12px 16px; font-family: var(--mono); font-size: 11px;
  color: var(--text-2); line-height: 1.8;
}
.info-box a { color: var(--blue); }
.info-box strong { color: var(--text); }

/* ── Empty state — FIXED contrast ── */
.empty-state {
  padding: 56px 24px; text-align: center;
  font-family: var(--mono); font-size: 12px;
  color: var(--text-2);   /* was --text-3, now much more legible */
}
.empty-state::before {
  content: attr(data-icon); display: block;
  font-size: 32px; margin-bottom: 14px; opacity: 0.6;  /* was 0.4 */
}

/* ── Disclaimer banner ── */
.disclaimer {
  background: var(--surface); border: 1px solid var(--border-2);
  border-left: 2px solid var(--warn); border-radius: var(--r);
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 12px;
  transition: opacity 0.25s, transform 0.25s;
}
.disclaimer-body {
  display: flex; align-items: flex-start; gap: 10px; flex: 1;
}
.disclaimer-icon {
  color: var(--warn); font-size: 13px; flex-shrink: 0; margin-top: 1px;
}
.disclaimer-text {
  font-family: var(--mono); font-size: 10px; color: var(--text-2);
  line-height: 1.7;
}
.disclaimer-text strong { color: var(--text); }
.disclaimer-close {
  background: none; border: 1px solid var(--border-2); border-radius: 4px;
  color: var(--text-3); font-size: 16px; line-height: 1;
  width: 22px; height: 22px; flex-shrink: 0;
  display: grid; place-items: center;
  cursor: pointer; transition: all 0.15s; margin-top: 1px;
}
.disclaimer-close:hover { border-color: var(--warn); color: var(--warn); }

/* ── Footer ── */
.app-footer {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
}
.footer-sep { opacity: 0.5; }
.app-footer a { color: var(--text-2); text-decoration: none; transition: color 0.15s; }
.app-footer a:hover { color: var(--blue); }

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

/* ── Responsive ── */
@media (max-width: 640px) {
  .app { padding: 20px 14px 48px; }
  .url-row { flex-direction: column; }
  .btn-analyze { width: 100%; justify-content: center; }
  .meta-strip { grid-template-columns: 1fr 1fr; }
  .progress-steps { display: none; }
  .wordmark-sub { display: none; }
  .panel-footer { flex-direction: column; align-items: flex-start; }
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ── Entry animation ── */
.app-header, .control-panel, .status-bar {
  animation: fadein 0.4s ease both;
}
.control-panel { animation-delay: 0.05s; }
.status-bar    { animation-delay: 0.1s; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
