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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(96, 120, 255, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(95, 125, 255, 0.08), transparent 28%),
    #080a13;
  color: #e0e0e0;
  display: flex;
  align-items: stretch;
}

/* ---- Layout ---- */
.container {
  display: grid;
  grid-template-columns: 300px 1fr;
  width: 100%;
  height: 100vh;
}

/* ---- Sidebar ---- */
.panel {
  background: rgba(12, 16, 34, 0.98);
  border-right: 1px solid rgba(70, 80, 150, 0.18);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.panel-header {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(71, 88, 197, 0.2);
  background: linear-gradient(180deg, rgba(30, 37, 74, 0.98), rgba(11, 14, 30, 0.98));
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 96px;
  height: auto;
  min-width: 96px;
  border-radius: 18px;
  padding: 8px;
  filter: drop-shadow(0 0 18px rgba(95, 125, 255, 0.35));
}

.brand-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8ea0ff;
  margin-bottom: 4px;
}

.panel-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
  margin: 0;
}

.tool-tagline {
  margin: 6px 0 0;
  font-size: 12px;
  color: #b5bfff;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }

/* ---- Section title ---- */
.section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #444;
  margin-bottom: 8px;
}

hr { border: none; border-top: 1px solid #1c1c1c; }

/* ---- Form elements ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.form-input {
  width: 100%;
  background: rgba(14, 16, 32, 0.9);
  border: 1px solid #1e2340;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 12px;
  padding: 6px 9px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
.form-input:focus { border-color: rgba(95, 125, 255, 0.5); background: rgba(18, 22, 44, 0.9); }
.form-input::placeholder { color: #2a2a3a; }

.form-textarea {
  width: 100%;
  background: rgba(14, 16, 32, 0.9);
  border: 1px solid #1e2340;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 12px;
  padding: 6px 9px;
  outline: none;
  font-family: inherit;
  resize: vertical;
  transition: border-color .15s;
  line-height: 1.55;
}
.form-textarea:focus { border-color: rgba(95, 125, 255, 0.5); background: rgba(18, 22, 44, 0.9); }
.form-textarea::placeholder { color: #2a2a3a; }

/* ---- Section editor ---- */
.sec-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sec-editor-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sec-label-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid #1e2340;
  color: #8ea0ff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 0 3px;
  outline: none;
  font-family: inherit;
  min-width: 0;
  transition: border-color .15s;
}
.sec-label-input:focus { border-bottom-color: #5f7dff; color: #c0cfff; }

.sec-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.sec-btn {
  background: none;
  border: 1px solid #1e2340;
  border-radius: 4px;
  color: #2a2a4a;
  cursor: pointer;
  padding: 1px 5px;
  font-size: 12px;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
}
.sec-btn:hover { color: #8ea0ff; border-color: rgba(95,125,255,0.4); }
.sec-btn.danger:hover { color: #ff6060; border-color: rgba(255, 80, 80, 0.4); }

/* ---- Entry editor ---- */
.entry-editor {
  position: relative;
  background: rgba(8, 10, 22, 0.7);
  border: 1px solid #181c30;
  border-radius: 7px;
  padding: 8px 26px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entry-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.entry-fields .full { grid-column: 1 / -1; }

.entry-remove-btn {
  position: absolute;
  top: 7px;
  right: 6px;
  background: none;
  border: none;
  color: #222232;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.entry-remove-btn:hover { color: #ff6060; }

.add-entry-btn {
  background: transparent;
  border: 1px dashed #1e2340;
  border-radius: 6px;
  color: #2a2a4a;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  width: 100%;
  text-align: left;
  transition: border-color .15s, color .15s, background .15s;
}
.add-entry-btn:hover { border-color: rgba(95,125,255,0.4); color: #8ea0ff; background: rgba(95,125,255,0.04); }

/* ---- Add section ---- */
.add-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.add-section-btn {
  background: rgba(95, 125, 255, 0.04);
  border: 1px solid #1e2340;
  border-radius: 6px;
  color: #333;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 11px;
  font-family: inherit;
  text-align: center;
  transition: border-color .15s, color .15s, background .15s;
}
.add-section-btn:hover { border-color: rgba(95,125,255,0.4); color: #8ea0ff; background: rgba(95,125,255,0.08); }

/* ---- Action buttons ---- */
.action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(95, 125, 255, 0.1);
  color: #8ea0ff;
  border: 1px solid rgba(95, 125, 255, 0.2);
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.action-btn:hover { background: rgba(95, 125, 255, 0.2); color: #fff; }

.action-btn-primary {
  background: linear-gradient(135deg, #5f7dff, #7a60ff);
  color: #fff;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(95, 125, 255, 0.3);
}
.action-btn-primary:hover { background: linear-gradient(135deg, #6f8dff, #8a70ff); color: #fff; }

/* ---- Output side ---- */
.output-side {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(70, 80, 150, 0.12);
  background: rgba(8, 10, 22, 0.8);
}

.io-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #444;
}

.save-indicator {
  font-size: 11px;
  color: #333;
  transition: color .3s;
}
.save-indicator.saved { color: #00c878; }

.preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 40px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e transparent;
}
.preview-scroll::-webkit-scrollbar { width: 6px; }
.preview-scroll::-webkit-scrollbar-track { background: transparent; }
.preview-scroll::-webkit-scrollbar-thumb { background: #1e1e1e; border-radius: 4px; }

/* ============================================================
   RESUME PAPER
   All classes prefixed r- to avoid conflicts
   ============================================================ */
.resume-paper {
  background: #fff;
  color: #111;
  width: 680px;
  min-height: 940px;
  padding: 52px 56px;
  border-radius: 2px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.3);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  flex-shrink: 0;
}

/* Empty state */
.r-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  gap: 12px;
  color: #bbb;
  text-align: center;
}
.r-empty svg { opacity: 0.2; }
.r-empty p { font-size: 13px; color: #ccc; }
.r-empty small { font-size: 11px; color: #aaa; }

/* Header */
.r-header {
  margin-bottom: 18px;
  text-align: center;
}
.r-name {
  font-size: 30px;
  font-weight: 700;
  color: #0a0a1a;
  letter-spacing: -0.5px;
  margin: 0 0 3px;
  line-height: 1.1;
}
.r-job-title {
  font-size: 13px;
  color: #666;
  margin: 0 0 10px;
}
.r-contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 6px;
  font-size: 11.5px;
  color: #555;
  line-height: 1.8;
}
.r-contact-sep { color: #ccc; margin: 0 1px; }

/* Sections */
.r-section { margin-top: 16px; }

.r-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: #3a50cc;
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 1.5px solid #3a50cc;
}

/* Entries */
.r-entry { margin-bottom: 11px; }
.r-entry:last-child { margin-bottom: 0; }

.r-entry-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.r-entry-meta {
  flex: 1;
  min-width: 0;
}
.r-entry-role {
  font-weight: 700;
  color: #111;
  font-size: 13px;
  display: block;
}
.r-entry-org {
  color: #444;
  font-size: 12px;
  display: block;
}
.r-entry-loc { color: #888; }
.r-entry-dates {
  font-size: 11.5px;
  color: #777;
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 1px;
}
.r-entry-grade {
  font-size: 11.5px;
  color: #888;
  margin-top: 2px;
}
.r-entry-sub {
  font-size: 11.5px;
  color: #888;
  margin-top: 1px;
  display: block;
}
.r-entry-link {
  font-size: 11px;
  color: #3a50cc;
  text-decoration: none;
  display: block;
  margin-top: 1px;
}

/* Description */
.r-bullets {
  margin: 5px 0 0 16px;
  padding: 0;
}
.r-bullets li {
  font-size: 12px;
  color: #333;
  margin-bottom: 2px;
  line-height: 1.55;
}
.r-desc-text {
  font-size: 12px;
  color: #333;
  margin: 5px 0 0;
  line-height: 1.55;
}

/* Summary */
.r-summary { font-size: 12.5px; color: #333; line-height: 1.65; }

/* Skills */
.r-skill-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.r-skill-row:last-child { margin-bottom: 0; }
.r-skill-cat { font-weight: 700; color: #222; white-space: nowrap; flex-shrink: 0; }
.r-skill-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.r-skill-tag {
  background: #f0f2ff;
  color: #344;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid #d8dcf0;
}

/* Languages */
.r-lang-list { font-size: 12.5px; color: #333; line-height: 1.8; }
.r-lang-item strong { color: #111; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  @page {
    margin: 0;
    size: A4;
  }
  html, body {
    height: auto;
    overflow: visible;
    background: white !important;
  }
  .panel,
  .preview-topbar { display: none !important; }
  .container { display: block; height: auto; }
  .output-side { height: auto; overflow: visible; display: block; }
  .preview-scroll {
    overflow: visible;
    padding: 0;
    display: block;
  }
  .resume-paper {
    width: 100% !important;
    min-height: 0 !important;
    padding: 1.2cm 2cm !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Prevent section titles from being orphaned at the bottom of a page */
  .r-section-title {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Keep each entry (job, education, project, cert) from splitting across pages */
  .r-entry {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Keep skill rows and language list together */
  .r-skill-row,
  .r-lang-list {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* If an entire section fits on the remaining space, keep it together */
  .r-section {
    break-inside: avoid;
    page-break-inside: avoid;
    /* padding-top (not margin) survives page breaks — margin collapses, padding doesn't */
    margin-top: 0;
    padding-top: 1.1cm;
  }
}

/* ---- Mobile ---- */
@media (max-width: 800px) {
  html, body { overflow: auto; height: auto; }
  .container { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .panel { height: auto; overflow: visible; border-right: none; border-bottom: 1px solid rgba(70,80,150,0.18); }
  .panel-body { overflow: visible; }
  .output-side { height: auto; overflow: visible; }
  .preview-scroll { overflow: visible; padding: 16px; }
  .resume-paper { width: 100%; min-width: 0; padding: 28px 24px; }
}
