/* ══════════════════════════════════════════════════════════════
   CV RENDERER - BASE STYLES
   Professional print-ready CV with dynamic pagination
   ══════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   GLOBAL RESET & BASE STYLES
   ────────────────────────────────────────────────────────────── */

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

:root {
  /* Color palette (defaults - can be overridden by templates) */
  --ink: #222;
  --muted: #666;
  --rule: #d9d9d9;
  --bg: #fff;
  --accent: #7c5cff;
  --accent-light: #a88aff;
  --border-color: #d1d5db;

  /* A4 dimensions (210mm × 297mm) */
  --page-width: 210mm;
  --page-height: 297mm;

  /* Layout measurements */
  --bleed: 3mm;
  --content-padding: 12mm;
  --sidebar-width: 65mm;

  /* Typography */
  --font-body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-heading: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
                  Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: #f3f4f6;
  line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────
   TOOLBAR (Screen only)
   ────────────────────────────────────────────────────────────── */

.toolbar {
  background: white;
  padding: 16px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cv-label {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.cv-selector {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.cv-selector:hover {
  border-color: #9ca3af;
}

.cv-selector:focus {
  outline: none;
  border-color: #7c5cff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.1);
}

.btn-primary,
.btn-secondary {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: #7c5cff;
  color: white;
}

.btn-primary:hover {
  background: #6a49e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.3);
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* ──────────────────────────────────────────────────────────────
   PAGE CONTAINER
   ────────────────────────────────────────────────────────────── */

#pages-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

/* ──────────────────────────────────────────────────────────────
   PAGE STRUCTURE
   ────────────────────────────────────────────────────────────── */

.page {
  width: var(--page-width);
  height: var(--page-height);
  background: var(--bg);
  position: relative;
  margin: 0 auto 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  padding: 0;
}

/* Bleed area (extends beyond page edges for safe printing) */
.bleed {
  position: absolute;
  top: calc(-1 * var(--bleed));
  left: calc(-1 * var(--bleed));
  right: calc(-1 * var(--bleed));
  bottom: calc(-1 * var(--bleed));
  pointer-events: none;
}

/* Content frame (sidebar + main area) */
.content-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

/* ──────────────────────────────────────────────────────────────
   SIDEBAR
   ────────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--accent);
  color: white;
  overflow: hidden;
  padding: var(--content-padding);
  position: relative;
}

.sidebar h1 {
  font-family: var(--font-heading);
  font-size: 18pt;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.1;
}

.sidebar .role {
  font-size: 11pt;
  font-weight: 500;
  opacity: 0.9;
  margin-bottom: 12px;
}

.sidebar .summary {
  font-size: 9pt;
  line-height: 1.4;
  opacity: 0.9;
  margin-bottom: 16px;
}

.sidebar section {
  margin-bottom: 16px;
}

.sidebar h3 {
  font-size: 9pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  opacity: 0.8;
}

.sidebar p {
  font-size: 9pt;
  line-height: 1.4;
  margin-bottom: 4px;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li {
  font-size: 9pt;
  line-height: 1.4;
  margin-bottom: 4px;
}

.sidebar a {
  color: white;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  transition: border-color 0.2s;
}

.sidebar a:hover {
  border-bottom-color: white;
}

.sidebar .skill-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 8pt;
  font-weight: 400;
  margin: 0 4px 4px 0;
}

.profile-photo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 16px;
  display: block;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

/* Continuation page sidebar (minimal) */
.sidebar-continued {
  padding: var(--content-padding);
}

/* ──────────────────────────────────────────────────────────────
   MAIN CONTENT AREA
   ────────────────────────────────────────────────────────────── */

.main {
  padding: var(--content-padding);
  overflow: hidden;
  height: 100%;
}

.main section {
  margin-bottom: 18px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.main h2 {
  font-family: var(--font-heading);
  font-size: 14pt;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--accent);
}

/* Entry (experience, projects) */
.entry {
  margin-bottom: 12px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
  gap: 12px;
}

.entry-title {
  font-size: 11pt;
  font-weight: 700;
  color: var(--ink);
}

.entry-company {
  font-size: 10pt;
  font-weight: 500;
  color: var(--accent);
}

.entry-date {
  font-size: 9pt;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.entry ul {
  list-style: disc;
  margin-left: 18px;
  margin-top: 4px;
}

.entry li {
  font-size: 9pt;
  line-height: 1.4;
  margin-bottom: 3px;
  color: var(--ink);
}

/* Education entries */
.edu-entry {
  margin-bottom: 8px;
}

.edu-entry h4 {
  font-size: 10pt;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.edu-entry p {
  font-size: 9pt;
  color: var(--muted);
  line-height: 1.4;
}

/* Skills grid */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.skill-group {
  margin-bottom: 6px;
}

.skill-group h4 {
  font-size: 9pt;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
}

.skill-group p {
  font-size: 9pt;
  color: var(--ink);
  line-height: 1.4;
}

/* Certifications list */
.cert-list {
  list-style: disc;
  margin-left: 18px;
}

.cert-list li {
  font-size: 9pt;
  line-height: 1.4;
  margin-bottom: 3px;
  color: var(--ink);
}

/* ──────────────────────────────────────────────────────────────
   PRINT STYLES
   ────────────────────────────────────────────────────────────── */

@media print {
  /* Remove browser default margins */
  html, body {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Hide toolbar when printing */
  .toolbar {
    display: none !important;
  }

  /* Reset page container */
  #pages-container {
    display: block !important;
    max-width: none !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Page setup - A4 with no margins */
  @page {
    size: A4 portrait;
    margin: 0;
  }

  /* Hide bleed area in print to prevent overflow */
  .bleed {
    display: none !important;
  }

  /* Page sizing for print - full A4 size */
  .page {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    box-shadow: none !important;
    page-break-after: always;
    page-break-inside: avoid;
    display: block !important;
    position: relative !important;
  }

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

  /* Content frame should fill the entire page */
  .content-frame {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* Normal padding for content areas */
  .sidebar {
    padding: var(--content-padding) !important;
  }

  .main {
    padding: var(--content-padding) !important;
  }

  /* Ensure content doesn't break across pages */
  .entry,
  .edu-entry,
  .skill-group {
    page-break-inside: avoid;
  }

  /* Print colors - force all colors to print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: white;
  }

  .sidebar,
  .content-frame,
  .bleed {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ──────────────────────────────────────────────────────────────
   RESPONSIVE (Screen only)
   ────────────────────────────────────────────────────────────── */

@media screen and (max-width: 1024px) {
  #pages-container {
    padding: 12px;
  }

  .page {
    transform: scale(0.8);
    transform-origin: top center;
    margin-bottom: 20px;
  }
}

@media screen and (max-width: 768px) {
  .page {
    transform: scale(0.6);
  }

  .toolbar {
    padding: 12px;
  }

  .toolbar-left {
    width: 100%;
  }

  .cv-selector {
    width: 100%;
  }
}
