:root {
  --primary-color: #2c3e50;
  --accent-color: #3498db;
  --text-color: #333;
  --light-gray: #f4f7f6;
  --border-color: #e0e0e0;
}

/* Print page setup: use @page margins so every page has identical insets */
@page {
  size: A4;
  margin: 12mm;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: #fff;
  max-width: 210mm; /* A4 width */
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 20px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-left h1 {
  font-size: 2.5rem;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
}

.header-left h2 {
  font-size: 1.2rem;
  color: var(--accent-color);
  font-weight: 500;
}

.header-right {
  text-align: right;
  font-size: 0.9rem;
}

.header-right p {
  margin-bottom: 3px;
}

.header-right a {
  color: var(--text-color);
  text-decoration: none;
}

/* Layout */
.container {
  display: grid;
  grid-template-columns: 2fr 1fr; /* Main content vs Sidebar */
  gap: 40px;
}

/* Section Styling */
section {
  margin-bottom: 25px;
}

h3 {
  font-size: 1.1rem;
  color: var(--primary-color);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 5px;
  margin-bottom: 15px;
  letter-spacing: 0.5px;
}

/* Experience Items */
.job {
  margin-bottom: 20px;
}

.job-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.job-title {
  font-weight: 700;
  color: #000;
}

.company {
  font-style: italic;
  color: #555;
}

.dates {
  font-size: 0.9rem;
  color: #666;
  min-width: 120px;
  text-align: right;
}

.job ul {
  list-style-type: none;
  padding-left: 0;
}

.job ul li {
  position: relative;
  padding-left: 15px;
  margin-bottom: 5px;
  font-size: 0.95rem;
}

.job ul li::before {
  content: "•";
  color: var(--accent-color);
  position: absolute;
  left: 0;
  font-weight: bold;
}

/* Sidebar items */
.skill-category {
  margin-bottom: 15px;
}

.skill-category h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: #444;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  background: var(--light-gray);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.85rem;
  border: 1px solid #ddd;
}

.interest-item {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

/* Summary */
.summary {
  margin-bottom: 30px;
  font-size: 1rem;
  color: #444;
  text-align: justify;
}

/* Helpers extracted from inline styles */
.job-title-small { font-size: 0.95rem; }
.education-details { font-size: 0.85rem; color: #666; margin-top: 5px; }
.languages-list { list-style: none; font-size: 0.9rem; padding-left: 0; }
.section-spacer-top { margin-top: 25px; }
.interest-spaced { margin-top: 10px; }

/* Print Optimization */
@media print {
  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    height: auto;
  }
  body {
    margin: 0;           /* margins provided by @page */
    padding: 0;          /* avoid compounded/uneven margins on subsequent pages */
    max-width: 100%;
    background: #fff;
    height: auto;
    font-size: 0.97em;   /* slightly tighter text for better fit */
    line-height: 1.45;
  }

  header,
  .summary,
  .job,
  .skill-category,
  .languages-list {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  a {
    text-decoration: none;
    color: #000;
  }
  .container {
    display: block; /* Stack columns to reduce awkward splits */
  }
  /* Avoid breaking job descriptions across pages */
  .job {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 16px;
  }
  .job ul li { margin-bottom: 3px; }
  /* Keep individual interest items intact but allow the Interests section to split */
  .interest-item {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 6px;
  }
  .interest-spaced { margin-top: 6px; }
  .section-spacer-top { margin-top: 8px; }
  
  /* Utilities for manual page control if needed in HTML */
  .page-break { break-before: page; page-break-before: always; }
  .avoid-break { break-inside: avoid; page-break-inside: avoid; }
  /* Trim bottom spacing to help prevent a trailing blank page */
  .job:last-child,
  .skill-category:last-child,
  .interest-item:last-child,
  aside > :last-child,
  main > :last-child {
    margin-bottom: 0;
  }
  h3 {
    page-break-after: avoid;
    break-after: avoid;
    margin-bottom: 8px;
  }

  /* Reduce visual noise specific to print */
  .header-right a {
    color: #000;
  }

  /* Tighten vertical rhythm in print to fit more content per page */
  header { margin-bottom: 20px; padding-bottom: 10px; }
  .summary { margin-bottom: 20px; }
  .skill-category { margin-bottom: 8px; }
  .tags { gap: 3px; }
  .tag { padding: 1px 6px; font-size: 0.8rem; }
  main h3, aside h3 { margin-top: 6px; }
}
