/* ── Variabelen ──────────────────────────────────────────────────────────── */
:root {
  --kleur-oranje:     #c85c00;
  --kleur-rand:       #e8cfa4;
  --kleur-btn:        #f0ddff;
  --kleur-btn-rand:   #c99ae0;
  --kleur-input-rand: #cdb99a;
  --font-ui:          0.82rem;
  --font-klein:       0.78rem;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fff7f0;
  color: #2d2010;
}

/* ── Layout: sidebar + kaart ─────────────────────────────────────────────── */
.container {
  display: grid;
  grid-template-columns: clamp(430px, 36vw, 520px) minmax(0, 1fr);
  height: 100vh;
}

aside {
  background: #faf4e8;
  border-right: 1px solid var(--kleur-rand);
  padding: 50px 14px 14px;
  overflow-y: auto;
  width: 100%;
}

.section-title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--kleur-oranje);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Kaart ───────────────────────────────────────────────────────────────── */
.map-container {
  position: relative;
  outline: 2px solid #000;
}

.gm-style-cc { display: none !important; }

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

/* ── Typografie ──────────────────────────────────────────────────────────── */
h2 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--kleur-oranje);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--kleur-rand);
}

p {
  margin: 0 0 4px;
  font-size: var(--font-ui);
}

/* ── Sidebar-secties ─────────────────────────────────────────────────────── */
.sidebar-section {
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--kleur-rand);
  box-shadow: 0 1px 3px rgba(150, 90, 10, 0.07);
}

/* ── Acties-rijen ────────────────────────────────────────────────────────── */
.actions-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  white-space: nowrap;
  margin-top: 7px;
  font-size: var(--font-ui);
}

.actions-row.two-cols {
  display: grid;
  grid-template-columns: auto 90px;
  gap: 6px;
  white-space: nowrap;
  margin-top: 8px;
}

.actions-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.toggle-tekst {
  min-width: 72px;
}

/* Coördinaten-opties inspringen */
.coord-row {
  margin-left: 22px;
}

/* ── Knoppen ─────────────────────────────────────────────────────────────── */
.btn {
  border-radius: 999px;
  border: 1px solid var(--kleur-btn-rand);
  padding: 4px 10px;
  font-size: var(--font-klein);
  cursor: pointer;
  background: var(--kleur-btn);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
  white-space: nowrap;
  transition: background 0.12s;
}

.btn:hover { background: #e2c4ff; }

/* ── Formulierelementen ──────────────────────────────────────────────────── */
select,
input[type="number"],
input[type="text"] {
  padding: 4px 6px;
  font-size: var(--font-klein);
  border-radius: 6px;
  border: 1px solid var(--kleur-input-rand);
  background: #fff;
  color: #2d2010;
  transition: border-color 0.12s, box-shadow 0.12s;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--kleur-oranje);
  box-shadow: 0 0 0 2px rgba(200, 92, 0, 0.15);
}

input[type="number"] { width: 46px; }
#coordDecimalsInput  { width: 38px; }

#layoutNameInput,
#layoutSelect,
#saveFilename {
  flex: 1;
  min-width: 0;
}

#coordDecimalsWrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#saveDpiDims {
  color: #999;
  font-size: 0.72rem;
}

/* ── Uitgelijnde rasterjes ───────────────────────────────────────────────── */
.font-size-grid {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 5px 8px;
  align-items: center;
  margin-top: 7px;
  font-size: var(--font-ui);
  width: fit-content;
}

.layout-naam-grid {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px 8px;
  align-items: center;
  margin-top: 7px;
  font-size: var(--font-ui);
}

.layout-btn-group {
  display: flex;
  gap: 6px;
}

/* ── Soorten-lijst ───────────────────────────────────────────────────────── */
.species-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.species-row {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 6px;
  row-gap: 2px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fffaf4;
  border: 1px solid var(--kleur-rand);
  font-size: 0.8rem;
}

.species-main {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.species-main label {
  font-weight: 600;
  cursor: pointer;
}

.species-count {
  margin-left: auto;
  font-size: 0.72rem;
  opacity: 0.7;
}

.species-controls {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  white-space: nowrap;
  font-size: var(--font-ui);
}

.species-controls .label {
  font-weight: 500;
}

select.color-select {
  min-width: 80px;
}

select.duplicate-color { border: 2px solid red !important; }
.color-preview.duplicate-color { box-shadow: 0 0 0 2px red; }
.legend-color-dot.duplicate-color { box-shadow: 0 0 0 2px red; }

.color-preview {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #555;
  margin-left: 4px;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Toggle-menu knop + titel ────────────────────────────────────────────── */
.map-header-bar {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-menu-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--kleur-btn-rand);
  background: #e6beff;
  font-size: var(--font-klein);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background 0.12s;
  white-space: nowrap;
}

.toggle-menu-btn:hover { background: #dba8ff; }

.help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--kleur-btn-rand);
  background: #e6beff;
  font-size: 0.9rem;
  font-weight: 700;
  color: #333;
  cursor: pointer;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background 0.12s;
}

