/* Ensure job entries are not split between pages when printing */
cv-work-entry,
.cv-work-entry,
.work-entry,
.job-entry {
  break-inside: avoid;
  page-break-inside: avoid;
  /* For extra compatibility */
  display: block;
}

/* Print styles for PDF export */
@media print {

  /* Reduce top margin for first printed page */
  @page :first {
    /* margin-top: 0.75cm; */
  }

  /* Match .cv-header spacing to screen for print */
  .cv-header {
    margin: 0 auto;
    padding: 0;
  }

  /* Hide non-printable elements */
  .no-print,
  .controls-bar,
  .floating-controls {
    display: none !important;
  }

  /* Force light theme for printing */
  body {
    background: #fff !important;
    color: #333 !important;
    font-family: "SF Pro Display", "SF Pro Text", system-ui, -apple-system, "Segoe UI", "Ubuntu", "Cantarell", sans-serif;
    font-size: 10pt;
    line-height: 1.4;
    padding: 0;
    margin: 0;
  }

  hr {
    margin: 0.5cm 0;
  }

  /* A4 page setup */
  @page {
    size: A4;
    margin: 1.5cm 1cm;
  }

  /* Main container */
  .cv-container {
    max-width: 100%;
    margin: 0;
    box-shadow: none;
    display: grid;
    grid-template-columns: 35% 65%;
    min-height: auto;
    page-break-after: auto;
    background: #fff;
    padding-bottom: 0;
  }

  /* Left column */
  .left-column {
    text-align: right;
    padding: 0.5cm;
    border-right: 1px solid #ddd;
    border-bottom: 0;
  }

  /* Right column */
  .right-column {
    padding: 0.5cm;
  }

  .left-column,
  .right-column {
    padding-top: 0;
  }

  /* Photo section */
  .photo-section {
    margin-bottom: 1cm;
  }

  .profile-photo {
    max-width: 200px;
    max-height: 200px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Personal name heading */
  #cvName {
    font-size: 2rem;
  }

  section h2 {
    font-size: 12pt;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #333;
  }

  .contact-info a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
  }

  .contact-info a:hover {
    text-decoration: underline;
    color: #555;
  }

  .language-name {
    font-weight: 600;
    color: #333;
  }

  .language-level {
    color: #888;
    padding-bottom: 0.5rem;
  }

  .interests-section ul {
    list-style: none;
    padding: 0;
  }

  .interests-section li {
    padding: 0.2cm 0 0.2cm 1rem;
    position: relative;
  }

  .interests-section li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #333;
    font-weight: bold;
  }

  .signature-section {
    /* margin-top: 1cm; */
    /* padding-top: 0.5cm; */
    /* border-top: 1px solid #ddd; */
    text-align: center;
    color: #888;
  }

  /* Keep signature image same dimensions as on screen */
  .signature-image {
    width: 75% !important;
    /* height: 98px !important; */
    object-fit: contain;
    float: right;
    /* display: inline-block; */
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* CV header */
  .cv-header {
    margin-bottom: 0.6cm;
    text-align: center;
    page-break-after: avoid;
  }

  .cv-header h1 {
    font-size: 24pt;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #333;
    margin-bottom: 0.2cm;
  }

  .cv-subtitle {
    color: #555;
    font-weight: 400;
  }

  .intro-section,
  .work-section,
  .education-section,
  .skills-section {
    /* margin-bottom: 0.6cm; */
  }

  .intro-section h2,
  .work-section h2,
  .education-section h2,
  .skills-section h2 {
    font-size: 12pt;
    font-weight: 700;
    line-height: 1.75;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.4cm;
    color: #333;
    background: #bdbdbd;
    border-radius: 0;
    padding-left: 0.5cm;
    margin-left: -0.5cm;
    margin-right: -2.5rem;
    page-break-after: avoid;
  }

  .intro-section p {
    font-size: 9pt;
    line-height: 1.2;
    text-align: justify;
  }

  /* Work experience separators */
  cv-work-entry:not(:last-child) {
    border-bottom: 2px dotted #ddd;
    padding-bottom: 0.5rem;
    margin-bottom: 0 !important;
  }

  cv-work-entry:not(:first-child) {
    padding-top: 0.5rem;
  }

  /* Work entries spacing */
  cv-work-entry {
    padding: 0.5;
    margin-bottom: 0.5cm;
  }

  /* Education styles */
  .education-entry {
    margin-bottom: 0.5cm;
  }

  .education-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
  }

  .institution {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
  }

  .education-entry .period {
    color: #888;
    white-space: nowrap;
  }

  .degree {
    color: #888;
    margin: 0;
  }

  .degree-info {
    color: #555;
  }

  /* Skills section */
  .skill-category-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.75rem;
  }

  .skills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.2cm 0.5cm;
  }

  .skill-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }

  .skill-name {
    color: #555;
  }

  .tachometer-rating {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
  }

  .tacho-bar {
    display: inline-block;
    width: 6px;
    border-radius: 1px 1px 0 0;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .tacho-bar:nth-child(1) { height: 6px; }
  .tacho-bar:nth-child(2) { height: 8px; }
  .tacho-bar:nth-child(3) { height: 10px; }
  .tacho-bar:nth-child(4) { height: 13px; }
  .tacho-bar:nth-child(5) { height: 16px; }

  .tacho-bar.empty {
    background-color: transparent;
    border: 1px solid #e4e4e4;
  }

  /* Prevent page breaks inside elements */
  .work-entry,
  .education-entry,
  .skill-category,
  .personal-section,
  .languages-section,
  .interests-section {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Prevent orphaned lines */
  p,
  li {
    orphans: 3;
    widows: 3;
  }

  /* Ensure proper page breaks */
  .work-section,
  .education-section,
  .skills-section {
    page-break-before: auto;
  }

  /* Allow page break before skills if needed */
  .skills-section {
    page-break-before: auto;
  }
}