/* App */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --page-bg: #e8eaed;
  --accent: #1e3a5f;
  --font-ui: "Segoe UI", system-ui, sans-serif;
  --cv-date-width: 7.6rem;
  --cv-section-gap: 2.25rem;
  --cv-head-gap: 3.2rem;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--page-bg);
  min-height: 100vh;
  overflow: hidden;
}

/* PDF-Viewer-Vorschau */
.viewer {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.viewer-viewport {
  flex: 1;
  overflow: auto;
  overscroll-behavior: none;
  touch-action: none;
  background: #9aa0a8;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.viewer-viewport.is-panning {
  cursor: grabbing;
}

.viewer-stage {
  --viewer-zoom: 1;
  zoom: var(--viewer-zoom);
  width: fit-content;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 5rem;
}

.preview-wrap {
  background: #b0b5be;
  padding: 1.25rem;
  border-radius: 6px;
}

#cv-preview {
  margin: 0 auto;
}

/* Pull-to-refresh: Symbol oben mittig */
.reload-indicator {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 200;
  width: 3.25rem;
  height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 0) scale(0.9);
}

.reload-indicator.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.reload-indicator.is-visible svg {
  display: block;
  animation: reload-spin 0.9s linear infinite;
}

@keyframes reload-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Download FAB unten rechts */
.fab-download {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 100;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30, 58, 95, 0.35);
  transition: transform 0.15s, opacity 0.15s;
}

.fab-download:hover:not(:disabled) {
  transform: scale(1.06);
}

.fab-download:disabled {
  cursor: wait;
  opacity: 0.6;
}

.fab-download.is-loading {
  opacity: 0.55;
}

/* PDF-Export: beide Seiten */
.cv-print-root {
  width: 210mm;
  margin: 0 auto;
}

/* Eine DIN-A4-Seite */
.cv-document {
  background: #fff;
  color: #000;
  width: 210mm;
  margin: 0 auto;
  padding: 20mm 22mm 22mm;
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  line-height: 1.45;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}

/* Vorschau im Browser: volle A4-Höhe + Abstand zwischen Blättern */
@media screen {
  .cv-document {
    min-height: 297mm;
  }

  .cv-document--page2 {
    margin-top: 1.25rem;
  }
}

/* PDF-Export: nur Inhaltshöhe, kein Extra-Abstand */
.cv-print-root.is-pdf-export .cv-document {
  min-height: auto !important;
  box-shadow: none !important;
}

.cv-print-root.is-pdf-export .cv-document--page2 {
  margin-top: 0 !important;
}

.cv-document h2,
.cv-document h3 {
  margin: 0;
  font-weight: 700;
  color: #000;
}

/* Kopf */
.cv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: var(--cv-head-gap);
}

.cv-head-title {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 42%;
  padding-top: 0.15rem;
}

.cv-doc-label {
  margin: 0 0 0.5rem;
  font-size: 13pt;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.cv-applicant {
  margin: 0;
  font-size: 15pt;
  font-weight: 700;
  line-height: 1.3;
}

.cv-birth {
  margin: 0.45rem 0 0;
  font-size: 10.5pt;
  line-height: 1.35;
  color: #333;
}

.cv-contact-box {
  flex: 0 0 auto;
  width: max-content;
  max-width: 58%;
  margin: -0.85rem 0 0 auto;
  padding: 1.05rem 1.15rem;
  background: #f7f7f7;
  border: 0.75pt solid #bbb;
  font-size: 10.5pt;
  line-height: 1.45;
}

.cv-contact-box-title {
  margin: 0 0 0.65rem;
  font-size: 10pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #333;
  border-bottom: 0.5pt solid #ccc;
  padding-bottom: 0.4rem;
}

.cv-contact-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.cv-contact-item {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 0.65rem;
  align-items: baseline;
}

.cv-contact-item dt {
  margin: 0;
  font-weight: 400;
  color: #444;
  font-size: 10pt;
}

.cv-contact-item dd {
  margin: 0;
  white-space: nowrap;
}

/* Abschnitte */
.cv-section {
  margin-top: var(--cv-section-gap);
}

.cv-head + .cv-section {
  margin-top: 0;
}

.cv-section h2 {
  font-size: 12pt;
  font-weight: 700;
  margin: 0 0 1.1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1.25pt solid #000;
  line-height: 1.3;
}

.cv-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.cv-row {
  display: grid;
  grid-template-columns: var(--cv-date-width) 1fr;
  column-gap: 1.4rem;
  align-items: start;
}

.cv-date {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10.5pt;
  line-height: 1.45;
  color: #222;
  padding-top: 0.1rem;
}

.cv-date--range {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  line-height: 1.3;
}

.cv-date-from,
.cv-date-to {
  display: block;
}

.cv-line-main {
  margin: 0;
  font-weight: 700;
  font-size: 11pt;
  line-height: 1.4;
}

.cv-line-sub {
  margin: 0.3rem 0 0;
  font-size: 11pt;
  line-height: 1.45;
}

.cv-line-detail {
  margin: 0.25rem 0 0;
  font-size: 10.5pt;
  line-height: 1.45;
  color: #333;
}

.cv-tasks {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
  font-size: 11pt;
  line-height: 1.5;
}

.cv-tasks li {
  margin-bottom: 0.35rem;
}

.cv-tasks li:last-child {
  margin-bottom: 0;
}

.cv-skills {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  font-size: 11pt;
  line-height: 1.5;
}

.cv-skill-block h3 {
  font-size: 11pt;
  font-weight: 700;
  margin: 0 0 0.45rem;
}

.cv-skill-block p {
  margin: 0;
}

.cv-skill-row {
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  column-gap: 1rem;
  margin-bottom: 0.4rem;
}

.cv-skill-row:last-child {
  margin-bottom: 0;
}

.cv-skill-label {
  font-weight: 700;
}

@media print {
  body * {
    visibility: hidden;
  }

  .cv-print-root,
  .cv-print-root * {
    visibility: visible;
  }

  .cv-print-root {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
  }

  .cv-document {
    box-shadow: none;
    margin-top: 0;
  }

  .cv-document--page2 {
    break-before: page;
    page-break-before: always;
  }

  .cv-contact-box {
    background: #f7f7f7 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media (max-width: 720px) {
  .viewer-stage {
    padding: 1rem 1rem 4.5rem;
  }

  .fab-download {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .cv-print-root,
  .cv-document {
    width: 210mm;
    min-width: 210mm;
  }
}
