/* ============================================================
   ABSTRICT · Features v5 CSS
   Action bar, Price tracker, Build history, Encoder badge,
   Custom component modal, Import, AI refiner variants
   ============================================================ */

/* === Buttons row (catalog header) === */
.v5-actions {
  display: flex; gap: 6px; align-items: center;
  margin-left: auto;
}
/* Defensive: ensure v5-actions sits inline even in non-flex parents */
.picker-top { flex-wrap: wrap; align-items: center; }
.v5-btn {
  white-space: nowrap;
}
.v5-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px; font-weight: 500;
  color: var(--text); cursor: pointer;
  transition: all 150ms var(--ease);
}
.v5-btn:hover { background: var(--bg-alt); border-color: var(--accent); color: var(--accent); }
.v5-btn svg { width: 13px; height: 13px; }
.v5-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.v5-btn.primary:hover { background: var(--accent-hover); color: #fff; }

/* === #2 Price Tracker === */
.price-tracker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px; margin-top: 12px;
}
.price-track-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 12px;
  transition: border-color 150ms var(--ease);
}
.price-track-card:hover { border-color: var(--accent); }
.price-track-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.price-track-name { font-size: 12px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price-track-current { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--accent); }
.price-track-spark { height: 32px; margin: 6px 0; }
.price-track-spark svg { display: block; width: 100%; height: 100%; }
.price-track-meta { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--text-muted); }
.price-track-target {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono);
}
.price-track-target input {
  width: 60px; padding: 2px 6px;
  background: var(--bg-alt); border: 1px solid var(--border-subtle);
  border-radius: 3px; font-family: var(--mono); font-size: 10px;
  color: var(--text);
}
.price-track-target input:focus { border-color: var(--accent); outline: none; }
.price-track-target.hit { color: var(--success); font-weight: 600; }
.price-track-btn {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 6px; background: transparent;
  border: 1px solid var(--border-subtle); border-radius: 3px;
  color: var(--text-muted); cursor: pointer;
  transition: all 150ms var(--ease);
}
.price-track-btn:hover { color: var(--accent); border-color: var(--accent); }
.price-track-empty {
  grid-column: 1 / -1;
  padding: 20px; text-align: center;
  color: var(--text-muted); font-size: 12px;
}

/* === #5 Build History === */
.build-history {
  margin-top: 12px; padding: 10px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  display: flex; gap: 12px; align-items: center;
}
.build-history-spark { flex: 1; height: 36px; min-width: 0; }
.build-history-spark svg { width: 100%; height: 100%; }
.build-history-info { flex-shrink: 0; }
.build-history-title { font-size: 11px; font-weight: 600; }
.build-history-meta { font-family: var(--mono); font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* === #6 Streaming Encoder Badge (on GPU cards) === */
.card-encoder-badge {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px;
  background: rgba(13,148,136,.15); color: #0d9488;
  border: 1px solid rgba(13,148,136,.3); border-radius: 99px;
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase;
  z-index: 2;
}
body.dark .card-encoder-badge { background: rgba(13,148,136,.2); }
.card-encoder-badge svg { width: 9px; height: 9px; }

/* === #4 Custom Component Creator Modal === */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; max-width: 480px; width: 90vw; max-height: 80vh; overflow: auto; box-shadow: var(--shadow-lg); animation: modalIn 220ms var(--ease-spring); }
@keyframes modalIn { from { transform: translateY(20px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.modal-card .modal-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 16px; }
.modal-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.modal-form-row.full { grid-template-columns: 1fr; }
.modal-form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.modal-form-row input, .modal-form-row select {
  padding: 8px 10px;
  background: var(--bg-alt); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); font-family: var(--font);
  font-size: 13px; color: var(--text);
}
.modal-form-row input:focus, .modal-form-row select:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.modal-list { margin-top: 12px; }
.modal-list-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border-subtle); font-size: 11px; }
.modal-list-item:last-child { border: none; }
.modal-list-item button { font-family: var(--mono); font-size: 9px; padding: 2px 6px; background: transparent; border: 1px solid var(--border-subtle); border-radius: 3px; color: var(--danger); cursor: pointer; }

/* === #7 Import URL === */
.import-result {
  margin-top: 12px; padding: 10px 12px;
  background: var(--bg-alt); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); font-size: 11px;
  font-family: var(--mono);
}
.import-result.ok { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.25); color: var(--success); }
.import-result.err { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.25); color: var(--danger); }
.import-result ul { margin: 6px 0 0; padding-left: 18px; }

/* === #8 AI Refiner === */
.ai-refiner {
  margin-top: 16px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.ai-refiner-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.ai-refiner-title { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.ai-refiner-budget { font-family: var(--mono); font-size: 16px; font-weight: 600; color: var(--accent); }
.ai-refiner-slider { width: 100%; appearance: none; height: 4px; background: var(--bg-alt); border-radius: 2px; outline: none; -webkit-appearance: none; }
.ai-refiner-slider::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; background: var(--accent); border-radius: 50%; cursor: pointer; box-shadow: var(--shadow-sm); border: 2px solid var(--surface); }
.ai-refiner-slider::-moz-range-thumb { width: 18px; height: 18px; background: var(--accent); border-radius: 50%; cursor: pointer; border: 2px solid var(--surface); }
.ai-refiner-variants { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 12px; }
.ai-variant {
  padding: 10px 12px;
  background: var(--bg-alt); border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: all 200ms var(--ease);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.ai-variant:hover { border-color: var(--accent); background: var(--surface); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ai-variant-name { font-size: 11px; font-weight: 600; }
.ai-variant-meta { font-family: var(--mono); font-size: 10px; color: var(--text-muted); display: flex; justify-content: space-between; }
.ai-variant-score { color: var(--accent); font-weight: 600; }

/* === Mobile overrides === */
@media (max-width: 768px) {
  .modal-form-row { grid-template-columns: 1fr; }
  .multi-cart { width: calc(100vw - 32px); right: 16px; bottom: 72px; }
  .ai-refiner .ai-variant { flex-direction: column; align-items: flex-start; gap: 6px; }
}
