/*
 * ARC-356 — FlowGrid-inspired ArcheYo theme layer
 *
 * Source of truth: ARC-355 FlowGrid-to-ArcheYo Design Token Mapping.
 * This file intentionally overrides only design tokens / low-risk base styling.
 * It is loaded after archeyo.css so the theme remains isolated and revertable.
 */

:root {
  --bg: #0a0a0b;
  --surface: #111113;
  --surface2: #18181b;
  --surface3: #1f1f23;
  --surface-ink: #0f0f12;
  --surface-table: #141416;

  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text: #ededef;
  --text-dim: #8b8b8e;
  --text-muted: #5c5c5f;

  --accent: #c87a3c;
  --accent-light: #e09550;
  --accent-bg: rgba(200, 122, 60, 0.12);
  --accent-bg-soft: rgba(200, 122, 60, 0.1);
  --accent-glow: rgba(200, 122, 60, 0.22);
  --accent-border-subtle: rgba(200, 122, 60, 0.24);
  --accent-border: rgba(200, 122, 60, 0.32);
  --accent-border-strong: rgba(200, 122, 60, 0.42);
  --focus-ring: rgba(200, 122, 60, 0.12);
  --white-contrast: #fff;
  --hover-surface: rgba(255, 255, 255, 0.035);

  --flowgrid-accent: #5e6ad2;
  --flowgrid-accent-light: #6c78e0;
  --flowgrid-accent-bg: rgba(94, 106, 210, 0.12);

  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.1);
  --orange: #fb923c;
  --orange-bg: rgba(251, 146, 60, 0.12);
  --blue: #a5b4fc;
  --blue-bg: rgba(94, 106, 210, 0.15);
  --purple: #a5b4fc;
  --purple-bg: rgba(94, 106, 210, 0.15);

  --shadow: 0 16px 48px rgba(0, 0, 0, 0.32);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

html,
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

body {
  background:
    radial-gradient(circle at top left, var(--accent-bg-soft), transparent 24%),
    radial-gradient(circle at right, rgba(94, 106, 210, 0.04), transparent 22%),
    var(--bg);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* ARC-357 — shell, navigation, and reusable core component alignment. */
.app-shell {
  background: var(--bg);
}

.sidebar {
  background: var(--surface-ink);
  border-right: 1px solid var(--border-subtle);
  box-shadow: none;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-item {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.nav-item:hover {
  background: var(--hover-surface);
  border-color: var(--border-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-light);
  box-shadow: none;
}

.content-card,
.table-card,
.info-card,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}

.button.primary,
.btn-primary {
  background: var(--accent);
  border-color: var(--accent-border-strong);
  color: var(--white-contrast);
  box-shadow: 0 0 0 1px var(--focus-ring), 0 8px 22px rgba(0, 0, 0, 0.26);
}

.btn-secondary,
.button.secondary {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.button,
.btn,
.nav-button {
  border-radius: var(--radius-sm);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-bg);
}

input,
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
}

table,
.data-table,
.afas-projects-table {
  background: var(--surface);
  border-collapse: collapse;
}

th,
.data-table th,
.afas-projects-table th {
  padding: 8px 10px;
  background: var(--surface-table);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}

td,
.data-table td,
.afas-projects-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
}

.badge {
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  box-shadow: none;
}

.badge.accent {
  background: var(--accent-bg);
  border-color: var(--accent-border-subtle);
  color: var(--accent-light);
}

.template-modal-card,
.project-emergency-modal-card,
.gemeente-modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/*
 * ARC-358 — representative screen tuning.
 * Rollback stays simple: remove this stylesheet import from index.html or revert this
 * additive block; no base archeyo.css selectors are edited here.
 */
.dashboard-hero,
.panel.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: none;
  padding: 18px;
}

.dashboard-hero h3,
.panel.hero h3 {
  color: var(--text);
}

.stats-grid .stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 14px;
}

.stats-grid .stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.72;
}

.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 14px;
}

.quick-action:hover {
  background: var(--surface2);
  border-color: var(--accent-border);
  box-shadow: none;
  transform: translateY(-1px);
}

.beheer-grid {
  gap: 12px;
  margin-top: 14px;
}

.beheer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: none;
  padding: 16px;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.beheer-card:hover:not(.disabled) {
  background: var(--surface2);
  border-color: var(--accent-border);
  box-shadow: none;
  transform: translateY(-1px);
}

.beheer-card-icon {
  margin-bottom: 10px;
  font-size: 1.55rem;
  filter: saturate(0.92);
}

.beheer-card-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.beheer-tab-content .panel,
#section-projectenadministratie .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}

.integrations-layout {
  gap: 12px;
}

.integration-status,
#section-dashboard .empty,
#section-beheer .empty,
#section-datamodelconversie .empty,
#section-projectenadministratie .empty,
#section-printen .empty {
  background: var(--surface2);
  border: 1px solid var(--border-subtle);
}

.datamodel-conversie-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 12px;
}

.selected-source-overview {
  margin: -4px 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface2);
  padding: 8px;
}

.selected-source-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.selected-source-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px 5px;
  background: rgba(255,255,255,0.035);
  font-size: 11px;
}

.selected-source-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-source-chip .button {
  min-height: 22px;
  height: 22px;
  padding: 1px 6px;
  font-size: 11px;
}

.selected-source-empty {
  color: var(--muted);
  font-size: 12px;
}

.mapping-editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.55fr) minmax(720px, 1.9fr) minmax(240px, 0.65fr);
  gap: 14px;
  align-items: stretch;
}

.velddata-mapping-grid {
  min-height: 460px;
}

