/* Extra styles specific to dwg-counting */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
  border: 0.5px solid var(--border-default);
  background: var(--bg-primary);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.back-link:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--bg-primary));
}
.back-link svg { opacity: 0.8; }
@media (max-width: 640px) {
  .back-link span { display: none; }
  .back-link { padding: 6px; }
  .back-link svg { width: 16px; height: 16px; }
}

.processing-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

.symbols-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.symbol-card {
  background: var(--card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.symbol-card:hover {
  border-color: var(--primary);
}
.symbol-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}

.symbol-card input[type=checkbox] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.symbol-thumb {
  width: 64px;
  height: 64px;
  background: #fff;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  object-fit: contain;
  padding: 4px;
  flex-shrink: 0;
}

.symbol-info {
  flex: 1;
  min-width: 0;
}
.symbol-id {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  font-weight: 600;
}
.symbol-desc {
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 2px;
  line-height: 1.35;
}

.threshold-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.threshold-row label { font-weight: 600; }
.threshold-row input[type=range] {
  flex: 0 0 240px;
  accent-color: var(--primary);
}
#threshold-value {
  display: inline-block;
  min-width: 40px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--primary);
}
.threshold-hint { color: var(--text-tertiary); font-size: 12px; flex: 1; }

.confidence-high { color: #16a34a; font-weight: 600; }
.confidence-medium { color: #d97706; font-weight: 600; }
.confidence-low { color: #dc2626; font-weight: 600; }

/* Edit button on symbol cards */
.symbol-edit {
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}
.symbol-edit:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Crop modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.btn-close {
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-tertiary);
}
.modal-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.crop-canvas-wrap {
  position: relative;
  overflow: auto;
  max-height: 65vh;
  border: 1px solid var(--border-default);
  background: #fff;
  cursor: crosshair;
}
#crop-img {
  display: block;
  max-width: none;
  user-select: none;
  pointer-events: none;
}
#crop-selection {
  position: absolute;
  border: 2px dashed var(--primary);
  background: rgba(21, 90, 239, 0.08);
  pointer-events: none;
  display: none;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.crop-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.crop-name-row label {
  font-size: 13px;
  font-weight: 600;
}
.crop-name-row input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 14px;
}
.symbol-delete {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}
.symbol-delete:hover {
  color: #dc2626;
  border-color: #dc2626;
}
.symbol-debug {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}
.symbol-debug:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.debug-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  max-height: 70vh;
  overflow-y: auto;
}
.debug-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-default);
}
.debug-section:last-child { border-bottom: none; }
.debug-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.debug-kv { display: grid; grid-template-columns: 220px 1fr; gap: 4px 12px; }
.debug-kv strong { color: var(--text-secondary); font-weight: 500; }
.debug-thumbs { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.debug-thumb {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; min-width: 120px;
}
.debug-thumb a {
  display: block;
  border: 1px solid var(--border-default);
  padding: 4px;
  background: #fff;
  cursor: zoom-in;
}
.debug-thumb img { display: block; max-width: 160px; max-height: 160px; }
.debug-thumb span { font-size: 11px; color: var(--text-tertiary); }
.debug-thresholds { display: grid; grid-template-columns: 60px 1fr 60px; gap: 4px 10px; align-items: center; }
.debug-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}
.debug-bar-fill {
  height: 100%;
  background: var(--primary);
}
