/* ===== CV Builder Page (English / LTR) ===== */
.cv-builder-body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}
.cv-builder-body .page-hero h1,
.cv-builder-body .page-hero p {
  text-align: center;
}
.cv-builder-body .nav-links {
  text-align: left;
}

.cv-builder-page {
  padding: 24px 0 60px;
  background: var(--bg-light);
  min-height: 60vh;
}
.cv-builder-intro {
  text-align: center;
  margin-bottom: 24px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.cv-builder-intro h2 {
  margin: 0 0 8px 0;
  font-size: 1.5rem;
}
.cv-builder-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.cv-builder-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 24px;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.cv-form-panel {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.cv-form-panel h3 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  text-align: left;
}
.cv-export-hint {
  margin: 12px 0 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
  text-align: left;
}

.template-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.template-picker label {
  cursor: pointer;
  display: block;
}
.template-picker input { position: absolute; opacity: 0; pointer-events: none; }
.template-picker span {
  display: block;
  padding: 10px 8px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, background 0.2s;
}
.template-picker input:checked + span {
  border-color: var(--primary);
  background: rgba(196, 30, 58, 0.08);
  color: var(--primary);
}

.cv-form .field {
  margin-bottom: 14px;
}
.cv-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
  text-align: left;
}
.cv-builder-body .template-picker span {
  text-align: center;
}
.cv-form input[type="text"],
.cv-form input[type="email"],
.cv-form input[type="tel"],
.cv-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}
.cv-form textarea {
  min-height: 80px;
  resize: vertical;
}

