/* Repeating background watermark across the page (Free mode) */
.resume.watermarked {
  /* Tiled SVG with rotated watermark text */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='220' viewBox='0 0 320 220'><defs><style>.t{font:700%2018px%20Arial%2C%20sans-serif;%20fill:%23000000;%20fill-opacity:0.075;}</style></defs><g transform='translate(20%2C120)%20rotate(-30%20160%20-20)'><text x='0' y='0' class='t'>Made%20with%20EasyCVPro</text></g></svg>");
  background-size: 320px 220px;
  background-repeat: repeat;
  background-attachment: local;
  background-color: white; /* keep resume page white */
}
:root {
  --bg: #0b0d12;
  --panel: #11141b;
  --text: #e6eaf2;
  --muted: #a8b0c0;
  --primary: #6ea8fe;
  --primary-600: #5a96ef;
  --accent: #22c55e;
  --border: #1b2230;
  --resume-accent: #2563eb; /* default blue */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  background: radial-gradient(1200px 800px at 20% -10%, #14203b, transparent), var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(11, 13, 18, 0.8);
  backdrop-filter: saturate(140%) blur(8px);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  background: linear-gradient(135deg, var(--primary), #66d3fa);
  color: #0b0d12;
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 10px;
  letter-spacing: 1px;
}
.titles h1 { margin: 0; font-size: 18px; }
.titles .tag { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.header-actions { display: flex; gap: 10px; align-items: center; }
.theme-picker { display: inline-flex; gap: 6px; align-items: center; padding: 0 6px; }
.theme-picker .swatch {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #1d2a3f; background: var(--swatch);
  cursor: pointer;
}
.theme-picker .swatch.active { box-shadow: 0 0 0 2px #0b0d12, 0 0 0 3px var(--resume-accent); }
.save-status { color: #9fb6d6; font-size: 12px; min-width: 60px; text-align: right; }
.template-picker { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.select { background: #0f141f; color: var(--text); border: 1px solid #1d2a3f; padding: 8px 10px; border-radius: 8px; }
.badge {
  background: #243044;
  color: #9fb6d6;
  border: 1px solid #2d3a52;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

/* Clickable badge link */
.badge[href] { text-decoration: none; display: inline-block; }
.badge[href]:hover { filter: brightness(1.1); }

.btn {
  background: #1a2230;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn.primary {
  background: var(--primary-600);
  border-color: #426ac6;
}
.btn.ghost {
  background: transparent;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 16px; color: #bcd0f7; }

.cv-form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.two-col { grid-template-columns: 1fr 1fr; gap: 12px; }
label { color: #c8d3ea; font-size: 13px; }
input, textarea {
  width: 100%;
  background: #0f141f;
  border: 1px solid #1d2a3f;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}
textarea { resize: vertical; }
.line-controls { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.line-controls .btn.xs { background: #0f141f; border-color: #1d2a3f; }

/* Power sections UI */
.divider { height: 1px; background: #1d2a3f; margin: 16px 0; border-radius: 1px; }
.form-subtitle { margin: 0 0 8px; color: #bcd0f7; font-size: 14px; }
.power-section { border: 1px solid #1d2a3f; border-radius: 10px; padding: 10px; margin-bottom: 12px; background: #0f141f; }
.ps-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; color: #c8d3ea; }
.repeater { display: grid; gap: 8px; margin-top: 8px; }
.repeater-row { display: grid; gap: 8px; grid-template-columns: 1fr 2fr 1fr auto; align-items: start; }
.repeater-row input, .repeater-row textarea { width: 100%; }
.repeater-row textarea { min-height: 56px; resize: vertical; }
.repeater-row .bullets { grid-column: 1 / span 3; }
.repeater-row .controls { display: flex; gap: 6px; align-items: center; }
.btn.xs { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.square { width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; }
.btn.icon { font-size: 14px; }
.hint { color: #8fa3c7; font-size: 12px; margin: 0; }
.inline { display: inline-flex; align-items: center; gap: 8px; }

/* Tiny help bubble */
.help {
  display: inline-grid;
  place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #22304a;
  color: #cfe1ff;
  font-size: 11px;
  cursor: help;
  border: 1px solid #2d3a52;
}
label > span .help { margin-left: 6px; }

/* Progress bar under header */
.progress {
  padding: 6px 16px 0;
}
.progress-inner { max-width: 1200px; margin: 0 auto; display: grid; gap: 6px; }
.progress-track {
  height: 8px;
  background: #121827;
  border: 1px solid #1d2a3f;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #5a96ef, #60d7ff);
}
.progress-text { color: #a8b0c0; font-size: 12px; }

/* Icons for section titles */
#secProjects > h3::before { content: '🧰 '; }
#secAchievements > h3::before { content: '🏆 '; }
#secCertifications > h3::before { content: '🎖️ '; }
#secVolunteer > h3::before { content: '🤝 '; }
#secCourses > h3::before { content: '🎓 '; }
#secPublications > h3::before { content: '📰 '; }
#secReferences > h3::before { content: '📇 '; }

.preview-panel { overflow: auto; padding-bottom: 24px; }
.resume {
  background: white;
  color: #1b2430;
  width: 100%;
  max-width: 800px; /* A4 ~ 794px @96dpi */
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  position: relative;
}
.resume.a4 { aspect-ratio: 1 / 1.4142; }
.resume-header {
  padding: 28px 28px 16px;
  border-bottom: 2px solid #eaecef;
}
.resume-header h1 { margin: 0; font-size: 28px; }
.resume-header .muted { color: #6b7280; margin: 6px 0 0; }
/* Ensure muted text is readable on white resume */
.resume .muted { color: #6b7280; }
.contact { font-size: 13px; }
.header-extras { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.profile-photo { width: 64px; height: 64px; object-fit: cover; border: 2px solid #e5e7eb; }
.profile-photo.circle { border-radius: 999px; }
.profile-photo.square { border-radius: 8px; }
.qr canvas { display: block; width: 64px; height: 64px; }

.resume-body { display: grid; grid-template-columns: 1fr; }
.resume-aside { display: none; }
.resume-main { display: block; }

.resume-section { padding: 16px 28px; }
/* Prevent long lines from overflowing the preview */
.resume-section p, .resume-section ul { overflow-wrap: anywhere; word-break: break-word; }
.resume-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: var(--resume-accent);
  /* Avoid leaving a lone heading at the bottom of a page */
  break-after: avoid-page;
  page-break-after: avoid;
}
.list { margin: 0; padding: 0 0 0 18px; }
.list li { margin: 6px 0; }
.skills { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.skills li {
  background: #f3f4f6;
  color: #111827;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

/* Accent links and bullets */
.resume a { color: var(--resume-accent); }
.template-bold .resume-section h3 { color: var(--resume-accent); }
.template-bold .resume-section h3::after { background: var(--resume-accent); }

.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; color: #374151; }
.contact-list li { display: flex; align-items: center; gap: 8px; }
.contact-list .label { color: #6b7280; min-width: 64px; font-size: 12px; }

.wm {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(0, 0, 0, 0.15);
  font-weight: 800;
  font-size: 56px;
  transform: rotate(-25deg);
  pointer-events: none;
  user-select: none;
  /* Add subtle diagonal stripe pattern behind text for better visibility */
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(0,0,0,0.05) 0,
    rgba(0,0,0,0.05) 12px,
    transparent 12px,
    transparent 24px
  );
}

/* Avoid awkward page breaks for key blocks */
.avoid-break { break-inside: avoid; page-break-inside: avoid; }
.resume-section { break-inside: auto; }

/* Template variants */
.template-modern .resume-header { border-color: #eaecef; }

.template-classic .resume-header {
  border-bottom: 3px double #d1d5db;
}
.template-classic .resume-section h3 {
  text-transform: none;
  letter-spacing: 0;
  font-size: 16px;
  color: #1f2937;
}

.template-bold .resume-header {
  border-bottom: none;
  background: #111827;
  color: #f9fafb;
}
.template-bold .resume {
  border: none;
}
.template-bold .resume-section h3 {
  color: #111827;
  position: relative;
}
.template-bold .resume-section h3::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: #111827;
  margin-top: 6px;
}

/* Minimal template: airier spacing, toned headings */
.template-minimal .resume-header { border-bottom: 1px solid #edf2f7; }
.template-minimal .resume-header h1 { font-size: 26px; font-weight: 700; }
.template-minimal .resume-section { padding: 14px 24px; }
.template-minimal .resume-section h3 { font-size: 13px; color: #4b5563; }
.template-minimal .skills li { background: #eef2f7; }

/* Sidebar template: two-column layout with colored aside */
.template-sidebar .resume-body {
  grid-template-columns: 260px 1fr;
}
.template-sidebar .resume-aside {
  display: block;
  background: #fafafb;
  border-right: 1px solid #eceef2;
}
.template-sidebar .resume-main { display: block; }
.template-sidebar .resume-section { padding: 16px 20px; }
.template-sidebar .resume-section h3 { color: #2b3442; }
.template-sidebar .skills li { background: #eef2f7; }
.template-sidebar .contact-block { padding-top: 20px; }

/* Print tweaks when generating PDF */
@media print {
  body { background: white; }
  .app-header, .app-footer { display: none !important; }
  .panel { border: none; padding: 0; }
  .resume { border: none; border-radius: 0; }
}

/* Unified accent mode: make accent consistent across templates */
.accent-unified .resume-section h3 { color: var(--resume-accent) !important; }
.accent-unified .resume a { color: var(--resume-accent) !important; }
/* Bold template decorative rule uses accent */
.accent-unified.template-bold .resume-section h3::after { background: var(--resume-accent) !important; }

.app-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.footer-inner .actions { display: flex; gap: 10px; }

/* Modal */
.modal::backdrop { background: rgba(0,0,0,0.6); }
.modal { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--panel); color: var(--text); }
.modal h3 { margin: 0 0 8px; }
.modal-actions { margin-top: 12px; display: flex; gap: 10px; justify-content: flex-end; }

/* Splash overlay removed */

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #1a2230;
  color: #e6eaf2;
  border: 1px solid #2d3a52;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  z-index: 1000;
  max-width: 320px;
}
.toast.success { border-color: #2e7d32; }
.toast .title { font-weight: 600; margin-bottom: 4px; }
.toast .body { font-size: 13px; color: #cfd8ea; }

/* Responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .template-sidebar .resume-body { grid-template-columns: 1fr; }
  .resume-aside { display: none; }
}

/* Make sure template selector is always reachable on small screens */
@media (max-width: 640px) {
  .header-actions {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .template-picker {
    order: -1; /* show first on small screens */
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }
}
