/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Top Bar ===== */
.top-bar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.top-bar-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #2563eb;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.top-actions { display: flex; align-items: center; gap: 1rem; }
.resume-selector { display: flex; align-items: center; gap: 0.35rem; }
.resume-selector select {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: #475569;
  background: #fff;
  cursor: pointer;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.trust-badges { display: flex; gap: 0.4rem; }
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.blue { background: #eff6ff; color: #2563eb; }
.badge.green { background: #ecfdf5; color: #059669; }

/* ===== App Layout ===== */
.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  flex: 1;
  width: 100%;
}

/* ===== Form Panel ===== */
.form-panel {
  padding: 1rem 1.25rem 2rem;
  overflow-y: auto;
  height: calc(100vh - 52px);
}

/* ===== Progress Bar ===== */
.progress-bar-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.progress-label { font-size: 0.8rem; font-weight: 600; color: #475569; }
.progress-pct { font-size: 0.75rem; font-weight: 700; color: #2563eb; }
.progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Section Cards ===== */
.section-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  overflow: hidden;
  transition: border-color 0.2s;
}
.section-card:focus-within { border-color: #93c5fd; }

.section-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.section-toggle:hover { background: #f8fafc; }
.section-toggle h2 {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
  text-transform: none;
  letter-spacing: -0.01em;
}
.section-icon { font-size: 1rem; }
.optional-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.35rem;
}
.chevron {
  color: #94a3b8;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.section-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.section-body {
  padding: 0 1rem 1rem;
  transition: all 0.2s;
}
.section-body.collapsed {
  display: none;
}

/* ===== Form Elements ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.2rem; }
.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}
.req { color: #ef4444; }
.form-group input,
.form-group textarea,
.form-group select {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
  color: #1e293b;
  width: 100%;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.char-count { font-size: 0.7rem; color: #94a3b8; text-align: right; }
.helper-text { font-size: 0.7rem; color: #94a3b8; margin-top: 0.25rem; }

/* ===== Entry Items ===== */
.entry-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  position: relative;
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.entry-item .form-grid { margin-bottom: 0.4rem; }
.entry-item .remove-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  transition: all 0.15s;
}
.entry-item .remove-btn:hover { color: #ef4444; background: #fef2f2; }

.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: none;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.5rem;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.add-btn:hover { border-color: #2563eb; background: #eff6ff; }

/* ===== Skill Input ===== */
.skill-input-wrap {
  display: flex;
  gap: 0.35rem;
}
.skill-input-wrap input { flex: 1; }
.skill-add-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #2563eb;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.skill-add-btn:hover { background: #2563eb; color: #fff; }

.skills-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; min-height: 28px; }
.skill-tag {
  background: #eff6ff;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  animation: slideIn 0.15s ease-out;
}
.skill-tag:hover { background: #fee2e2; color: #dc2626; }
.skill-tag .x { font-size: 0.65rem; opacity: 0.6; }

/* ===== Template Picker ===== */
.template-picker { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.tmpl-btn {
  flex: 1;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.6rem 0.4rem 0.4rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.tmpl-btn.active { border-color: #2563eb; background: #eff6ff; }
.tmpl-btn:hover { border-color: #93c5fd; }
.tmpl-btn span { font-size: 0.7rem; font-weight: 600; color: #475569; }
.tmpl-preview {
  width: 100%;
  height: 48px;
  border-radius: 3px;
  margin-bottom: 0.3rem;
}
.executive-preview { background: linear-gradient(180deg, #1e3a5f 35%, #f1f5f9 35%); }
.modern-preview { background: linear-gradient(90deg, #2563eb 28%, #f1f5f9 28%); }
.minimal-preview { background: #f8fafc; border: 1px solid #e2e8f0; }

/* ===== Style Options ===== */
.style-options { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.style-group { flex: 1; min-width: 120px; }
.style-group label { font-size: 0.7rem; font-weight: 600; color: #64748b; display: block; margin-bottom: 0.25rem; }
.style-group select {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  font-family: inherit;
  background: #fff;
  color: #1e293b;
}
.color-picker { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.color-dot.active { border-color: #1e293b; box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor; }
.color-dot:hover { transform: scale(1.15); }
.color-picker input[type="color"] {
  width: 22px;
  height: 22px;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

/* ===== Preview Panel ===== */
.preview-panel {
  background: #e2e8f0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
  position: sticky;
  top: 52px;
  overflow: hidden;
}
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  gap: 0.5rem;
}
.toolbar-left { display: flex; gap: 0.4rem; }
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: 7px;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.download-btn.primary { background: #2563eb; color: #fff; }
.download-btn.primary:hover { background: #1d4ed8; }
.download-btn.secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.download-btn.secondary:hover { background: #e2e8f0; }
.download-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auto-saved { color: #94a3b8; font-size: 0.75rem; white-space: nowrap; }

.preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ===== Resume Page ===== */
.resume-page {
  background: #fff;
  width: 595px;
  min-height: 842px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.1);
  font-size: 10pt;
  line-height: 1.5;
  color: #1e293b;
  flex-shrink: 0;
  border-radius: 2px;
}
.resume-page.font-small { font-size: 9pt; }
.resume-page.font-large { font-size: 11pt; }

/* === EXECUTIVE TEMPLATE === */
.resume-page.template-executive .resume-header {
  padding: 24px 28px 18px;
  color: #fff;
}
.resume-page.template-executive .resume-header h1 {
  font-size: 20pt;
  font-weight: 700;
  margin-bottom: 1px;
  letter-spacing: -0.02em;
}
.resume-page.template-executive .resume-header .subtitle {
  font-size: 10.5pt;
  opacity: 0.88;
  margin-bottom: 8px;
  font-weight: 400;
}
.resume-page.template-executive .resume-header .contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 8.5pt;
  opacity: 0.9;
}
.resume-page.template-executive .resume-header .contact-row span {
  display: flex;
  align-items: center;
  gap: 3px;
}
.resume-page.template-executive .resume-body { padding: 18px 28px 28px; }
.resume-page.template-executive .resume-section { margin-bottom: 14px; }
.resume-page.template-executive .resume-section h3 {
  font-size: 10pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 3px;
  margin-bottom: 8px;
  border-bottom: 1.5px solid;
}
.resume-page .entry { margin-bottom: 10px; }
.resume-page .entry:last-child { margin-bottom: 0; }
.resume-page .entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.resume-page .entry-title { font-weight: 700; font-size: 10pt; }
.resume-page .entry-date { font-size: 8.5pt; color: #64748b; white-space: nowrap; flex-shrink: 0; }
.resume-page .entry-sub { font-size: 9pt; color: #475569; margin-bottom: 2px; }
.resume-page .entry-desc {
  font-size: 9pt;
  color: #334155;
  white-space: pre-line;
  line-height: 1.55;
}
.resume-page .summary-text { font-size: 9pt; color: #475569; line-height: 1.6; }
.resume-page .skills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.resume-page .skills-list span {
  font-size: 8.5pt;
  padding: 2px 8px;
  border-radius: 3px;
}
.resume-page .languages-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 9pt;
  color: #475569;
}

/* === MODERN TEMPLATE (Sidebar) === */
.resume-page.template-modern {
  display: grid;
  grid-template-columns: 170px 1fr;
  min-height: 842px;
}
.resume-page.template-modern .sidebar {
  color: #fff;
  padding: 24px 14px;
}
.resume-page.template-modern .sidebar h1 {
  font-size: 15pt;
  font-weight: 700;
  margin-bottom: 1px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.resume-page.template-modern .sidebar .subtitle {
  font-size: 8.5pt;
  opacity: 0.85;
  margin-bottom: 16px;
}
.resume-page.template-modern .sidebar .sidebar-section { margin-bottom: 14px; }
.resume-page.template-modern .sidebar .sidebar-section h3 {
  font-size: 7.5pt;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.65;
  margin-bottom: 5px;
  font-weight: 600;
}
.resume-page.template-modern .sidebar .sidebar-section p {
  font-size: 8.5pt;
  color: #fff;
  margin-bottom: 1px;
  word-break: break-all;
  line-height: 1.4;
}
.resume-page.template-modern .sidebar .skill-list {
  list-style: none;
  font-size: 8.5pt;
}
.resume-page.template-modern .sidebar .skill-list li {
  padding: 1.5px 0;
  opacity: 0.92;
}
.resume-page.template-modern .main-content { padding: 24px 22px 28px; }
.resume-page.template-modern .resume-section { margin-bottom: 14px; }
.resume-page.template-modern .resume-section h3 {
  font-size: 10pt;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

/* === MINIMAL TEMPLATE === */
.resume-page.template-minimal .resume-header {
  padding: 26px 30px 14px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
}
.resume-page.template-minimal .resume-header h1 {
  font-size: 20pt;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.resume-page.template-minimal .resume-header .subtitle {
  font-size: 10pt;
  color: #64748b;
  margin-bottom: 6px;
}
.resume-page.template-minimal .resume-header .contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  font-size: 8.5pt;
  color: #64748b;
}
.resume-page.template-minimal .resume-body { padding: 16px 30px 28px; }
.resume-page.template-minimal .resume-section { margin-bottom: 14px; }
.resume-page.template-minimal .resume-section h3 {
  font-size: 9pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid #e2e8f0;
}
.resume-page.template-minimal .skills-list span {
  background: none !important;
  padding: 0 !important;
  color: #475569;
  font-size: 8.5pt;
}
.resume-page.template-minimal .skills-list span:not(:last-child)::after {
  content: ' · ';
  color: #cbd5e1;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.25s ease-out, toastOut 0.25s ease-in 2.5s forwards;
  white-space: nowrap;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  text-align: center;
}
.modal-box h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.modal-box p { font-size: 0.85rem; color: #64748b; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: center; }
.modal-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.15s;
}
.modal-btn.cancel { background: #f1f5f9; color: #475569; }
.modal-btn.cancel:hover { background: #e2e8f0; }
.modal-btn.danger { background: #ef4444; color: #fff; }
.modal-btn.danger:hover { background: #dc2626; }

/* ===== FAB ===== */
.fab-download {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 52px;
  height: 52px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  cursor: pointer;
  z-index: 200;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.fab-download:hover { transform: scale(1.08); }

/* ===== Footer ===== */
footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
}
.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #94a3b8;
}
.footer-links { display: flex; gap: 0.5rem; align-items: center; }
.footer-links a { color: #64748b; text-decoration: none; }
.footer-links a:hover { color: #2563eb; }

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .app-layout { grid-template-columns: 1fr; }
  .preview-panel { position: relative; top: 0; height: auto; min-height: 500px; }
  .form-panel { height: auto; }
  .fab-download { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .trust-badges { display: none; }
  .style-options { flex-direction: column; }
  .footer-inner { flex-direction: column; gap: 0.35rem; text-align: center; }
}

/* ===== Print ===== */
@media print {
  .top-bar, .form-panel, .preview-toolbar, .fab-download, footer, .toast-container, .modal-overlay { display: none !important; }
  .app-layout { display: block; }
  .preview-panel { background: none; height: auto; position: static; }
  .preview-scroll { padding: 0; }
  .resume-page { box-shadow: none; }
}