.help-btn:hover { background: #dba8ff; }

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.help-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.help-modal-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(780px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  background: #fff7f0;
  border-radius: 14px;
  padding: 32px 36px 36px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.help-modal-close {
  position: sticky;
  float: right;
  top: 0;
  border: 1px solid var(--kleur-btn-rand);
  background: var(--kleur-btn);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
  margin-left: 12px;
  transition: background 0.12s;
}

.help-modal-close:hover { background: #e2c4ff; }

.help-modal-box h1 {
  font-size: 1.1rem;
  color: var(--kleur-oranje);
  margin: 0 0 4px;
}

.help-modal-box h2 {
  font-size: 0.88rem;
  color: var(--kleur-oranje);
  border-bottom: 1px solid var(--kleur-rand);
  padding-bottom: 3px;
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.help-modal-box p {
  font-size: 0.84rem;
  margin: 0 0 6px;
  line-height: 1.55;
}

.help-modal-box table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.help-modal-box th {
  background: #faf4e8;
  border: 1px solid var(--kleur-rand);
  padding: 5px 10px;
  text-align: left;
  color: #7a4f00;
}

.help-modal-box td {
  border: 1px solid var(--kleur-rand);
  padding: 5px 10px;
  vertical-align: top;
  line-height: 1.5;
}

.help-modal-box tr:nth-child(even) td { background: #fffbf4; }

.help-modal-box code {
  font-family: ui-monospace, monospace;
  font-size: 0.80rem;
  background: #f0ece4;
  padding: 1px 5px;
  border-radius: 4px;
}

.map-main-title {
  font-size: 30px;
  font-weight: 700;
  color: #3b1b70;
  text-shadow: 0 1px 3px rgba(255,255,255,0.8);
  pointer-events: none;
  white-space: nowrap;
}

.sidebar-hidden aside { display: none; }
.sidebar-hidden .map-container { grid-column: 1 / -1; }

/* ── Legenda ─────────────────────────────────────────────────────────────── */
.legend-species {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ffffffdd;
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  font-size: 0.95rem;
  cursor: move;
  user-select: none;
  width: fit-content;
  max-width: min(420px, 35vw);
  z-index: 1000;
}

.legend-header {
  height: 1px;
  margin-bottom: 4px;
  background: transparent;
  cursor: move;
  padding: 0;
  border: none;
  font-size: 0;
}

.legend-species ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-style: italic;
}

.legend-species li {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.legend-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #555;
  flex-shrink: 0;
}

/* ── Kompas ──────────────────────────────────────────────────────────────── */
.north-arrow {
  position: absolute;
  bottom: 20px;
  left: 20px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  cursor: move;
  z-index: 1000;
}

.north-arrow img {
  display: block;
  width: 120px;
  height: auto;
  pointer-events: auto;
}

/* ── Schaalbalk ──────────────────────────────────────────────────────────── */
.grid-scale {
  position: absolute;
  bottom: 80px;
  right: 20px;
  background: transparent;
  padding: 0;
  box-shadow: none;
  border-radius: 0;
  z-index: 1000;
  cursor: move;
  width: fit-content;
}

.grid-scale-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

/* ── Uitsnede-kader ──────────────────────────────────────────────────────── */
#cropBox {
  position: absolute;
  border: 2px dashed rgba(220, 30, 30, 0.9);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  z-index: 999;
  cursor: move;
  min-width: 80px;
  min-height: 60px;
  display: none;
}

.crop-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1.5px solid rgba(220, 30, 30, 0.9);
  border-radius: 2px;
}

.crop-handle[data-dir="nw"] { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle[data-dir="n"]  { top: -6px; left: calc(50% - 5px); cursor: n-resize; }
.crop-handle[data-dir="ne"] { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle[data-dir="e"]  { top: calc(50% - 5px); right: -6px; cursor: e-resize; }
.crop-handle[data-dir="se"] { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle[data-dir="s"]  { bottom: -6px; left: calc(50% - 5px); cursor: s-resize; }
.crop-handle[data-dir="sw"] { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle[data-dir="w"]  { top: calc(50% - 5px); left: -6px; cursor: w-resize; }

.crop-dims {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .container {
    grid-template-columns: 1fr;
  }

  aside {
    position: absolute;
    z-index: 998;
    width: min(460px, 100vw);
    max-width: 100vw;
    height: 100vh;
    overflow-y: auto;
    background: #faf4e8;
  }

  .map-container { grid-column: 1 / -1; }
}
