/* page.css – Seitenlayout Scriptbuilder (Preview + Print) */

/* ── MEASURE CONTAINER (off-screen, für Höhenmessung) ── */
#measure-container,
#measure-container-render {
  position: fixed;
  left: -9999px;
  top: 0;
  visibility: hidden;
  overflow: hidden;
  /* width, font-size, line-height, font-family per JS */
}

/* ── STRUKTUR-PANEL ── */
#struct-panel {
  width: var(--col-structure);
  min-width: var(--col-structure);
  flex-shrink: 0;
  transition: width 0.2s ease, min-width 0.2s ease;
}
#struct-panel.collapsed {
  width: 50px;
  min-width: 50px;
}

.struct-dirty-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--btn-orange);
  line-height: 1;
}

/* ── PAGES.HTML LAYOUT ── */
#pg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#pg-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pg-tool-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  margin-right: 6px;
}

#pg-structure-select {
  font-family: inherit;
  font-size: var(--text-micro);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
  min-width: 200px;
  max-width: 320px;
  cursor: pointer;
  outline: none;
}
#pg-structure-select:focus { border-color: var(--btn-blue); }

.pg-status {
  font-size: 11px;
  color: var(--text-sec);
  padding: 4px 10px;
  background: var(--border);
  border-radius: 10px;
  white-space: nowrap;
}
.pg-status.rendering { color: var(--btn-orange); }
.pg-status.done      { color: var(--btn-green); }
.pg-status.error     { color: var(--btn-red); }
.pg-status.dirty     { color: var(--btn-orange); }

#pg-settings {
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  max-height: 0;
  transition: max-height 0.3s ease;
}
#pg-settings.open {
  max-height: 1200px;
  overflow-y: auto;
}
#pg-settings::-webkit-scrollbar { width: 4px; }
#pg-settings::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.settings-inner {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sec);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.settings-sub-label {
  font-size: 11px;
  color: var(--text-sec);
  margin-top: 4px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-field label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-sec);
  white-space: nowrap;
}

.settings-field input[type="number"] {
  width: 70px;
  font-size: 13px;
  padding: 4px 8px;
  height: 30px;
}

.settings-field input[type="text"] {
  font-size: 13px;
  padding: 4px 8px;
  height: 30px;
}

.settings-field.wide input[type="text"] { width: 280px; }
.settings-field.mid  input[type="text"] { width: 160px; }
.settings-field.full { width: 100%; }
.settings-field.full input[type="text"] { width: 100%; }

.settings-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin-top: 6px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ── PAGE PREVIEW ── */
#page-preview {
  flex: 1;
  overflow-y: auto;
  background: #b0b3b8;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-content: flex-start;
}
#page-preview::-webkit-scrollbar { width: 6px; }
#page-preview::-webkit-scrollbar-thumb { background: #888; border-radius: 3px; }

.pg-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #666;
  width: 100%;
  padding: 60px 0;
}
.pg-empty-state i { color: #999; }

/* ── THUMBNAIL WRAPPER ── */
.page-thumb {
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  background: #fff;
  flex-shrink: 0;
  transition: box-shadow 0.15s, transform 0.15s;
}
.page-thumb:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transform: translateY(-1px);
}
.page-thumb .pg-page { pointer-events: none; }

.thumb-page-num {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 9px;
  color: rgba(0,0,0,0.4);
  font-family: -apple-system, sans-serif;
  pointer-events: none;
}

/* ── VOLLANSICHT MODAL ── */
#page-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 20px;
}
#page-modal.open { display: flex; }

#page-modal-close {
  position: fixed;
  top: 14px;
  right: 16px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 18px;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#page-modal-close:hover { background: rgba(0,0,0,0.9); }

/* ── DIE SEITE SELBST ── */
/* Padding, font etc. wird per inline-style (JS) gesetzt */
.pg-page {
  width: 210mm;
  height: 297mm;
  background: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  box-sizing: border-box;
}

.pg-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.pg-footer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  padding-bottom: 1mm;
  border-top: 0.5pt solid #ccc;
  font-size: 8pt;
  color: #666;
  font-family: Georgia, 'Times New Roman', serif;
}
.pg-footer-inner { flex: 1; }
.pg-footer-outer { text-align: right; }

/* ── STRUKTUR-HEADER-SEITE ── */
.pg-struct-header {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 55%;
  padding-bottom: 8mm;
  border-bottom: 1pt solid #555;
  margin-bottom: 6mm;
}
.pg-struct-path {
  color: #888;
  line-height: 1.4;
  margin-bottom: 4mm;
}
.pg-struct-label {
  color: #666;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2mm;
}
.pg-struct-title {
  font-weight: 700;
  line-height: 1.2;
  color: #111;
}

/* ── NODE HEADER ── */
.pg-node-header {
  padding-bottom: 1.5mm;
  margin-bottom: 2mm;
  border-bottom: 0.5pt solid #bbb;
}
.pg-node-title {
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5mm;
}
.pg-node-path {
  color: #888;
  line-height: 1.35;
}

/* ── ZWISCHENÜBERSCHRIFT ── */
.pg-section-heading {
  margin: 2.5mm 0 1mm;
  padding-bottom: 0.5mm;
  border-bottom: 0.3pt solid #ddd;
}
.pg-section-title { font-weight: 600; line-height: 1.3; }
.pg-section-path  { color: #aaa; line-height: 1.3; margin-top: 0.3mm; }

/* ── BLOCK ── */
.pg-block {
  display: flex;
  word-break: break-word;
  hyphens: auto;
  margin-bottom: 1.5mm;
}
.pg-block-aspect {
  flex-shrink: 0;
  color: #777;
  word-break: break-word;
  hyphens: auto;
  padding-right: 0;
  line-height: 1.35;
}
.pg-block-content {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  hyphens: auto;
}

/* ── PRINT ── */
@media print {
  body > * { display: none !important; }
  #print-pages { display: block !important; }
  .pg-page { page-break-after: always; box-shadow: none !important; }
  .pg-page:last-child { page-break-after: auto; }
}

@page { size: 210mm 297mm; margin: 0; }

#print-pages { display: none; }
