*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --red: #e8140e;
  --red-hover: #c01109;

  /* tokens de tema (claro) */
  --bg: #eeeef4;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #fafafa;
  --text-strong: #111827;
  --text: #1f2937;
  --text-2: #374151;
  --text-3: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border: #e5e7eb;
  --border-2: #d1d5db;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text); background: var(--bg);
  min-height: 100vh; display: flex; flex-direction: column;
  transition: background .25s ease, color .25s ease;
}

/* ── NAV ── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 32px; height: 56px; gap: 0;
  transition: background .25s ease, border-color .25s ease;
}
.logo { display: flex; align-items: center; font-size: 22px; font-weight: 900; color: var(--text); text-decoration: none; margin-right: 28px; }
.logo-heart { color: var(--red); }
.logo span { font-style: italic; }
nav ul { display: flex; list-style: none; gap: 4px; flex: 1; }
nav ul li a { font-size: 13px; font-weight: 600; color: var(--text-2); text-decoration: none; padding: 8px 10px; border-radius: 6px; display: flex; align-items: center; gap: 4px; white-space: nowrap; transition: background .15s, color .15s; }
nav ul li a:hover { background: var(--surface-2); }
nav ul li a.active { color: var(--red); }
.chevron { font-size: 10px; color: var(--text-faint); }

/* ── DROPDOWN MENUS ── */
nav ul li.has-dropdown { position: relative; }
nav .dropdown {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.14);
  padding: 10px; min-width: 230px;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity .15s, transform .15s; z-index: 200;
}
nav ul li.has-dropdown:hover .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
nav .dropdown::before { content: ""; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }
nav .dropdown ul { display: block; list-style: none; flex: none; gap: 0; }
nav .dropdown li a { font-size: 13px; font-weight: 500; padding: 8px 10px; border-radius: 6px; color: var(--text-2); display: block; }
nav .dropdown li a:hover { background: var(--surface-2); color: var(--red); }
nav .dropdown-mega { display: grid; grid-template-columns: repeat(3, 172px); gap: 4px 14px; left: auto; right: 0; min-width: 0; }
nav .dropdown-mega .dropdown-col { min-width: 0; }
nav .dropdown-mega h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); padding: 6px 10px 4px; margin: 0; }

/* ── UPLOAD STATE (before files) ── */
#uploadState {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  text-align: center; padding: 72px 24px 80px;
}
#uploadState h1 { font-size: clamp(28px, 3.5vw, 44px); font-weight: 800; color: var(--text-strong); margin-bottom: 16px; }
#uploadState p { font-size: 17px; color: var(--text-3); max-width: 620px; margin: 0 auto 40px; line-height: 1.6; }

.upload-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 14px; }
.btn-upload {
  display: flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff;
  font-size: 18px; font-weight: 700; padding: 20px 48px;
  border-radius: 14px; border: none; cursor: pointer;
  transition: background .15s, transform .1s; min-width: 320px;
  letter-spacing: 0.01em;
}
.btn-upload:hover { background: var(--red-hover); transform: translateY(-1px); }
.cloud-btns { display: flex; flex-direction: column; gap: 8px; }
.cloud-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--red); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.cloud-btn:hover { background: var(--red-hover); }
.cloud-btn svg { width: 22px; height: 22px; fill: #fff; }
.drop-hint { font-size: 13px; color: var(--text-faint); }

/* ── EDITOR STATE (after files) ── */
#editorState {
  flex: 1; display: none;
  flex-direction: row; overflow: hidden;
}
#editorState.visible { display: flex; }

/* Left: file area */
.file-area {
  flex: 1; overflow-y: auto;
  padding: 40px 32px; position: relative;
  display: flex; flex-direction: column; align-items: center;
}
.file-cards {
  display: flex; flex-wrap: wrap; gap: 20px;
  justify-content: center; width: 100%;
}

