/*
  Perch VBT import workflow.

  Loaded alongside styles/v3-app-shell.css in v3.html (after it, so the
  --v3-* custom properties it defines are already in scope) -- this file
  never redefines them and never touches css/styles.css, the legacy Phase
  9.7 stylesheet. Scoped entirely under .v3-perch-import-* /
  [data-perch-import-*] selectors so it can never bleed into the rest of the
  shell, the Force Measurement dashboard's .v3-fm-* styles, or the Force
  Measurement import's .v3-import-* styles.

  Unlike the Force Measurement import, this is an inline section of the
  Velocity-Based Training panel rather than a modal overlay -- so there is
  no overlay/backdrop rule here.
*/

.v3-perch-import {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-4);
  padding: var(--v3-space-5);
  background: var(--v3-surface);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-md);
}

.v3-perch-import-header h3 {
  margin: 0;
  font-size: 1rem;
}

.v3-perch-import-subtitle {
  margin: var(--v3-space-1) 0 0;
  color: var(--v3-text-muted);
  font-size: 0.85rem;
}

.v3-perch-import-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--v3-text-muted);
  min-height: 1.2em;
}

.v3-perch-import-success {
  margin: 0;
  padding: var(--v3-space-2) var(--v3-space-3);
  border-radius: var(--v3-radius-sm);
  background: #e6f4ea;
  border: 1px solid #a8d5b5;
  color: #1e5631;
  font-weight: 600;
  font-size: 0.85rem;
}

.v3-perch-import-field {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-2);
}

.v3-perch-import-field label {
  font-weight: 600;
  font-size: 0.85rem;
}

.v3-perch-import-field input[type="file"] {
  font: inherit;
  padding: var(--v3-space-2);
  border: 1px dashed var(--v3-border-strong);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
}

.v3-perch-import-field input[type="file"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.v3-perch-import-hint {
  margin: 0;
  color: var(--v3-text-muted);
  font-size: 0.78rem;
}

.v3-perch-import-file-errors {
  padding: var(--v3-space-3);
  border-radius: var(--v3-radius-sm);
  border: 1px solid #e0a3a3;
  background: #fdecea;
  color: #7a1f1f;
  font-size: 0.85rem;
}

.v3-perch-import-file-errors ul {
  margin: 0;
  padding-left: var(--v3-space-4);
}

.v3-perch-import-results {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-5);
}

/* The results region receives focus after parsing; keep that visible. */
.v3-perch-import-results:focus-visible,
.v3-perch-import-file-errors:focus-visible {
  outline: 2px solid var(--v3-focus-ring);
  outline-offset: 3px;
}

.v3-perch-import-section-heading {
  margin: 0 0 var(--v3-space-2);
  font-size: 0.95rem;
  font-weight: 700;
}

.v3-perch-import-note {
  margin: 0;
  color: var(--v3-text-muted);
  font-size: 0.85rem;
}

.v3-perch-import-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--v3-space-3);
  margin: 0;
}

.v3-perch-import-summary-item {
  padding: var(--v3-space-3);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
  border: 1px solid var(--v3-border);
}

.v3-perch-import-summary-item dt {
  margin: 0 0 var(--v3-space-1);
  font-size: 0.75rem;
  color: var(--v3-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.v3-perch-import-summary-item dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.v3-perch-import-summary-item--matchedRowCount,
.v3-perch-import-summary-item--eligibleRowCount {
  border-color: #a8d5b5;
}

.v3-perch-import-summary-item--unmatchedRowCount,
.v3-perch-import-summary-item--invalidRowCount {
  border-color: #e0a3a3;
}

.v3-perch-import-summary-item--ambiguousRowCount,
.v3-perch-import-summary-item--duplicateRowCount {
  border-color: #e6c36a;
}

.v3-perch-import-table-wrap {
  overflow-x: auto;
  max-height: 45vh;
  overflow-y: auto;
}

.v3-perch-import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.v3-perch-import-table caption {
  text-align: left;
  padding-bottom: var(--v3-space-2);
  color: var(--v3-text-muted);
  font-size: 0.8rem;
}

.v3-perch-import-table th,
.v3-perch-import-table td {
  padding: var(--v3-space-2) var(--v3-space-3);
  border-bottom: 1px solid var(--v3-border);
  text-align: left;
  white-space: nowrap;
}

.v3-perch-import-table thead th {
  background: var(--v3-surface-muted);
  font-weight: 700;
}

.v3-perch-import-table tbody th[scope="row"] {
  font-weight: 600;
}

.v3-perch-import-row--unmatched {
  background: #fdecea;
}

.v3-perch-import-row--ambiguous {
  background: #fdf3d9;
}

.v3-perch-import-status-badge {
  display: inline-block;
  padding: 2px var(--v3-space-2);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.v3-perch-import-status-badge--matched {
  background: #e6f4ea;
  color: #1e5631;
}

.v3-perch-import-status-badge--unmatched {
  background: #fdecea;
  color: #7a1f1f;
}

.v3-perch-import-status-badge--ambiguous {
  background: #fdf3d9;
  color: #7a4f00;
}

.v3-perch-import-validation-group + .v3-perch-import-validation-group {
  margin-top: var(--v3-space-3);
}

.v3-perch-import-validation-group h4 {
  margin: 0 0 var(--v3-space-1);
  font-size: 0.85rem;
  font-weight: 700;
}

.v3-perch-import-validation-group ul {
  margin: 0;
  padding-left: var(--v3-space-4);
  font-size: 0.82rem;
  color: var(--v3-text-muted);
}

.v3-perch-import-validation-group--file ul {
  color: #7a1f1f;
}

.v3-perch-import-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--v3-space-3);
}

.v3-perch-import-actions .v3-button[disabled],
.v3-perch-import-actions .v3-button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
