/**
 * PrintDialog v2 — 3-Spalten Druckdialog
 * @version 1.0.0
 */

/* ═══════════════════════════════════════════════════════════════════
   OVERLAY & DIALOG CONTAINER
   ═══════════════════════════════════════════════════════════════════ */

.print2-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10030;
  backdrop-filter: blur(2px);
  animation: print2FadeIn 0.2s ease-out;
}

.print2-dialog {
  background: var(--color-bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 92%;
  max-width: 1080px;
  min-height: 640px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: print2SlideUp 0.25s ease-out;
}

/* ═══════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════ */

.print2-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border-primary);
  flex-shrink: 0;
}

.print2-dialog-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.print2-dialog-title-label {
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-md);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.print2-dialog-close {
  background: none;
  border: none;
  font-size: var(--font-size-3xl);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  line-height: var(--line-height-tight);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.print2-dialog-close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-tertiary);
}

/* ═══════════════════════════════════════════════════════════════════
   BODY — THREE-COLUMN LAYOUT
   ═══════════════════════════════════════════════════════════════════ */

.print2-dialog-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --- LEFT SIDEBAR: Engines + Formats --- */

.print2-sidebar-left {
  width: 170px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px;
}

.print2-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.print2-sidebar-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps);
  color: var(--color-text-tertiary);
  padding: 8px 10px 4px;
}

.print2-sidebar-divider {
  height: 1px;
  background: var(--color-border-primary);
  margin: 8px 4px;
}

.print2-engine-option,
.print2-format-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
}

.print2-engine-option:hover,
.print2-format-option:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.print2-engine-option.active,
.print2-format-option.active {
  background: var(--color-bg-tertiary);
  border-color: var(--color-primary);
  color: var(--color-text-primary);
}

.print2-option-icon {
  font-size: var(--font-size-xl);
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.print2-option-info {
  flex: 1;
  min-width: 0;
}

.print2-option-name {
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-ui);
}

.print2-option-ext {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  font-family: var(--font-family-mono);
  margin-left: 4px;
}

/* --- CENTER: Preview Area --- */

.print2-preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.print2-preview-container {
  flex: 1;
  min-height: 320px;
  padding: 16px;
  overflow: hidden;
  position: relative;
  background: var(--color-bg-secondary);
  display: flex;
  flex-direction: column;
}

.print2-preview-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  border-radius: var(--radius-md);
  background: #ffffff;
}

.print2-preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 200px;
  gap: 12px;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-md);
}

.print2-preview-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border-primary);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: print2Spin 0.8s linear infinite;
}

.print2-preview-fallback,
.print2-preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 200px;
  gap: 8px;
  font-size: var(--font-size-md);
  text-align: center;
}

.print2-preview-fallback {
  color: var(--color-text-tertiary);
}

.print2-preview-error {
  color: var(--color-error);
}

/* --- RIGHT SIDEBAR: Options --- */

.print2-sidebar-right {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.print2-sidebar-right::-webkit-scrollbar {
  display: none;
}
.print2-sidebar-right * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.print2-sidebar-right *::-webkit-scrollbar {
  display: none;
}

.print2-options-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border-primary);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.print2-options-tabs::-webkit-scrollbar {
  display: none;
}

.print2-options-tab {
  flex: 1;
  padding: 8px 10px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-tertiary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.print2-options-tab:hover {
  color: var(--color-text-secondary);
}

.print2-options-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.print2-options-panel {
  display: none;
  padding: 12px;
  flex-direction: column;
  gap: 10px;
}

/* ⛔ DER AKTIVE REITER ROLLT (28.09.2026, Aufgabenkarten). Die Seitenleiste
   schneidet ab (overflow: hidden) — ein Anbieter-Reiter mit vielen Feldern lief
   unten hinaus und war nicht erreichbar. Gemessen: der Reiter «Aufgabenkarten»
   rund 1675 px in einer 633 px hohen Seitenleiste; «Spalten», «Bogen», «Name»
   und «Als Kartentyp speichern» lagen ausser Reichweite. Der Reiter nimmt jetzt
   den Rest der Leiste und rollt selbst; die Reiterzeile bleibt stehen.
   ⚠ Die Kinder schrumpfen nicht: eine Trennlinie (1 px, ohne Inhalt) fiele in
   einem überlaufenden Flex-Behälter sonst auf 0 px zusammen. */
.print2-options-panel.active {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.print2-options-panel.active > * {
  flex-shrink: 0;
}
/* ⛔ … UND ZEIGT SEINE LEISTE (28.09.2026, Befund der Durchsicht, Runde 2). Die Regeln
   oben blenden in der Seitenleiste jede Bildlaufleiste aus — auch die des rollenden
   Reiters. Gemessen im Reiter «Aufgabenkarten»: 2171 px Inhalt, 602 px sichtbar, und
   nichts zeigte, dass es unter dem Rand weitergeht; ohne Mausrad war der Rest
   unerreichbar. Der Reiter bekommt eine schmale Leiste in den Farben des Portals
   (wie #content-area in styles.css), die Reiterzeile bleibt ohne. */
.print2-sidebar-right .print2-options-panel.active {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-primary) transparent;
}
.print2-sidebar-right .print2-options-panel.active::-webkit-scrollbar {
  display: block;
  width: 6px;
}
.print2-sidebar-right .print2-options-panel.active::-webkit-scrollbar-track {
  background: transparent;
}
.print2-sidebar-right .print2-options-panel.active::-webkit-scrollbar-thumb {
  background: var(--color-border-primary);
  border-radius: 3px;
}

.print2-setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.print2-setting-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

.print2-setting-select,
.print2-setting-input {
  appearance: none;
  -webkit-appearance: none;
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: border-color 0.15s ease;
  width: 100%;
}

.print2-setting-select {
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%239ca3af'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.print2-setting-select:hover,
.print2-setting-input:hover {
  border-color: var(--color-primary);
}

.print2-setting-select:focus,
.print2-setting-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* Checkbox & Radio */

.print2-checkbox-label,
.print2-radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 2px 0;
}

.print2-checkbox-label input,
.print2-radio-label input {
  accent-color: var(--color-primary);
  cursor: pointer;
}

.print2-radio-group {
  gap: 2px;
}

.print2-setting-heading {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-tertiary);
  padding: 4px 0 2px;
  margin-top: 4px;
}

