/* 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;
  --text-xs: 0.64rem;
  --text-sm: 0.8rem;
  --text-base: 1rem;
  --text-xl: 1.25rem;
}

* {
  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;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-right .btn {
  max-width: none;
}

/* Welcome modal */
.welcome-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-modal-content {
  max-width: 420px;
}

.welcome-modal-body {
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.welcome-modal-intro {
  margin: 0;
  font-size: var(--text-base);
  color: var(--color-text);
}

.welcome-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.welcome-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  text-align: left;
}

.welcome-btn-icon {
  font-size: var(--text-xl);
}

.welcome-btn-label {
  font-weight: 600;
  font-size: var(--text-base);
}

.welcome-btn-desc {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 400;
}

.welcome-modal-secondary {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.welcome-autosaved-meta {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--text-xs);
  color: var(--color-text);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* Block modal overlay */
.block-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
}

.block-modal-overlay[hidden] {
  display: none;
}

.block-modal {
  background: #e8e6eb;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 20px 40px rgba(0,0,0,0.15);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.block-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: #e8e6eb;
}

.block-modal-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.block-modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.block-modal-body .form-section {
  margin-bottom: 0;
}

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

.block-modal-body .form-section input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  background: #fff;
}

.block-modal-body .welcome-modal-actions {
  flex-direction: row;
  flex-wrap: wrap;
}

/* 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);
}

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

.basisgegevens-input {
  width: 100%;
  max-width: 560px;
  min-height: 5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font-sans);
  resize: vertical;
  line-height: 1.4;
}

.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;
}

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

.basisgegevens-overlay {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  right: auto;
  max-width: 45%;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
  pointer-events: none;
}

.basisgegevens-overlay.basisgegevens-empty {
  display: none;
}

.basisgegevens-title {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}

.basisgegevens-text {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.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;
}

/* Print-only: Hypotheses op aparte A4 – verborgen op scherm */
.print-hypotheses-page {
  display: 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: normal;
  max-width: 220px;
  line-height: 1.3;
}

.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;
}

/* Hypotheses onder de content */
.hypotheses-below {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem 0 0;
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.hypotheses-below h4 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
}

.hypotheses-below .above-list {
  margin: 0;
  padding: 0;
}

/* 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%;
    min-height: auto;
  }

  body {
    display: block;
    padding: 0.5cm;
  }

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

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

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

  .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;
  }

  .hypotheses-below {
    display: none !important;
  }

  .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;
  }

  /* Hypotheses op aparte A4-pagina (na content-area met page-break-after) */
  .print-hypotheses-page {
    display: block !important;
    padding: 1rem 0;
    break-before: page;
    page-break-before: always;
  }

  .print-hypotheses-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 1rem;
  }

  .print-hypotheses-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 1rem;
    line-height: 1.6;
  }

  .print-hypotheses-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
    color: #333;
  }

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