/* =============================================
   Anschreiben V5 – Premium Cover Letter CSS
   Navy + Copper – passend zu Lebenslauf V5
   Scope: .letter-premium-v5
   ============================================= */

.letter-premium-v5 {
  /* Farben (identisch mit Lebenslauf V5) */
  --navy: #2b3044;
  --copper: #b08968;
  --dark-text: #333333;
  --gray-text: #555555;
  --label-color: #999999;
  --white: #ffffff;
  --white-muted: rgba(255, 255, 255, 0.82);
  --white-faint: rgba(255, 255, 255, 0.5);
  --white-dim: rgba(255, 255, 255, 0.15);
  --white-ghost: rgba(255, 255, 255, 0.3);

  /* Maße */
  --page-width: 210mm;
  --page-height: 297mm;
  --sidebar-width: 75mm;

  /* Schrift */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-xxs: 9px;
  --font-size-xs: 11px;
  --font-size-sm: 11.5px;
  --font-size-base: 12px;
  --font-size-name: 40px;

  /* Abstände */
  --spacing-xs: 4px;
  --spacing-sm: 6px;
  --spacing-md: 10px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 40px;
}

/* ---- Scoped Reset ---- */
.letter-premium-v5 *,
.letter-premium-v5 *::before,
.letter-premium-v5 *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.letter-premium-v5 {
  font-family: var(--font-family);
  color: var(--dark-text);
  line-height: 1.5;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.letter-premium-v5 a {
  color: inherit;
  text-decoration: none;
}

/* =============================================
   Page
   ============================================= */
.lv5-page {
  width: var(--page-width);
  min-height: var(--page-height);
  margin: 32px auto;
  display: flex;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  overflow: visible;
}

.lv5-page--continuation {
  break-before: page;
  page-break-before: always;
}

/* =============================================
   Sidebar (Navy)
   ============================================= */
.lv5-sidebar,
.lv5-sidebar--minimal {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
}

.lv5-sidebar {
  padding: 40px 20px var(--spacing-lg);
}

.lv5-sidebar--minimal {
  padding: var(--spacing-lg) 20px;
}

.lv5-sidebar-title {
  font-size: var(--font-size-base);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.lv5-sidebar-section {
  margin-bottom: var(--spacing-xl);
}

/* Divider */
.lv5-divider {
  height: 1px;
  background: var(--white-dim);
  margin-bottom: var(--spacing-lg);
}

/* Contact Row */
.lv5-contact-row {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  min-width: 0;
}

.lv5-contact-icon {
  flex-shrink: 0;
  margin-top: 2px;
  width: 13px;
  height: 13px;
  color: var(--copper);
}

.lv5-contact-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lv5-contact-text,
.lv5-attachment-text {
  font-size: var(--font-size-xs);
  color: var(--white-muted);
  overflow-wrap: anywhere;
  word-wrap: break-word;
  hyphens: auto;
  min-width: 0;
}

/* Attachments */
.lv5-attachments {
  list-style: none;
  font-size: var(--font-size-xs);
  color: var(--white-muted);
}

.lv5-attachments li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: var(--spacing-sm);
}

.lv5-copper-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--copper);
  flex-shrink: 0;
  margin-top: 4px;
}

/* Spacer & Footer */
.lv5-sidebar-spacer {
  flex: 1;
}

.lv5-sidebar-footer {
  font-size: var(--font-size-xxs);
  color: var(--white-ghost);
  text-align: center;
}

/* =============================================
   Main Content
   ============================================= */
.lv5-main {
  flex: 1;
  min-width: 0;
  padding: 40px var(--spacing-xl) var(--spacing-lg);
  display: flex;
  flex-direction: column;
}

.lv5-header {
  margin-bottom: var(--spacing-xl);
}

.lv5-name-block {
  min-width: 0;
}

.lv5-name {
  font-size: var(--font-size-name);
  color: var(--navy);
  line-height: 1.08;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0;
  overflow-wrap: anywhere;
}

.lv5-jobtitle {
  font-size: var(--font-size-xs);
  color: var(--label-color);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: var(--spacing-sm);
  overflow-wrap: anywhere;
}

