/*
 * ════════════════════════════════════════════════════════════════
 *  PBCCD INGESTION — Component Styles
 *  Climate Change Duties Platform · Argyll & Bute Council
 *
 *  PBCCD-specific components only. All shared tokens, shell,
 *  layout, and shared components are in civic-swiss.css, loaded first.
 *
 *  v1.0 — April 2026
 * ════════════════════════════════════════════════════════════════
 */


/* ── UPLOAD ZONE ─────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--divider);
  border-radius: var(--tile-radius);
  padding: var(--sp8);
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--surface);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 6%, var(--surface));
}

.upload-zone.has-file {
  border-color: var(--green);
  border-style: solid;
  cursor: default;
}

.upload-icon {
  margin-bottom: var(--sp3);
  color: var(--text-f);
}

.upload-zone.has-file .upload-icon { color: var(--green); }

.upload-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp1);
}

.upload-hint {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-f);
}

.upload-filename {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--green);
  margin-top: var(--sp2);
}


/* ── STEP INDICATOR ──────────────────────────────────────── */

.steps {
  display: flex;
  gap: var(--sp4);
  margin-bottom: var(--sp5);
}

.step {
  display: flex;
  align-items: center;
  gap: var(--sp2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-f);
  opacity: .5;
  transition: opacity .2s, color .2s;
}

.step.active {
  opacity: 1;
  color: var(--teal);
}

.step.done {
  opacity: 1;
  color: var(--green);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-size: 11px;
  font-weight: 700;
}

.step.done .step-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}


/* ── EXTRACT PREVIEW ─────────────────────────────────────── */

.extract-section {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--tile-radius);
  overflow: hidden;
  margin-bottom: var(--sp4);
}

.extract-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp3) var(--sp4);
  background: var(--surface2);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.extract-header:hover { background: var(--surface3); }

.extract-part {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.extract-title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.extract-count {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-f);
}

.extract-body {
  padding: var(--sp4);
  display: none;
}

.extract-section.open .extract-body { display: block; }

.extract-chevron {
  transition: transform .2s;
  color: var(--text-f);
}

.extract-section.open .extract-chevron { transform: rotate(180deg); }


/* ── QUESTION CARDS ──────────────────────────────────────── */

.q-card {
  position: relative;
  border: 1px solid var(--divider);
  border-radius: var(--tile-radius);
  padding: var(--sp3) var(--sp4) var(--sp3) calc(var(--sp4) + 8px);
  margin-bottom: var(--sp3);
  background: var(--surface);
}
.q-card::before {
  content: '';
  position: absolute;
  left: 0; top: var(--sp3); bottom: var(--sp3);
  width: 3px; border-radius: var(--tile-radius);
  background: var(--teal);
}

.q-id {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--teal);
  text-transform: uppercase;
  margin-bottom: var(--sp1);
}

.q-question {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-m);
  margin-bottom: var(--sp2);
}

.q-response {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  padding: var(--sp2) var(--sp3);
  background: var(--surface2);
  border-radius: var(--r-sm);
}

.q-mappings {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp1);
  margin-top: var(--sp2);
}

.q-mappings-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-f);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: var(--sp2);
  margin-bottom: 2px;
}

.q-mappings-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-f);
}

.q-map-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal);
  border: 1px solid color-mix(in srgb, var(--teal) 25%, var(--divider));
  cursor: pointer;
  transition: opacity .15s, background .15s, text-decoration .15s;
}

.q-map-tag:hover {
  background: color-mix(in srgb, var(--teal) 20%, var(--surface));
}

/* User manually excluded a mapping — red strikethrough */
.q-map-tag.excluded {
  text-decoration: line-through;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  background: color-mix(in srgb, var(--red) 8%, var(--surface2));
  color: var(--text-f);
  border-color: color-mix(in srgb, var(--red) 30%, var(--divider));
}

.q-map-tag.excluded svg {
  opacity: .4;
}

.q-map-tag.excluded:hover {
  background: color-mix(in srgb, var(--red) 14%, var(--surface2));
  color: var(--text-m);
}

/* Auto-excluded: already ingested from a previous run — muted neutral, no strikethrough */
.q-map-tag.auto-excluded {
  text-decoration: none;
  background: var(--surface3);
  color: var(--text-f);
  border-color: var(--divider);
  opacity: 0.75;
  cursor: default;
}

.q-map-tag.auto-excluded svg {
  opacity: .35;
}

.q-map-tag.auto-excluded:hover {
  background: var(--surface3);
  color: var(--text-f);
  opacity: 0.9;
}


/* ── SUMMARY PANEL ───────────────────────────────────────── */

.ingest-summary {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--tile-radius);
  padding: var(--sp4) var(--sp5);
  margin-bottom: var(--sp4);
}

.ingest-summary-title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp3);
}

