/* ===================================================
   Maisdoolhof Generator — Stylesheet
   =================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #166534;
  --primary-light: #22c55e;
  --primary-dark: #14532d;
  --primary-bg: #f0fdf4;
  --surface: #ffffff;
  --bg: #f4f6f4;
  --text: #1a1a1a;
  --text-secondary: #616161;
  --text-muted: #9e9e9e;
  --border: #e0e0e0;
  --error: #d32f2f;
  --warning: #f57c00;
  --sidebar-w: 380px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
  --transition: .2s ease;
  --maze-path: #22c55e;
  --maze-wall: #166534;
  --maze-solution: #3b82f6;
  --maze-start: #f59e0b;
  --maze-end: #ef4444;
  --maze-bridge: #a78bfa;  /* bridge gap cells — purple */
}

html, body { height: 100%; width: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ---------- App Layout ---------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}

.sidebar-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-bg);
  color: var(--text);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon { font-size: 22px; line-height: 1; filter: saturate(0.7); opacity: 0.8; }

.logo h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.2px;
  color: var(--primary-dark);
}

.subtitle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ---------- Tabs ---------- */
.tabs {
  margin-bottom: 0px;
}

.tabs-nav {
  display: flex;
  gap: 4px;
  background: #eee;
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.tab-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tab-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ---------- Steps ---------- */
.sidebar-steps {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}

.sidebar-steps::-webkit-scrollbar { width: 5px; }
.sidebar-steps::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.step {
  border-bottom: 1px solid var(--border);
}

.step.disabled { opacity: .5; pointer-events: none; }
.step.disabled .step-header { cursor: default; }

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}
.step-header:hover { background: var(--primary-bg); }

.step-indicator {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.step.active .step-indicator,
.step.complete .step-indicator {
  background: var(--primary);
  color: white;
}

.step-optional .step-indicator {
  background: transparent;
  border: 1.5px dashed var(--border);
  color: var(--text-muted);
}
.step-optional.active .step-indicator {
  border-color: var(--primary);
  color: var(--primary);
}

.step-header h2 {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.chevron {
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition);
}

.step.collapsed .chevron { transform: rotate(90deg); }
.step:not(.collapsed) .step-body { display: block; }
.step.collapsed .step-body { display: none; }

.step-body {
  padding: 4px 16px 16px;
}

.step-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* ---------- Form Elements ---------- */
.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-row label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

select, .text-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
  outline: none;
}
select:focus, .text-input:focus { border-color: var(--primary-light); }

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

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: background var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover { background: var(--primary-light); }

.number-input {
  width: 60px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
  outline: none;
}
.number-input:focus { border-color: var(--primary-light); }

.unit-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.slider-value-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform 80ms;
  text-decoration: none;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-ghost {
  background: var(--primary-bg);
  color: var(--primary);
  border: 1px solid rgba(22,101,52,.2);
}
.btn-ghost:hover:not(:disabled) { background: #dcfce7; }

.btn-warning {
  background: #f59e0b;
  color: white;
  animation: pulse-warning 1.2s ease-in-out infinite;
}
.btn-warning:hover:not(:disabled) { background: #d97706; }
@keyframes pulse-warning {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.5); }
  50%       { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
}

.btn-full { width: 100%; }
.btn-half { flex: 1; }

.btn-sm { font-size: 12px; padding: 5px 10px; }

.btn-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.btn-entry-start {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.btn-entry-start:hover { background: #fde68a; }
.btn-entry-start.active-entry {
  background: var(--maze-start);
  color: white;
  border-color: var(--maze-start);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .4);
  animation: entry-pulse 1.4s ease-in-out infinite;
}

@keyframes entry-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, .4); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, .15); }
}

.btn-entry-end {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.btn-entry-end:hover { background: #fecaca; }
.btn-entry-end.active-entry {
  background: var(--maze-end);
  color: white;
  border-color: var(--maze-end);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .4);
  animation: entry-pulse-end 1.4s ease-in-out infinite;
}

@keyframes entry-pulse-end {
  0%, 100% { box-shadow: 0 0 0 3px rgba(239, 68, 68, .4); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, .15); }
}

.entry-point-row {
  display: flex;
  gap: 8px;
}

.export-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.btn-export {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  padding: 8px 10px;
  flex-direction: column;
  gap: 4px;
  height: 58px;
}
.btn-export:hover:not(:disabled) { background: var(--primary-bg); border-color: var(--primary-light); color: var(--primary); }
.btn-export .btn-icon { width: 18px; height: 18px; }

/* ---------- Info / Stats Boxes ---------- */
.hint-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: #78350f;
}

.stats-box {
  background: var(--primary-bg);
  border: 1px solid rgba(22,101,52,.15);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.parcel-info { }

/* ---------- Selected Parcels List ---------- */
.selected-parcels-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.selected-parcel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 12px;
}
.selected-parcel-item.primary {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}
.parcel-item-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 9999px;
  background: var(--primary-dark);
  color: #fff;
  white-space: nowrap;
}
.selected-parcel-item:not(.primary) .parcel-item-badge {
  background: #0369a1;
}
.parcel-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.parcel-item-area {
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}
.parcel-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  transition: color var(--transition);
}
.parcel-item-remove:hover { color: #ef4444; }

.info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 0;
}
.info-row .label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- File Drop ---------- */
.file-drop {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.file-drop:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.file-drop input[type="file"] { display: none; }

.file-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.upload-icon {
  width: 36px;
  height: 36px;
  fill: var(--text-muted);
}

.file-drop-text {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- Map Container ---------- */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #e5e7eb;
}

/* ---------- Geocoder ---------- */
.geocoder-box {
  position: absolute;
  top: 12px;
  left: 60px;
  z-index: 800;
  width: 300px;
  font-size: 13px;
}
.geocoder-input-row {
  display: flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 8px;
  box-shadow: var(--shadow-lg);
  gap: 6px;
}
.geocoder-icon {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary);
  flex-shrink: 0;
}
#geocoder-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 8px 0;
  font-size: 13px;
  background: transparent;
  color: var(--text-primary);
}
#geocoder-input::placeholder { color: var(--text-secondary); }
.geocoder-clear {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  padding: 0 2px;
  line-height: 1;
}
.geocoder-clear:hover { color: var(--text-primary); }
.geocoder-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
}
.geocoder-results li {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  line-height: 1.35;
}
.geocoder-results li:last-child { border-bottom: none; }
.geocoder-results li:hover, .geocoder-results li.active { background: var(--primary-bg); }
.geocoder-results li .gc-name { font-weight: 600; color: var(--text-primary); }
.geocoder-results li .gc-type { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

/* ---------- Map Toolbar ---------- */
.map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow-lg);
}

.toolbar-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.toolbar-btn svg { width: 18px; height: 18px; fill: currentColor; }
.toolbar-btn:hover { background: var(--primary-bg); color: var(--primary); }
.toolbar-btn.active { background: var(--primary); color: white; }

.toolbar-separator {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* ---------- Map Legend ---------- */
.map-legend {
  position: absolute;
  bottom: 28px;
  right: 12px;
  z-index: 800;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.1);
}

.legend-start {
  background: var(--maze-start);
  border-radius: 50%;
}

.legend-end {
  background: var(--maze-end);
  border-radius: 50%;
}

/* ---------- Entry Dots ---------- */
.entry-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.2);
}
.start-dot { background: var(--maze-start); }
.end-dot   { background: var(--maze-end); }

/* ---------- Loading Overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  background: white;
  border-radius: var(--radius);
  padding: 32px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #1a1a1a;
  color: white;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { background: var(--error); }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