/* Recipient */
.lv5-recipient {
  font-size: var(--font-size-base);
  color: var(--dark-text);
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);
  font-style: normal;
}

.lv5-recipient p {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Date */
.lv5-date {
  font-size: var(--font-size-base);
  color: var(--label-color);
  text-align: right;
  margin-bottom: var(--spacing-lg);
  overflow-wrap: anywhere;
}

/* Reference */
.lv5-reference {
  font-size: var(--font-size-xs);
  color: var(--label-color);
  margin-bottom: var(--spacing-sm);
  overflow-wrap: anywhere;
}

/* Subject (Copper Pill) */
.lv5-subject-wrap {
  margin-bottom: var(--spacing-lg);
}

.lv5-subject-pill {
  display: inline-block;
  max-width: 100%;
  background: var(--copper);
  padding: 6px 12px;
  font-size: var(--font-size-base);
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 2px;
  overflow-wrap: anywhere;
}

/* Body */
.lv5-body {
  font-size: var(--font-size-sm);
  color: var(--gray-text);
  line-height: 1.8;
  flex: 1;
  min-width: 0;
}

.lv5-body p {
  margin-bottom: 16px;
  overflow-wrap: anywhere;
}

.lv5-body p:last-child {
  margin-bottom: 0;
}

/* Closing */
.lv5-closing {
  margin-top: var(--spacing-xl);
  font-size: var(--font-size-base);
  color: var(--dark-text);
}

.lv5-closing-formula {
  margin-bottom: 0;
}

.lv5-closing-name {
  margin-top: 40px;
  overflow-wrap: anywhere;
}

.lv5-closing--continuation {
  margin-top: var(--spacing-lg);
}

/* =============================================
   Page Rules
   ============================================= */
@page {
  size: A4 portrait;
  margin: 0;
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
  html,
  body {
    background: #fff !important;
  }

  .letter-premium-v5,
  .letter-premium-v5 * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .lv5-page {
    margin: 0;
    box-shadow: none;
    page-break-after: always;
    min-height: var(--page-height);
  }

  .lv5-page:last-child {
    page-break-after: auto;
  }
}

/* =============================================
   BewerbungsFix: PDF-Bundle
   ============================================= */
.letter-v5-bundle .letter-premium-v5 {
  background: #ffffff;
}

.letter-v5-bundle .lv5-page {
  margin: 0 auto !important;
  box-shadow: none !important;
  page-break-after: always;
  break-after: page;
  min-height: var(--page-height);
}

.letter-v5-bundle .lv5-page:last-child {
  page-break-after: auto;
  break-after: auto;
}

@media print {
  .letter-v5-bundle .lv5-page + .lv5-page {
    break-before: page;
    page-break-before: always;
  }
}

.cv-v1-bundle + .letter-v5-bundle,
.letter-v2-bundle + .letter-v5-bundle,
.letter-v3-bundle + .letter-v5-bundle,
.letter-v5-bundle + .letter-v5-bundle,
.letter-v5-bundle + section.pdf-sheet {
  page-break-before: always;
  break-before: page;
}

/* =============================================
   BewerbungsFix: Live-Vorschau (nur Seite 1)
   ============================================= */
.live-sheet.letter-v5-premium-active {
  aspect-ratio: 210 / 297;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.letter-premium-v5-mount {
  position: relative;
  z-index: 4;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
  container-type: size;
  container-name: letter-premium-v5-preview;
}

.letter-premium-v5-mount .letter-premium-v5 {
  background: #ffffff;
  width: max-content;
  margin: 0;
  transform-origin: center center;
  transform: scale(
    calc(min(calc(100cqw / 210mm), calc(100cqh / 297mm)) * 1.028)
  );
}

.letter-premium-v5-mount .lv5-page + .lv5-page {
  display: none !important;
}

.letter-premium-v5-mount .lv5-page {
  margin: 0 !important;
  box-shadow: none !important;
}

@supports not (container-type: size) {
  .letter-premium-v5-mount .letter-premium-v5 {
    transform: scale(0.411);
  }
}

.live-sheet.letter-v5-premium-active .live-sheet-lock {
  display: none;
}
