/* Context Driehoek – Creatieve Maan */

:root {
  --color-primary: #4a90d9;
  --color-primary-dark: #357abd;
  --color-bg: #f8fafc;
  --color-card: #fff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1rem;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.back:hover {
  text-decoration: underline;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Input panel – bovenaan, volle breedte */
.input-panel {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.input-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-section {
  margin-bottom: 0;
}

.panel-section label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--color-text-muted);
}

#name-input {
  width: 100%;
  max-width: 280px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.top-sections-title,
.factors-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.top-sections-row,
.factors-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.top-sections-row .factor-input,
.factors-row .factor-input {
  flex: 1;
  min-width: 180px;
}

.factor-input h3,
.factor-input h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.add-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.factor-add-input,
.section-add-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.btn-add {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add:hover {
  background: var(--color-primary-dark);
}

.item-list,
.section-item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-list li,
.section-item-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.2rem;
  background: var(--color-bg);
  border-radius: 6px;
  font-size: 0.85rem;
}

.item-list li .item-text,
.section-item-list li .item-text {
  flex: 1;
  min-width: 0;
}

.item-list li .btn-edit,
.item-list li .btn-delete,
.section-item-list li .btn-edit,
.section-item-list li .btn-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.item-list li .btn-delete:hover,
.section-item-list li .btn-delete:hover {
  color: var(--color-danger);
}

.item-list li .btn-edit:hover,
.section-item-list li .btn-edit:hover {
  color: var(--color-primary);
}

.panel-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn {
  flex: 1;
  max-width: 120px;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

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

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

.btn-secondary:hover {
  background: #e2e8f0;
}

/* Content area – driehoek links, secties rechts */
.content-area {
  display: flex;
  gap: 2rem;
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  margin-top: 0;
}

.content-left {
  flex: 2;
  min-width: 0;
}

.view-name {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.triangle-container {
  position: relative;
  width: 100%;
  min-width: 280px;
  aspect-ratio: 400 / 400;
  background: rgba(74, 144, 217, 0.06);
  border-radius: var(--radius);
}

.triangle-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.triangle-svg .label {
  font-size: 12px;
  fill: #333;
  font-weight: 500;
}

.triangle-svg .label-center {
  font-size: 10px;
  fill: #333;
  font-weight: 500;
}

.triangle-svg .label-sector {
  font-size: 10px;
  font-weight: 600;
}

.triangle-svg .label-omgeving { fill: #2d6b2d; }
.triangle-svg .label-gezin { fill: #2d5a7b; }
.triangle-svg .label-kind { fill: #8b4a5a; }

.items-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.items-layer.print-mode {
  pointer-events: none;
}

.triangle-item {
  position: absolute;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  cursor: grab;
  pointer-events: auto;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.triangle-item-omgeving {
  background: #b8e6b8;
  border: 1px solid #7cb87c;
}

.triangle-item-gezin {
  background: #b8d4e6;
  border: 1px solid #7ca8c4;
}

.triangle-item-kind {
  background: #f0c8d0;
  border: 1px solid #c4909c;
}

.triangle-item:active {
  cursor: grabbing;
}

.triangle-item.dragging {
  z-index: 100;
  opacity: 0.9;
}

/* Secties sidebar – rechts, onder elkaar */
.sections-sidebar {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.above-section {
  flex: 1;
  min-height: 0;
}

.above-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}

.above-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.above-list li {
  font-size: 0.9rem;
  padding: 0.25rem 0;
  color: var(--color-text);
  border-bottom: 1px dotted var(--color-border);
}

.above-list li:last-child {
  border-bottom: none;
}

/* Credits */
.credits {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Mobile */
@media (max-width: 768px) {
  .content-area {
    flex-direction: column;
  }

  .triangle-container {
    max-width: none;
  }

  .top-sections-row .factor-input,
  .factors-row .factor-input {
    min-width: 100%;
  }

  .triangle-item {
    cursor: default;
    pointer-events: none;
  }

  .items-layer {
    pointer-events: none;
  }
}

/* Print / PDF – A4 liggend, past op 1 pagina */
@media print {
  @page {
    size: A4 landscape;
    margin: 1cm;
  }

  html, body {
    margin: 0;
    padding: 0;
    background: white;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  body {
    display: flex;
    flex-direction: column;
    padding: 0.5cm;
  }

  .back,
  .input-panel,
  .credits,
  .header {
    display: none !important;
  }

  .content-area {
    flex: 1;
    max-width: none;
    margin: 0;
    padding: 0;
    gap: 0;
    page-break-inside: avoid;
    height: 18cm;
    max-height: 18cm;
    min-height: 0;
    align-items: stretch;
  }

  .content-left {
    flex: 2;
    min-width: 0;
    min-height: 0;
    padding-right: 0;
  }

  .view-name {
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
  }

  .triangle-container {
    max-width: none;
    max-height: 16cm;
    min-width: 0;
  }

  .sections-sidebar {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
    padding-left: 1rem;
    border-left: 1px solid #d4d8dc;
    margin-left: 1rem;
  }

  .above-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .above-section h4 {
    color: #333;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
  }

  .above-list {
    font-size: 0.8rem;
    flex: 1;
    min-height: 0;
  }

  .above-list li {
    border-bottom-color: #ccc;
    padding: 0.15rem 0;
  }
}