/* Repeatable blocks (experience, education, skills, languages) */
.repeatable-section {
  margin-bottom: 18px;
}
.repeatable-section > .field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.repeatable-section > .field-label-row label {
  margin-bottom: 0;
}
.repeatable-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.repeatable-item {
  position: relative;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-light, #f8f9fa);
}
.repeatable-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.repeatable-item-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.btn-remove-item {
  padding: 4px 10px;
  font-size: 0.8rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #666;
  cursor: pointer;
}
.btn-remove-item:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-remove-item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.repeatable-item .exp-title,
.repeatable-item .exp-org,
.repeatable-item .exp-dates,
.repeatable-item .edu-degree,
.repeatable-item .edu-school,
.repeatable-item .edu-year {
  margin-bottom: 8px;
}
.repeatable-item .edu-note {
  min-height: 64px;
  margin-bottom: 0;
}
.repeatable-item .exp-desc {
  margin-bottom: 0;
  min-height: 72px;
}
.repeatable-item .repeatable-item--lang {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 400px) {
  .repeatable-item .repeatable-item--lang {
    grid-template-columns: 1fr;
  }
}
.repeatable-item .skill-line {
  margin-bottom: 0;
}
.btn-add-repeat {
  margin-top: 10px;
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(196, 30, 58, 0.06);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-add-repeat:hover {
  background: rgba(196, 30, 58, 0.12);
}

.cv-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.btn-export-cv {
  flex: 1;
  min-width: 160px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn-export-cv:hover:not(:disabled) { background: var(--primary-dark); }
.btn-export-cv:disabled { opacity: 0.75; cursor: wait; }

.btn-print-cv.btn-print-secondary {
  flex: 0 1 auto;
  min-width: 100px;
  padding: 12px 16px;
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn-print-cv.btn-print-secondary:hover { background: rgba(196, 30, 58, 0.06); }

.template-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: -8px 0 16px 0;
  text-align: left;
  padding: 10px 12px;
  background: rgba(196, 30, 58, 0.06);
  border-radius: var(--radius);
  border-right: 3px solid var(--primary);
}

/* Preview wrapper (screen) — only ONE sheet visible (fixes grid overriding [hidden]) */
.cv-preview-wrap {
  background: #c5c5c5;
  border-radius: var(--radius);
  padding: 24px;
  min-height: 400px;
  overflow: auto;
}
.cv-preview-wrap h3 {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.cv-preview-wrap .cv-sheet.cv-sheet--inactive {
  display: none !important;
}

/* A4 sheet (LTR) */
.cv-sheet {
  width: 210mm;
  min-height: 297mm;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  padding: 14mm 16mm;
  font-size: 10.5pt;
  line-height: 1.45;
  color: #1a1a1a;
  text-align: left;
  direction: ltr;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

.cv-sheet h1 {
  margin: 0 0 4px 0;
  font-size: 22pt;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.cv-sheet .cv-job-title {
  margin: 0 0 12px 0;
  font-size: 11pt;
  color: #444;
  font-weight: 600;
}
.cv-sheet .cv-contact-line {
  font-size: 9.5pt;
  color: #555;
  margin-bottom: 14px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 10px;
}
.cv-sheet .cv-section-title {
  font-size: 11pt;
  font-weight: 800;
  color: var(--primary, #c41e3a);
  margin: 14px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 2px solid #eee;
}
.cv-sheet h2.cv-section-title {
  font-size: 11pt;
  font-weight: 800;
  line-height: 1.3;
}
.cv-sheet .cv-block {
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.cv-sheet .cv-empty {
  color: #aaa;
  font-style: italic;
  font-size: 9.5pt;
}

/* --- Template 1: ATS-friendly (single column, simple headings, system-safe font) --- */
.cv-template-1.cv-template-ats {
  font-family: Arial, Helvetica, "Segoe UI", sans-serif;
}
.cv-template-1.cv-template-ats .cv-header-block {
  text-align: left;
  border-bottom: 2px solid #111;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.cv-template-1.cv-template-ats .cv-contact-line {
  border: none;
  text-align: left;
  color: #333;
}
.cv-template-1.cv-template-ats h1 {
  font-size: 20pt;
  font-weight: 700;
  color: #000;
}
.cv-template-1.cv-template-ats .cv-job-title {
  color: #222;
  font-weight: 600;
}
.cv-template-1.cv-template-ats .cv-section-title,
.cv-template-1.cv-template-ats h2.cv-section-title {
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10pt;
  font-weight: 700;
  border-bottom: 1px solid #000;
  padding-bottom: 4px;
  margin-top: 16px;
}

/* --- Template 2: عمود جانبي --- */
.cv-template-2 {
  display: grid;
  grid-template-columns: 32% 1fr;
  gap: 16px;
  padding: 0;
  min-height: 297mm;
}
.cv-template-2 .cv-sidebar {
  background: #1e3a5f;
  color: #fff;
  padding: 14mm 10mm;
}
.cv-template-2 .cv-sidebar h1 {
  color: #fff;
  font-size: 16pt;
}
.cv-template-2 .cv-sidebar .cv-job-title {
  color: #b8d4f0;
}
.cv-template-2 .cv-sidebar .cv-contact-line {
  color: #e0e8f0;
  border-color: rgba(255,255,255,0.2);
  font-size: 9pt;
}
.cv-template-2 .cv-sidebar .cv-section-title {
  color: #fff;
  border-color: rgba(255,255,255,0.3);
}
.cv-template-2 .cv-main {
  padding: 14mm 12mm 14mm 8mm;
}
.cv-template-2 .cv-main .cv-section-title {
  color: #1e3a5f;
}

/* --- Template 3: بسيط / Minimal --- */
.cv-template-3 {
  border: 1px solid #ddd;
}
.cv-template-3 h1 {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: none;
}
.cv-template-3 .cv-section-title {
  font-size: 10pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #333;
  color: #333;
}
.cv-template-3 .cv-contact-line {
  border: none;
  font-size: 9pt;
}

@media (max-width: 900px) {
  .cv-builder-layout {
    grid-template-columns: 1fr;
  }
  .cv-form-panel {
    position: static;
    max-height: none;
  }
  .cv-sheet {
    width: 100%;
    min-height: auto;
  }
  .cv-template-2 {
    display: block;
    padding: 14mm;
  }
  .cv-template-2 .cv-sidebar {
    margin-bottom: 16px;
    border-radius: 4px;
  }
}

@media print {
  .top-bar,
  .main-nav,
  .page-hero,
  .cv-builder-intro,
  .cv-form-panel,
  .footer {
    display: none !important;
  }
  .cv-builder-page {
    padding: 0;
    background: #fff;
  }
  .cv-builder-layout {
    display: block;
    max-width: none;
    padding: 0;
  }
  .cv-preview-wrap {
    padding: 0;
    background: #fff;
    box-shadow: none;
    border-radius: 0;
  }
  .cv-preview-wrap h3 {
    display: none;
  }
  .cv-sheet {
    box-shadow: none;
    width: 100%;
    max-width: none;
    margin: 0;
    page-break-after: avoid;
  }
  .cv-sheet[hidden],
  .cv-sheet.cv-sheet--inactive {
    display: none !important;
  }
}