/* PDF card (a página em si é "papel": permanece branca nos dois temas) */
.pdf-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: grab; animation: fadeUp .2s ease;
}
.pdf-card.dragging { opacity: .4; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.pdf-thumb {
  width: 160px; height: 210px;
  background: #fff; border-radius: 6px;
  border: 1px solid var(--border-2);
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  transition: box-shadow .15s;
}
.pdf-thumb:hover { box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.pdf-thumb canvas { max-width: 100%; max-height: 100%; }
.pdf-thumb-inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 10px;
}
.pdf-thumb-lines { width: 80%; display: flex; flex-direction: column; gap: 5px; }
.pdf-thumb-line { height: 5px; border-radius: 2px; background: #e5e7eb; }
.pdf-thumb-line:nth-child(1) { width: 90%; }
.pdf-thumb-line:nth-child(2) { width: 75%; }
.pdf-thumb-line:nth-child(3) { width: 85%; }
.pdf-thumb-line:nth-child(4) { width: 60%; }
.pdf-thumb-line:nth-child(5) { width: 80%; }
.pdf-thumb-line:nth-child(6) { width: 70%; }
.pdf-thumb-icon { font-size: 28px; color: #e8140e; }
.pdf-thumb-badge { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.pdf-card-remove {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.4); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; line-height: 1;
  opacity: 0; transition: opacity .15s;
}
.pdf-thumb:hover .pdf-card-remove { opacity: 1; }
.pdf-card-name { font-size: 12px; color: var(--text-2); text-align: center; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Add more btn */
.add-more-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 22px; font-weight: 300;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  margin-top: 8px; align-self: center;
  box-shadow: 0 2px 8px rgba(232,20,14,.35);
  transition: background .15s, transform .1s;
}
.add-more-btn:hover { background: var(--red-hover); transform: scale(1.07); }

/* img/other file card */
.img-thumb {
  width: 160px; height: 210px; border-radius: 6px;
  border: 1px solid var(--border-2); overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  position: relative;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ── SIDEBAR ── */
.sidebar {
  width: 360px; min-width: 320px;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
  transition: background .25s ease, border-color .25s ease;
}
.sidebar-header { padding: 28px 24px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 22px; font-weight: 800; color: var(--text-strong); }
.sidebar-options { flex: 1; padding: 20px 24px; display: flex; flex-direction: column; gap: 0; }

/* Option sections */
.opt-section { margin-bottom: 20px; }
.opt-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.opt-info { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-faint); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: var(--text-faint); cursor: help; }

/* Radio option */
.opt-radio {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 8px;
  border: 1.5px solid var(--border); margin-bottom: 8px;
  cursor: pointer; transition: border-color .15s, background .15s;
  position: relative;
}
.opt-radio input[type=radio] { display: none; }
.opt-radio.selected { border-color: var(--border); background: var(--surface-3); }
.opt-radio:hover { border-color: var(--text-faint); }
.opt-radio-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.opt-radio-text strong { font-size: 14px; font-weight: 700; color: var(--text-strong); }
.opt-radio-text small { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.opt-check { width: 24px; height: 24px; border-radius: 50%; background: #16a34a; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff; flex-shrink: 0; margin-left: auto; }

/* Toggle group */
.toggle-group { display: flex; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--border); }
.toggle-btn { flex: 1; padding: 10px; font-size: 13px; font-weight: 600; background: var(--surface); border: none; cursor: pointer; color: var(--text-2); transition: all .15s; }
.toggle-btn.active { background: var(--surface); color: var(--red); border: 2px solid var(--red); border-radius: 6px; margin: -1px; }

/* Premium badge */
.badge-premium { display: inline-flex; align-items: center; gap: 3px; background: #fef9c3; color: #854d0e; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 4px; }

/* Input */
.opt-input { width: 100%; border: 1.5px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; color: var(--text-2); background: var(--surface); outline: none; transition: border-color .15s; }
.opt-input:focus { border-color: var(--text-faint); }
textarea.opt-input { resize: vertical; min-height: 70px; font-family: inherit; }

/* Action button */
.sidebar-action { padding: 20px 24px; border-top: 1px solid var(--border); margin-top: auto; }
.btn-action {
  width: 100%; padding: 18px; border-radius: 12px;
  background: var(--red); color: #fff;
  font-size: 16px; font-weight: 700; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  transition: background .15s, transform .1s;
}
.btn-action:hover { background: var(--red-hover); transform: translateY(-1px); }
.btn-action:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-action .arrow { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); display: flex; align-items: center; justify-content: center; font-size: 14px; }

/* ── DROP OVERLAY ── */
.drop-zone { position: fixed; inset: 0; z-index: 200; background: rgba(232,20,14,.08); border: 4px dashed var(--red); display: none; align-items: center; justify-content: center; pointer-events: none; }
.drop-zone.active { display: flex; }
.drop-zone span { font-size: 22px; font-weight: 700; color: var(--red); background: var(--surface); padding: 16px 32px; border-radius: 12px; }

/* ── LOADING STATE ── */
#loadingState {
  display: none; flex: 1;
  flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 100px 24px; text-align: center;
}
#loadingState.visible { display: flex; }
.spinner-wrap { margin-bottom: 28px; }
.spinner {
  width: 64px; height: 64px;
  border: 5px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingState h2 { font-size: 20px; font-weight: 700; color: var(--text-2); }
#loadingState p { font-size: 14px; color: var(--text-faint); margin-top: 8px; }

/* ── RESULT STATE ── */
#resultState {
  display: none; flex: 1;
  flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 72px 24px 48px; text-align: center;
}
#resultState.visible { display: flex; }
#resultState h1 { font-size: clamp(22px, 3vw, 34px); font-weight: 800; color: var(--text-strong); margin-bottom: 36px; max-width: 700px; line-height: 1.2; }
.result-row { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.btn-back {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface-2); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-2); transition: background .15s;
  flex-shrink: 0;
}
.btn-back:hover { background: var(--border-2); }
.btn-download {
  display: flex; align-items: center; gap: 12px;
  background: var(--red); color: #fff;
  font-size: 18px; font-weight: 700; padding: 18px 44px;
  border-radius: 14px; border: none; cursor: pointer;
  transition: background .15s, transform .1s; min-width: 300px; justify-content: center;
}
.btn-download:hover { background: var(--red-hover); transform: translateY(-1px); }

/* Error / notice card */
.notice-card {
  background: var(--surface); border: 1.5px solid #fecaca;
  border-radius: 12px; padding: 24px 28px;
  max-width: 640px; width: 100%; text-align: left; margin-bottom: 32px;
}
.notice-card.warn { border-color: #fde68a; background: #fffbeb; }
.notice-card h3 { font-size: 16px; font-weight: 800; color: var(--text-strong); margin-bottom: 8px; }
.notice-card p { font-size: 14px; color: var(--text-3); line-height: 1.6; }

/* Security card */
.security-card {
  background: var(--surface); border: 1.5px solid #bae6fd;
  border-radius: 12px; padding: 28px 32px;
  max-width: 720px; width: 100%; text-align: left;
}
.security-card h3 { font-size: 18px; font-weight: 800; color: var(--text-strong); margin-bottom: 12px; }
.security-card p { font-size: 14px; color: var(--text-3); line-height: 1.6; margin-bottom: 20px; }
.security-card p a { color: var(--text-strong); font-weight: 700; }
.security-logos { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.security-logo { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.security-logo span { font-size: 9px; font-weight: 700; color: var(--text-muted); letter-spacing: .5px; text-align: center; }

/* ── FOOTER ── */
footer { background: var(--surface); border-top: 1px solid var(--border); padding: 14px 32px; text-align: center; font-size: 12px; color: var(--text-faint); transition: background .25s ease, border-color .25s ease; }

#fileInput { display: none; }

.opt-radio:not(.selected):hover { background: var(--surface-3); }