/* Zwischenzeile unter einer Überschrift (Feldtyp 'heading' mit stufe: 2, 28.09.2026):
   klein und ruhig, wie die Feldgruppen im Prototyp der Aufgabenkarten — weder
   Überschrift (Versalien) noch Erklärsatz (grösser). */
.print2-setting-subheading {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-tertiary);
  padding: 2px 0 0;
}

/* Erklärender Hinweis eines OptionProviders (Feldtyp 'info') — kein Eingabefeld,
   sondern Fliesstext, der z.B. begründet, warum eine Liste leer ist. */
.print2-setting-info {
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-secondary);
  padding: 4px 0;
}

.print2-setting-separator {
  height: 1px;
  background: var(--color-border-primary);
  margin: 6px 0;
}

.print2-no-options {
  font-size: var(--font-size-base);
  color: var(--color-text-tertiary);
  text-align: center;
  padding: 20px 12px;
}

/* ═══════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════ */

.print2-dialog-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-primary);
  flex-shrink: 0;
}

.print2-btn {
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.print2-btn-cancel {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: var(--color-border-primary);
}

.print2-btn-cancel:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.print2-btn-print {
  background: var(--color-primary);
  color: #ffffff;
  font-weight: var(--font-weight-semibold);
}

.print2-btn-print:hover {
  filter: brightness(1.1);
}

.print2-btn-print:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.print2-btn-export {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border-color: var(--color-primary);
  font-weight: var(--font-weight-semibold);
}

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

.print2-btn-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

/* ═══════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════ */

@keyframes print2FadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes print2SlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .print2-dialog {
    width: 96%;
    max-height: 95vh;
    max-width: none;
  }

  .print2-dialog-body {
    flex-direction: column;
  }

  .print2-sidebar-left {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--color-border-primary);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    gap: 4px;
  }

  .print2-sidebar-left .print2-sidebar-section {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .print2-sidebar-label {
    display: none;
  }

  .print2-sidebar-divider {
    display: none;
  }

  .print2-engine-option,
  .print2-format-option {
    flex: 0 0 auto;
    padding: 6px 10px;
  }

  .print2-preview-container {
    min-height: 200px;
  }

  .print2-sidebar-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border-primary);
    max-height: 200px;
  }
}

/* ── PDF-VIEWER-EBENE (10.08.2026) ─────────────────────────────────────────
   Das fertige PDF erscheint IM Portal statt in einem neuen Tab (Markus:
   «kein sauberer Druckdialog … sondern irgendeine Browserseite»). Liegt über
   dem Druckdialog (z-index 10030 + 10), volle Fläche, Kopf mit den drei
   Handgriffen. Der Viewer selbst kommt vom Browser (iframe). */
.print2-pdfviewer {
  position: fixed; inset: 0; z-index: 10040;
  display: flex; flex-direction: column;
  background: var(--color-bg-primary);
}
.print2-pdfviewer-kopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--color-border-primary);
  background: var(--color-bg-secondary);
}
.print2-pdfviewer-titel {
  font-size: var(--font-size-md); font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.print2-pdfviewer-aktionen { display: flex; gap: var(--spacing-sm); flex: 0 0 auto; }
.print2-pdfviewer-frame { flex: 1; border: none; width: 100%; }

/* ═══ SCHNITT-BEFUNDE (W2, Satzgeometrie-Vertrag, 30.08.2026) ══════════════
   Der Rasterdruck zerteilt an der Seitenkante — die Leiste macht den Riss zum
   Befund VOR dem Druck. Warnton, nicht Fehlerrot: das Dokument ist druckbar,
   es verliert nur Schoenheit. */
.print2-schnitt-befunde {
  padding: 6px 12px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--color-warning);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-primary);
}

/* Ehrliches Gate: Vollbogen ohne A4-Hochformat — die flache Ansicht sagt
   WARUM sie flach ist, statt wortlos anders auszusehen als der Druck. */
.print2-schnitt-hinweis {
  padding: 6px 12px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-primary);
}