.mapping-field-list,
.mapping-row-list,
.validation-summary-strip {
  background: var(--surface2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0;
}

.mapping-field-list h5,
.mapping-row-list h5 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mapping-field-list {
  max-height: 520px;
  overflow: auto;
}

.velddata-tree-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)), var(--surface2);
}

.velddata-tree {
  padding: 8px 0;
}

.velddata-tree-group + .velddata-tree-group {
  border-top: 1px solid var(--border-subtle);
}

.velddata-tree-group.collapsed .velddata-tree-children {
  display: none;
}

.velddata-tree-group:not(.collapsed) .tree-caret {
  transform: rotate(90deg);
}

.tree-caret {
  transition: transform 120ms ease;
}

.velddata-tree-node {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 18px auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 7px 12px;
  text-align: left;
  cursor: pointer;
}

.velddata-tree-node:hover,
.velddata-tree-node.active {
  background: rgba(199, 120, 53, 0.12);
  border-left-color: var(--accent, #c77835);
}

.velddata-tree-parent strong,
.tree-field-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-badge {
  border-radius: 5px;
  background: rgba(88, 135, 255, 0.18);
  color: #8fb4ff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  padding: 4px 5px;
}

.tree-count {
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 11px;
  padding: 3px 8px;
}

.tree-caret,
.tree-spacer {
  color: var(--muted);
  text-align: center;
}

.velddata-tree-leaf {
  grid-template-columns: 36px minmax(0, 1fr);
  color: var(--muted-strong, var(--text));
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.mapping-row-list {
  overflow: auto;
}

.mapping-row-list .mapping-row {
  width: 100%;
  justify-content: flex-start;
}

.mapping-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mapping-row-header,
.mapping-filter-row,
.mapping-row-compact {
  display: grid;
  grid-template-columns: minmax(96px, 0.62fr) minmax(138px, 0.95fr) 24px minmax(108px, 0.64fr) minmax(150px, 0.95fr) minmax(122px, 0.72fr) minmax(76px, 0.38fr) minmax(116px, 0.55fr);
  gap: 8px;
  align-items: center;
}

.mapping-row-header {
  min-height: 42px;
  padding: 0 12px;
  background: rgba(255,255,255,0.025);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mapping-filter-row {
  min-height: 34px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.012);
}

.mapping-filter-select {
  min-width: 0;
  width: 100%;
  height: 26px;
  min-height: 26px;
  padding: 2px 7px;
  font-size: 12px;
}

.mapping-row-compact {
  min-height: 28px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}

.mapping-row-compact input,
.mapping-row-compact select {
  min-width: 0;
  width: 100%;
  height: 24px;
  min-height: 24px;
  padding: 2px 7px;
  font-size: 12px;
}

.mapping-row-compact .button {
  min-height: 24px;
  height: 24px;
  padding-top: 2px;
  padding-bottom: 2px;
  font-size: 12px;
}

.mapping-row-empty,
.mapping-row-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.mapping-row-toolbar {
  border-bottom: 0;
}

.mapping-arrow {
  color: var(--muted);
  text-align: center;
}

.mapping-required {
  justify-content: center;
  min-width: 0;
  gap: 0;
}

.mapping-required input {
  width: 16px;
  height: 16px;
  min-height: 16px;
}

.mapping-required span {
  display: none;
}

.mapping-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.mapping-delete-button {
  min-width: 28px;
  padding-inline: 6px;
  color: #ff9b9b;
}

.mapping-row-actions .button {
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
}

.mapping-row.selected {
  background: rgba(199, 120, 53, 0.08);
  box-shadow: inset 3px 0 0 var(--accent, #c77835);
}

.mapping-field-list .button,
.mapping-target-filter .button,
.velddata-tree-node {
  cursor: pointer;
}

.mapping-target-filter {
  display: block;
  margin-bottom: 0;
}

.mapping-target-filter .button.active,
.mapping-target-filter .velddata-tree-node.active {
  border-color: var(--accent, #c77835);
  color: var(--text);
}

.validation-summary-strip {
  margin-top: 12px;
  margin-bottom: 12px;
  padding: 10px;
}

@media (max-width: 960px) {
  .datamodel-conversie-grid,
  .mapping-editor-grid {
    grid-template-columns: 1fr;
  }
}

#beheerBillingSummary.stats-grid .stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
}

#beheerBillingSummary.stats-grid .stat-card::before {
  background: var(--accent);
}

#beheerBillingUsage.data-table-wrap {
  max-height: min(58vh, 520px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

#printTabs .button[aria-selected="true"],
#printTabs .button.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-light);
}

#section-printen .panel,
.export-grid .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: none;
}

#section-printen .section-stack {
  gap: 12px;
}

#boxStickerPreview {
  background: var(--surface2);
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

#section-photos.active {
  height: calc(100vh - 104px);
  min-height: 0;
  overflow: hidden;
}

#section-photos .photo-layout {
  height: 100%;
  min-height: 0;
}

#section-photos .photo-layout > .panel {
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#section-photos .photo-layout > .stack {
  align-self: stretch;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 1200px) {
  #section-photos.active {
    height: auto;
    overflow: visible;
  }

  #section-photos .photo-layout,
  #section-photos .photo-layout > .panel,
  #section-photos .photo-layout > .stack {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 900px) {
  .dashboard-hero,
  .panel.hero,
  #section-beheer .toolbar,
  #section-projectenadministratie .toolbar,
  #section-printen .toolbar {
    align-items: flex-start;
    gap: 12px;
  }

  .beheer-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .integrations-layout {
    grid-template-columns: 1fr;
  }
}
