/* style.css - Arquitetura de Layout Profissional | Dadge CV Pro */
:root {
  --green: #1dbf73;
  --green-dark: #19a463;
  --dark: #0f172a;
  --dark-2: #1e293b;
  --text: #475569;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --sidebar-w: 400px;
  --topbar-h: 80px;
  --radius: 12px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== TOPBAR REFORMULADA ========== */
.topbar-enhanced {
  background: linear-gradient(135deg, #fff, var(--bg));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  flex-shrink: 0;
  position: relative;
  padding: 0.5rem 1.5rem;
}

.topbar-enhanced::before {
  content: ''; 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
}

.topbar-enhanced-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand .icon-wrapper {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(29,191,115,0.2);
}

.topbar-brand .icon-wrapper i { font-size: 1.1rem; color: white; }

.title-section .topbar-title { 
  font-size: 1.1rem; 
  font-weight: 700; 
  color: #1a202c; 
  line-height: 1.2;
}

.title-section .topbar-sub { 
  font-size: 0.65rem; 
  color: #718096; 
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.topbar-tabs {
  display: flex;
  gap: 6px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 40px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 20px;
  border-radius: 32px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.tab-btn i { margin-right: 8px; }

.tab-btn:hover { 
  background: rgba(29,191,115,0.1); 
  color: var(--green); 
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: white;
  box-shadow: 0 2px 6px rgba(29,191,115,0.25);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.topbar-donation {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fffbeb;
  padding: 6px 16px;
  border-radius: 40px;
  border: 1px solid #fde68a;
  font-size: 0.7rem;
  font-weight: 600;
}

.topbar-donation i { margin-right: 5px; }

.donation-text { color: #b45309; }
.donation-iban { color: #92400e; }

.btn-export {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 32px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-export:hover { 
  transform: translateY(-1px); 
  box-shadow: 0 4px 10px rgba(29,191,115,0.35); 
}

/* ========== PAINÉIS DE CONTEÚDO ========== */
.app-layout { display: flex; flex: 1; height: calc(100vh - 85px); overflow: hidden; }
.sidebar-form { width: var(--sidebar-w); height: 100%; overflow-y: auto; background: var(--white); border-right: 1px solid var(--border); padding: 1.5rem 1.2rem; flex-shrink: 0; }
.sidebar-form::-webkit-scrollbar { width: 6px; }
.sidebar-form::-webkit-scrollbar-track { background: var(--bg); }
.sidebar-form::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.form-panel { display: none; }
.form-panel.active { display: block; }

.form-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.25rem; overflow: hidden; box-shadow: var(--shadow); }
.form-card-header {
  background: linear-gradient(135deg, rgba(29,191,115,0.06), rgba(25,164,99,0.02));
  padding: 0.85rem 1.15rem; font-weight: 700; font-size: 0.85rem; color: var(--dark-2);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
}
.form-card-header i { color: var(--green); margin-right: 4px; }
.form-card-body { padding: 1.15rem; }

.form-row { margin-bottom: 1rem; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text); margin-bottom: 0.4rem; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 0.85rem; color: var(--dark-2); background-color: var(--white);
}
.form-field input:focus, .form-field textarea:focus, .form-field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,191,115,0.08); outline: none; }

/* Barra de ferramentas rica - ESTILO MELHORADO */
.rich-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.rich-toolbar button {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--dark-2);
  transition: all 0.15s ease;
  font-weight: 500;
}

.rich-toolbar button i { margin-right: 4px; }

.rich-toolbar button:hover {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.rich-toolbar button.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.template-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.tmpl-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: white; cursor: pointer;
  font-size: 0.72rem; font-weight: 600; color: var(--text); transition: all 0.15s ease;
}
.tmpl-btn:hover { border-color: var(--green); color: var(--green); }
.tmpl-btn.active { border-color: var(--green); background: rgba(29,191,115,0.04); color: var(--green); }

.photo-upload { display: flex; justify-content: center; margin-bottom: 1rem; }
.photo-preview {
  width: 85px; height: 85px; border-radius: 50%; border: 2px dashed var(--text-light);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; background: var(--bg); overflow: hidden;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview i { font-size: 20px; color: var(--text-light); }
.photo-preview span { font-size: 0.62rem; color: var(--text-light); }

.entry-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 0.75rem; }
.entry-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; border-bottom: 1px dashed var(--border); padding-bottom: 4px; }
.entry-card-label { font-size: 0.75rem; font-weight: 700; color: var(--green-dark); }
.btn-remove { background: transparent; border: none; color: #ef4444; cursor: pointer; font-size: 0.85rem; font-weight: bold; }
.btn-add { background: var(--white); border: 1px solid var(--green); color: var(--green); padding: 4px 12px; border-radius: 12px; cursor: pointer; font-size: 0.72rem; font-weight: 600; }

/* ========== PAINEL DE VISUALIZAÇÃO ========== */
.preview-panel { flex: 1; display: flex; flex-direction: column; background: #64748b; overflow: hidden; }
.preview-toolbar { padding: 0.8rem 1.5rem; background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.preview-label { font-size: 0.85rem; font-weight: 700; color: var(--dark); }
.preview-label i { color: var(--green); margin-right: 6px; }
.preview-hint { font-size: 0.7rem; color: var(--text); }

.preview-scroll { flex: 1; overflow-y: auto; padding: 2rem 1.5rem; display: flex; justify-content: center; align-items: flex-start; }
.preview-scroll::-webkit-scrollbar { width: 8px; }
.preview-scroll::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
.preview-page-wrap { width: 210mm; background: white; box-shadow: var(--shadow-lg); }

/* ==========================================================================
   ESTILOS EXCLUSIVOS DA FOLHA A4
   ========================================================================== */
.cv-page {
  width: 210mm;
  min-height: auto;
  height: auto;
  box-sizing: border-box;
  background: #ffffff;
  position: relative;
  overflow: visible;
}

/* --- MODELO 1: PROFISSIONAL --- */
.cv-profissional {
  font-family: 'Inter', sans-serif;
  color: #1f2937;
  background: #ffffff;
  padding: 40px 35px;
  width: 100%;
  box-sizing: border-box;
}

.cv-pro-header {
  display: flex;
  align-items: center;
  gap: 25px;
  margin-bottom: 30px;
  padding-bottom: 25px;
  border-bottom: 3px solid #1dbf73;
}

.cv-pro-photo {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 3px solid #1dbf73;
}

.cv-pro-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-pro-photo-placeholder { font-size: 48px; color: #9ca3af; }
.cv-pro-header-info { flex: 1; }
.cv-pro-header-info h1 { font-size: 28px; font-weight: 800; color: #111827; margin: 0 0 5px 0; font-family: 'Montserrat', sans-serif; }
.cv-pro-header-info h2 { font-size: 14px; font-weight: 600; color: #1dbf73; margin: 0 0 12px 0; text-transform: uppercase; letter-spacing: 1px; }
.cv-pro-contacts { display: flex; flex-wrap: wrap; gap: 15px 25px; margin-top: 8px; }
.cv-pro-contact { font-size: 11px; color: #4b5563; display: inline-flex; align-items: center; gap: 5px; }
.cv-pro-section { margin-bottom: 28px; }
.cv-pro-section-title { font-size: 14px; font-weight: 700; color: #111827; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.cv-pro-section-line { width: 45px; height: 3px; background: #1dbf73; margin-bottom: 15px; }
.cv-pro-profile { font-size: 12px; line-height: 1.6; color: #4b5563; text-align: justify; margin: 0; }
.cv-pro-grid { display: flex; gap: 35px; margin-top: 10px; }
.cv-pro-left { flex: 1; }
.cv-pro-right { flex: 1.5; }
.cv-pro-skills { display: flex; flex-wrap: wrap; gap: 8px; }
.cv-pro-skill { background: #f3f4f6; padding: 5px 12px; border-radius: 20px; font-size: 11px; color: #1f2937; font-weight: 500; }
.cv-pro-langs { display: flex; flex-direction: column; gap: 10px; }
.cv-pro-lang { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px dashed #e5e7eb; }
.cv-pro-lang-name { font-size: 12px; font-weight: 600; color: #1f2937; }
.cv-pro-lang-level { font-size: 11px; color: #1dbf73; font-weight: 500; }
.cv-pro-edus { display: flex; flex-direction: column; gap: 15px; }
.cv-pro-edu { padding-bottom: 8px; }
.cv-pro-edu-title { font-size: 13px; font-weight: 700; color: #111827; margin-bottom: 3px; }
.cv-pro-edu-sub { font-size: 11px; color: #6b7280; margin-bottom: 3px; }
.cv-pro-edu-date { font-size: 11px; color: #1dbf73; font-weight: 500; }
.cv-pro-courses { display: flex; flex-direction: column; gap: 8px; }
.cv-pro-course { font-size: 11px; color: #4b5563; line-height: 1.4; }
.cv-pro-course-meta { color: #9ca3af; font-size: 10px; }
.cv-pro-items { display: flex; flex-direction: column; gap: 20px; }
.cv-pro-item { padding-bottom: 8px; border-left: 2px solid #e5e7eb; padding-left: 15px; position: relative; }
.cv-pro-item::before { content: ''; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px; background: #1dbf73; border-radius: 50%; }
.cv-pro-item-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 5px; }
.cv-pro-item-title { font-size: 13px; font-weight: 700; color: #111827; }
.cv-pro-item-date { font-size: 10px; color: #9ca3af; font-weight: 500; }
.cv-pro-item-sub { font-size: 11px; color: #1dbf73; font-weight: 600; margin-bottom: 8px; }
.cv-pro-item-desc { margin: 5px 0 0 0; padding-left: 18px; font-size: 11px; color: #4b5563; line-height: 1.5; }
.cv-pro-item-desc li { margin-bottom: 4px; }
.cv-pro-ref { font-size: 11px; color: #6b7280; font-style: italic; margin: 0; }

/* --- MODELO 2: CLÁSSICO --- */
.cv-classico { 
  font-family: 'Arial', sans-serif; 
  color: #1f2937; 
  padding: 30px 35px;
  height: auto;
  min-height: auto;
}
.cv-classico .cv-cl-header { border-bottom: 2px solid #111827; padding-bottom: 12px; margin-bottom: 18px; }
.cv-classico .cv-cl-header-inner { display: flex; align-items: center; gap: 18px; }
.cv-classico .cv-cl-photo { width: 90px; height: 90px; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); flex-shrink: 0; }
.cv-classico .cv-cl-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-classico .cv-cl-name-block h1 { font-size: 26px; font-weight: 700; color: #111827; letter-spacing: -0.5px; }
.cv-classico .cv-cl-name-block h2 { font-size: 12px; color: #4b5563; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; font-weight: 600; }
.cv-classico .cv-cl-contacts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 11px; color: #4b5563; }
.cv-classico .cv-cl-body { display: flex; gap: 24px; margin-top: 14px; }
.cv-classico .cv-cl-main { flex: 2; }
.cv-classico .cv-cl-aside { flex: 1; background: #f9fafb; padding: 14px; border-radius: 6px; border: 1px solid var(--border); }
.cv-classico .cv-cl-section { margin-bottom: 18px; }
.cv-classico .cv-cl-section-title { font-size: 13px; font-weight: 700; color: #111827; border-bottom: 1px solid #111827; padding-bottom: 4px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.cv-classico .cv-cl-profile { font-size: 11.5px; color: #374151; text-align: justify; line-height: 1.55; }
.cv-classico .cv-cl-job { margin-bottom: 14px; }
.cv-classico .cv-cl-job-header { display: flex; justify-content: space-between; font-weight: 700; font-size: 12px; }
.cv-classico .cv-cl-job-period { color: #6b7280; font-weight: 500; font-size: 11px; }
.cv-classico .cv-cl-job-company { font-style: italic; color: #4b5563; font-size: 11px; margin-bottom: 3px; }
.cv-classico .cv-cl-job-desc { padding-left: 14px; font-size: 11px; color: #374151; line-height: 1.5; }
.cv-classico .cv-cl-aside-section { margin-bottom: 16px; }
.cv-classico .cv-cl-aside-title { font-size: 11.5px; font-weight: 700; border-bottom: 1px solid #d1d5db; padding-bottom: 3px; margin-bottom: 8px; text-transform: uppercase; color: #4b5563; }
.cv-classico .cv-cl-skill-item { font-size: 11px; padding: 3px 0; color: #374151; }
.cv-classico .cv-cl-lang-item { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 6px; }
.cv-classico .cv-cl-lang-level { color: #6b7280; }
.cv-classico .cv-cl-edu-item { margin-bottom: 12px; }
.cv-classico .cv-cl-edu-degree { font-weight: 700; font-size: 11.5px; }
.cv-classico .cv-cl-edu-inst { font-size: 11px; color: #4b5563; }
.cv-classico .cv-cl-edu-year { font-size: 11px; color: #6b7280; }

/* --- MODELO 3: EXECUTIVO --- */
.cv-exec {
  font-family: 'Inter', sans-serif;
  color: #1f2937;
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: auto;
}
.cv-exec-header { background: #0b1320; color: #ffffff; padding: 30px 35px; display: flex; align-items: center; gap: 25px; }
.cv-exec-photo { width: 95px; height: 95px; border-radius: 50%; overflow: hidden; border: 2.5px solid #d97706; background: #1f2937; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cv-exec-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-exec-photo-placeholder { font-size: 40px; color: #6b7280; }
.cv-exec-name-block h1 { font-family: 'Montserrat', sans-serif; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; color: #ffffff; }
.cv-exec-name-block h2 { font-size: 11.5px; color: #d97706; text-transform: uppercase; letter-spacing: 1.8px; margin-top: 6px; font-weight: 600; }
.cv-exec-contact-strip { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 11px; color: #e5e7eb; }
.cv-exec-gold-bar { height: 4px; background: #d97706; }
.cv-exec-body { display: flex; flex: 1; background: #ffffff; }
.cv-exec-aside { width: 72mm; background: #f8fafc; padding: 25px 20px; border-right: 1px solid #e5e7eb; flex-shrink: 0; }
.cv-exec-main { flex: 1; padding: 30px 30px; }
.cv-exec-aside-section { margin-bottom: 24px; }
.cv-exec-aside-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: #374151; border-bottom: 1.5px solid #d97706; padding-bottom: 4px; margin-bottom: 10px; }
.cv-exec-profile-text { font-size: 11.5px; color: #4b5563; text-align: justify; line-height: 1.55; }
.cv-exec-skill { margin-bottom: 8px; }
.cv-exec-skill-name { font-size: 11.5px; color: #1f2937; font-weight: 500; display: block; }
.cv-exec-lang-item { margin-bottom: 8px; font-size: 11px; color: #374151; display: flex; justify-content: space-between; }
.cv-exec-lang-level { font-size: 10px; color: #6b7280; }
.cv-exec-main-section { margin-bottom: 24px; }
.cv-exec-main-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: #0b1320; border-bottom: 1.5px solid #0b1320; padding-bottom: 4px; margin-bottom: 14px; }
.cv-exec-job { margin-bottom: 16px; }
.cv-exec-job-header { display: flex; justify-content: space-between; font-weight: 700; font-size: 12.5px; color: #0b1320; }
.cv-exec-job-period { background: #0b1320; color: #ffffff; font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 500; flex-shrink: 0; }
.cv-exec-job-company { font-size: 11.5px; color: #d97706; font-weight: 600; margin: 2px 0 6px; }
.cv-exec-job-desc { padding-left: 14px; font-size: 11px; color: #4b5563; line-height: 1.5; }
.cv-exec-edu-item { margin-bottom: 12px; font-size: 11.5px; }
.cv-exec-edu-degree { font-weight: 700; color: #0b1320; }
.cv-exec-edu-inst { color: #4b5563; }
.cv-exec-edu-year { color: #6b7280; font-size: 11px; }

/* --- MODELO 4: CORPORATIVO --- */
.cv-corporativo {
  font-family: 'Inter', sans-serif;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

/* ── CABEÇALHO ESCURO ── */
.cv-corp-header {
  background: linear-gradient(135deg, #0b1b2e 0%, #1a2f4e 100%);
  color: #ffffff;
  padding: 30px 38px;
  display: flex;
  align-items: center;
  gap: 26px;
  position: relative;
  overflow: hidden;
}
.cv-corp-header::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(37,99,235,0.08);
  pointer-events: none;
}

.cv-corp-photo {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.18);
  background: #1e3a5f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.cv-corp-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-corp-photo-placeholder { font-size: 38px; color: #4b6cb7; }

.cv-corp-name-block { position: relative; z-index: 1; }
.cv-corp-name-block h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.1;
  color: #ffffff;
  margin: 0 0 5px;
}
.cv-corp-name-block h2 {
  font-size: 10.5px;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-weight: 500;
  margin: 0 0 12px;
}

.cv-corp-contact-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  font-size: 10px;
  color: #94a3b8;
}
.cv-corp-contact-item { display: inline-flex; align-items: center; gap: 5px; }
.cv-corp-contact-item i { color: #3b82f6; font-size: 9.5px; }

/* Barra azul accent */
.cv-corp-blue-bar {
  height: 3px;
  background: linear-gradient(90deg, #1d4ed8 0%, #7dd3fc 100%);
  flex-shrink: 0;
}

/* ── CORPO: aside + main ── */
.cv-corp-body {
  display: flex;
  background: #ffffff;
}

.cv-corp-aside {
  width: 70mm;
  background: #ffffff;
  padding: 22px 20px 22px 24px;
  border-right: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.cv-corp-main {
  flex: 1;
  padding: 22px 28px;
}

/* Títulos da aside */
.cv-corp-aside-section { margin-bottom: 20px; }
.cv-corp-aside-title {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #0f172a;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cv-corp-aside-title::before {
  content: '';
  width: 3px; height: 10px;
  background: #3b82f6;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Perfil */
.cv-corp-profile-text {
  font-size: 11px;
  color: #374151;
  text-align: justify;
  line-height: 1.65;
  margin: 0;
}

/* Competências */
.cv-corp-skill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #1e293b;
  margin-bottom: 7px;
  padding: 3px 0;
  border-bottom: 1px solid #f1f5f9;
}
.cv-corp-skill:last-child { border-bottom: none; margin-bottom: 0; }
.cv-corp-skill-dot {
  width: 5px; height: 5px;
  background: #3b82f6;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Idiomas */
.cv-corp-lang { margin-bottom: 10px; }
.cv-corp-lang:last-child { margin-bottom: 0; }
.cv-corp-lang-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}
.cv-corp-lang-name { font-size: 11px; font-weight: 600; color: #1e293b; }
.cv-corp-lang-level { font-size: 9px; color: #3b82f6; font-weight: 700; }
.cv-corp-lang-bar { height: 4px; background: #e0e7ff; border-radius: 4px; overflow: hidden; }
.cv-corp-lang-fill { height: 100%; background: linear-gradient(90deg, #1d4ed8, #60a5fa); border-radius: 4px; }

/* Formação na aside */
.cv-corp-edu { margin-bottom: 13px; padding-left: 10px; border-left: 2px solid #e0e7ff; }
.cv-corp-edu:last-child { margin-bottom: 0; }
.cv-corp-edu-degree { font-size: 11px; font-weight: 700; color: #0f172a; margin-bottom: 2px; }
.cv-corp-edu-inst { font-size: 10px; color: #3b82f6; margin-bottom: 2px; }
.cv-corp-edu-year { font-size: 9.5px; color: #94a3b8; font-weight: 500; }

/* Títulos da main */
.cv-corp-main-section { margin-bottom: 20px; }
.cv-corp-main-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: #0b1b2e;
  border-bottom: 1.5px solid #cbd5e1;
  padding-bottom: 5px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.cv-corp-main-title::before {
  content: '';
  width: 3px; height: 12px;
  background: #3b82f6;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Experiência */
.cv-corp-job { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed #e5e7eb; }
.cv-corp-job:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.cv-corp-job-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 3px;
}
.cv-corp-job-title { font-size: 12.5px; font-weight: 700; color: #0b1b2e; }
.cv-corp-job-period {
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.cv-corp-job-company { font-size: 11px; color: #3b82f6; font-weight: 600; margin: 2px 0 6px; }
.cv-corp-job-desc { padding-left: 14px; font-size: 11px; color: #4b5563; line-height: 1.55; margin: 0; }
.cv-corp-job-desc li { margin-bottom: 3px; }

/* Certificações */
.cv-corp-course { margin-bottom: 10px; padding-left: 10px; border-left: 2px solid #3b82f6; }
.cv-corp-course:last-child { margin-bottom: 0; }
.cv-corp-course-name { font-size: 11.5px; font-weight: 600; color: #0f172a; }
.cv-corp-course-meta { font-size: 10px; color: #6b7280; margin-top: 2px; }

/* Referências */
.cv-corp-ref { font-size: 11px; color: #64748b; font-style: italic; margin: 0; padding: 10px 13px; background: #f8fafc; border-radius: 4px; border-left: 2px solid #3b82f6; }

/* --- CARTA DE APRESENTAÇÃO --- */
.cv-carta { font-family: 'Inter', sans-serif; font-size: 12px; color: #1f2937; line-height: 1.6; padding: 35px 40px; }
.carta-header { display: flex; justify-content: space-between; margin-bottom: 30px; gap: 20px; }
.carta-remetente strong { font-size: 16px; color: #111827; display: block; margin-bottom: 4px; font-family: 'Montserrat', sans-serif; font-weight: 700; }
.carta-remetente span { display: block; font-size: 11.5px; color: #4b5563; }
.carta-data { font-size: 11.5px; color: #4b5563; text-align: right; font-weight: 500; }
.carta-destinatario { margin-bottom: 30px; background: #f9fafb; padding: 14px; border-radius: 8px; border: 1px solid var(--border); max-width: 130mm; }
.carta-destinatario strong { display: block; color: #111827; font-size: 13px; margin-bottom: 3px; }
.carta-destinatario span { display: block; font-size: 11.5px; color: #4b5563; }
.carta-assunto { margin-bottom: 30px; font-size: 13px; color: #111827; border-left: 4px solid var(--green); padding-left: 12px; font-weight: 600; }
.carta-body p { margin-bottom: 16px; text-align: justify; color: #374151; }
.carta-body b, .carta-body strong { font-weight: 700; color: #000; }
.carta-body i, .carta-body em { font-style: italic; }
.carta-body u { text-decoration: underline; }
.carta-body ul, .carta-body ol { margin: 8px 0; padding-left: 28px; }
.carta-body li { margin-bottom: 4px; }
.carta-assinatura { margin-top: 40px; }
.carta-assinatura .linha { width: 180px; border-top: 1px solid #9ca3af; margin-bottom: 8px; }
.carta-assinatura strong { font-size: 13px; color: #111827; }

.avoid-break { page-break-inside: avoid !important; break-inside: avoid !important; }

/* ========== EDITOR WYSIWYG ========== */
.wysiwyg-editor {
  min-height: 400px;
  max-height: 500px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.6;
  background: var(--white);
  color: var(--dark-2);
  resize: vertical;
}
.wysiwyg-editor:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,191,115,0.08); }
.wysiwyg-editor p { margin: 0 0 12px 0; }
.wysiwyg-editor ul, .wysiwyg-editor ol { margin: 8px 0 12px 25px; padding-left: 0; }
.wysiwyg-editor li { margin-bottom: 4px; }
.wysiwyg-editor b, .wysiwyg-editor strong { font-weight: 700; }
.wysiwyg-editor i, .wysiwyg-editor em { font-style: italic; }
.wysiwyg-editor u { text-decoration: underline; }

/* ========== RESPONSIVIDADE CORRIGIDA (ORIGINAL) ========== */
@media (max-width: 1200px) {
  .preview-scroll { 
    padding: 1rem; 
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .preview-page-wrap { 
    width: 100%; 
    max-width: 210mm; 
  }
  .sidebar-form { width: 360px; }
}

@media (max-width: 992px) {
  body {
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .app-layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .sidebar-form { 
    width: 100%; 
    height: auto; 
    max-height: 40vh; 
    overflow-y: auto; 
    border-right: none; 
    border-bottom: 1px solid var(--border); 
  }
  .preview-panel { 
    height: auto; 
    overflow: visible; 
    min-height: 60vh;
    display: flex;
    flex-direction: column;
  }
  .preview-scroll { 
    flex: 1;
    overflow-y: auto !important;
    padding: 1rem;
    min-height: 400px;
    max-height: none;
    -webkit-overflow-scrolling: touch;
  }
  .cv-page { 
    width: 100%; 
    min-height: auto;
    height: auto;
    overflow: visible;
  }
  .cv-pro-grid { flex-direction: column; height: auto; min-height: auto; }
  .cv-exec-body { flex-direction: column; }
  .cv-exec-aside { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .cv-exec { height: auto; min-height: auto; }
  .cv-classico { height: auto; min-height: auto; }
  .cv-classico .cv-cl-body { flex-direction: column; }
  .cv-corp-grid { flex-direction: column; }
  .topbar-donation .donation-iban { display: none; }
}

@media (max-width: 850px) {
  .topbar-enhanced-content { 
    flex-wrap: wrap; 
    gap: 10px; 
    justify-content: center; 
  }
  .topbar-enhanced { 
    height: auto; 
    padding: 10px 1rem; 
  }
  .topbar-brand { width: auto; }
  .topbar-tabs { order: 1; }
  .topbar-donation { 
    order: 2; 
    font-size: 0.65rem;
    padding: 4px 12px;
  }
  .topbar-donation .donation-iban { display: inline-block; }
  .btn-export { 
    order: 3; 
    padding: 6px 14px;
    font-size: 0.7rem;
  }
  .app-layout { height: auto; }
  
  .preview-scroll {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }
}

@media (max-width: 768px) {
  .topbar-enhanced-content { 
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .topbar-brand { order: 1; }
  .topbar-tabs { order: 2; width: auto; }
  .topbar-donation { order: 3; width: auto; }
  .btn-export { order: 4; width: auto; margin-top: 5px; }
  
  .topbar-donation span:first-of-type { font-size: 0.6rem; }
  .topbar-donation .donation-iban { display: none; }
  
  .tab-btn { 
    padding: 6px 12px; 
    font-size: 0.7rem; 
  }
  .tab-btn i { margin-right: 4px; }
  
  .preview-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 0.6rem 1rem;
    align-items: center;
    justify-content: flex-start;
  }
  .preview-toolbar .preview-label {
    flex-basis: 100%;
    font-size: 0.72rem;
  }
  .preview-toolbar .preview-hint {
    flex-basis: 100%;
  }
  .preview-hint { font-size: 0.65rem; }
  
  .sidebar-form { 
    max-height: 35vh; 
    padding: 1rem;
  }
  
  .preview-scroll {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 1rem;
  }
  
  .cv-page {
    max-width: 100%;
    height: auto;
    min-height: auto;
    overflow: visible;
  }
  
  .cv-carta {
    padding: 20px;
    max-width: 100%;
    overflow: visible;
  }
  
  .carta-body {
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .cv-pro-header { flex-direction: column; text-align: center; }
  .cv-pro-contacts { justify-content: center; }
  .cv-pro-section-line { margin-left: auto; margin-right: auto; }
  .cv-corp-body { flex-direction: column; }
  .cv-corp-aside { width: 100%; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .cv-corp-job-header { flex-direction: column; gap: 4px; }
  .cv-corp-job-period { align-self: flex-start; }
}

@media (max-width: 580px) {
  .topbar-enhanced-content {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-brand { justify-content: center; }
  .topbar-tabs { justify-content: center; }
  .topbar-donation { justify-content: center; text-align: center; }
  .btn-export { justify-content: center; }
  
  .topbar-donation span:first-of-type { font-size: 0.55rem; }
  
  .sidebar-form { max-height: 30vh; }
  
  .preview-scroll {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  .form-card-body { padding: 0.85rem; }
  .form-row.two-col { grid-template-columns: 1fr; gap: 0.5rem; }
  .template-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.3rem;
  }
  .template-grid .tmpl-btn {
    padding: 8px 3px;
    font-size: 0.57rem;
    gap: 2px;
  }
  .template-grid .tmpl-btn .tmpl-icon {
    font-size: 1rem;
  }
  
  .rich-toolbar button { padding: 4px 8px; font-size: 0.7rem; }
  .rich-toolbar { justify-content: center; }
  
  .cv-carta { padding: 15px; }
  .carta-header { flex-direction: column; }
  .carta-data { text-align: left; margin-top: 10px; }
  .carta-destinatario { max-width: 100%; }
}

@media (max-width: 480px) {
  .topbar-donation {
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-donation span:first-of-type { font-size: 0.5rem; }
  
  .preview-scroll {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
  }
}

/* Garantir scroll táctil no desktop */
.preview-scroll {
  -webkit-overflow-scrolling: touch;
}

.preview-page-wrap {
  overflow: visible;
}

.cv-page {
  overflow: visible;
  height: auto;
  min-height: auto;
}

/* Garantir que a formatação da carta seja renderizada corretamente */
.carta-body {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.carta-body b, .carta-body strong {
  font-weight: 700 !important;
}

.carta-body i, .carta-body em {
  font-style: italic !important;
}

.carta-body u {
  text-decoration: underline !important;
}

.carta-body ul, .carta-body ol {
  margin: 8px 0 16px 25px !important;
  padding-left: 0 !important;
}

.carta-body li {
  margin-bottom: 4px !important;
}

.carta-body p {
  margin: 0 0 12px 0 !important;
  line-height: 1.6 !important;
}

/* Botão ativo */
.rich-toolbar button.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ========== LINK GESTÃO NA TOOLBAR ========== */
.gestao-link {
  font-size: 0.75rem; color: #64748b; text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}
.gestao-link:hover { color: #3b82f6; }

/* ========== CONTADOR DE VISUALIZAÇÕES ========== */
.view-counter {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.78rem;
  color: #1e40af;
}
.view-counter i { color: #3b82f6; font-size: 0.8rem; }
.view-counter strong { font-size: 1rem; font-weight: 800; color: #1d4ed8; }
.view-counter span { color: #3b5998; }

.export-counter-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.78rem;
  color: #9a3412;
}
.export-counter-badge i      { color: #f97316; font-size: 0.8rem; }
.export-counter-badge strong { font-size: 1rem; font-weight: 800; color: #c2410c; }
.export-counter-badge span   { color: #7c2d12; }

/* ========== PAINEL DE PUBLICIDADE ========== */
.ads-panel {
  width: 220px;
  flex-shrink: 0;
  background: #f8fafc;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 12px;
  gap: 12px;
  overflow: hidden;
}

.ads-header {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #94a3b8;
  align-self: stretch;
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.ads-header i { margin-right: 5px; }

.ads-carousel {
  width: 196px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.ads-slides {
  width: 196px;
  aspect-ratio: 913 / 3145;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
}

.ads-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.55s ease;
  pointer-events: none;
}
.ads-slide.active {
  opacity: 1;
  pointer-events: auto;
}
.ads-slide img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Placeholders (removidos quando houver imagens reais) */
.ads-placeholder {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.9);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.ads-placeholder i { font-size: 2rem; opacity: 0.7; }
.ads-placeholder small { font-size: 0.65rem; opacity: 0.6; font-weight: 400; }
.ads-placeholder-1 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.ads-placeholder-2 { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.ads-placeholder-3 { background: linear-gradient(135deg, #0ea5e9, #06b6d4); }
.ads-placeholder-4 { background: linear-gradient(135deg, #22c55e, #10b981); }

/* Dots */
.ads-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}
.ads-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s;
}
.ads-dot.active {
  background: #3b82f6;
  transform: scale(1.25);
}
.ads-dot:hover { background: #60a5fa; }

/* Ocultar painel em ecrãs pequenos */
@media (max-width: 1280px) {
  .ads-panel { display: none; }
}

@media print {
  /* Oculta toda a interface — só o conteúdo é impresso */
  .topbar-enhanced,
  .sidebar-form,
  .preview-toolbar,
  .no-print {
    display: none !important;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .app-layout {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .preview-panel {
    display: block !important;
    background: #fff !important;
    overflow: visible !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
  }

  .preview-scroll {
    display: block !important;
    overflow: visible !important;
    background: #fff !important;
    padding: 0 !important;
    height: auto !important;
    max-height: none !important;
  }

  .preview-page-wrap {
    width: 100% !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .cv-page {
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    page-break-inside: auto !important;
  }

  /* Apenas elementos pequenos não se partem — texto longo flui naturalmente */
  .cv-pro-lang, .cv-pro-edu,
  .cv-corp-lang, .cv-corp-edu,
  .cv-cl-edu-item, .cv-exec-edu-item,
  .carta-destinatario, .carta-assunto, .carta-assinatura {
    page-break-inside: avoid !important;
  }
  /* Títulos de secção não ficam sozinhos no fundo da página */
  .cv-pro-section-title, .cv-cl-section-title,
  .cv-exec-section-title, .cv-corp-section-title,
  .cv-corp-item-header, .cv-exec-job-title, .cv-cl-job-title {
    page-break-after: avoid !important;
  }
  /* Cabeçalho de cada entrada de experiência (cargo + período) nunca fica orphão */
  .cv-pro-item-header, .cv-cl-job-header, .cv-exec-job-header, .cv-corp-job-header {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
  /* Linha da empresa mantém-se ligada ao cabeçalho acima */
  .cv-pro-item-sub, .cv-cl-job-company, .cv-exec-job-company, .cv-corp-job-company {
    page-break-before: avoid !important;
    break-before: avoid !important;
  }
  p, li { orphans: 2; widows: 2; }

  /* Carta com margens laterais generosas */
  .cv-carta { padding: 14mm 22mm !important; }

  /* 1ª página: sem margem superior | Restantes: 15mm em cima e em baixo */
  @page {
    size: A4 portrait;
    margin: 15mm 0;
  }

  @page :first {
    size: A4 portrait;
    margin: 0 0 15mm 0;
  }
}