.ingest-stat-row {
  display: flex;
  gap: var(--sp5);
  margin-bottom: var(--sp3);
}

.ingest-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ingest-stat-val {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--teal);
}

.ingest-stat-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-f);
}


/* ── INSTRUCTIONS ────────────────────────────────────────── */

.ingest-instructions {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-m);
  line-height: 1.55;
  padding: var(--sp3) var(--sp4);
  background: color-mix(in srgb, var(--teal) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--teal) 20%, var(--divider));
  border-radius: var(--r-md);
  margin-top: var(--sp3);
}

.ingest-instructions strong {
  color: var(--text);
}


/* ── ACTION BUTTONS ──────────────────────────────────────── */

.ingest-actions {
  display: flex;
  gap: var(--sp3);
  align-items: center;
  margin-top: var(--sp4);
}

.btn-ingest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}

.btn-ingest:disabled { opacity: .5; cursor: not-allowed; }

.btn-ingest-primary {
  background: var(--teal);
  color: #fff;
}

.btn-ingest-primary:hover:not(:disabled) { opacity: .9; }

.btn-ingest-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--divider);
}

.btn-ingest-secondary:hover:not(:disabled) {
  border-color: var(--text-f);
}

.ingest-status {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-f);
}


/* ── PROGRESS ────────────────────────────────────────────── */

.ingest-progress {
  width: 100%;
  height: 6px;
  background: var(--surface3);
  border-radius: var(--tile-radius);
  overflow: hidden;
  margin-top: var(--sp3);
}

.ingest-progress-bar {
  height: 100%;
  background: var(--teal);
  border-radius: var(--tile-radius);
  transition: width .3s;
  width: 0%;
}


/* ── RESULTS ─────────────────────────────────────────────── */

.ingest-result {
  padding: var(--sp3) var(--sp4);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  margin-top: var(--sp3);
}

.ingest-result-success {
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  border: 1px solid var(--green);
  color: var(--green);
}

.ingest-result-error {
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  border: 1px solid var(--red);
  color: var(--red);
}


/* ── INGEST PANELS (two-column layout: evidence vs spine) ── */
/*
 * pbccd.html hosts two independent write paths under a single file
 * upload: evidence ingestion into compliance.json (left panel) and
 * PBCCD spine seeding into the dashboard (right panel). Each panel is
 * self-contained with its own heading, preview, action and status so
 * the two flows never share state or messaging. Phase 5J will likely
 * add a third "Policy documents" panel using the same primitive.
 */

.ingest-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--sp5);
  align-items: stretch;
}

.ingest-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--tile-radius);
  padding: var(--sp5) var(--sp5) var(--sp5) var(--sp6);
  display: flex;
  flex-direction: column;
  gap: var(--sp4);
  min-height: 260px;
  transition: border-color var(--trans), background var(--trans);
}

.ingest-panel::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--sp5);
  bottom: var(--sp5);
  width: 3px;
  background: var(--teal);
  border-radius: var(--tile-radius);
}

.ingest-panel.is-ready { border-color: var(--text-f); }
.ingest-panel.is-empty { background: var(--surface2); }

.ingest-panel-eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-m);
  margin: 0;
}

.ingest-panel-title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text);
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.ingest-panel-lede {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-m);
  line-height: 1.55;
  margin: 0;
  max-width: 56ch;
}

.ingest-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp3);
  min-height: 0;
}

.ingest-panel-foot {
  display: flex;
  flex-direction: column;
  gap: var(--sp3);
}

.panel-placeholder {
  border: 1px dashed var(--divider);
  border-radius: var(--r-md);
  padding: var(--sp5);
  text-align: center;
  color: var(--text-f);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  background: var(--surface);
}

.ingest-panel.is-ready .panel-placeholder { display: none; }
.ingest-panel.is-empty .panel-ready-only  { display: none; }


/* ── SPINE PREVIEW CARD (right panel) ───────────────────── */

.spine-preview {
  display: flex;
  flex-direction: column;
  gap: var(--sp3);
  padding: var(--sp4);
  background: var(--surface2);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
}

.spine-preview-title {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-m);
  margin: 0;
}

.spine-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp3);
}

.spine-preview-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp2) 0;
}

.spine-preview-val {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1;
}

.spine-preview-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-m);
}

.spine-preview-foot {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-f);
  border-top: 1px solid var(--divider);
  padding-top: var(--sp3);
  line-height: 1.5;
}

.spine-preview-foot strong { color: var(--text); font-weight: 500; }

.spine-preview.error {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface));
  border-color: var(--amber);
}


/* ── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 860px) {
  .ingest-panels { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .steps { flex-direction: column; gap: var(--sp2); }
  .ingest-stat-row { flex-wrap: wrap; }
  .spine-preview-grid { grid-template-columns: repeat(3, 1fr); }
}
