/* ─── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f4f4f5;
  --surface:  #ffffff;
  --border:   #e4e4e7;
  --text:     #18181b;
  --muted:    #71717a;
  --accent:   #6366f1;
  --radius:   12px;
  --shadow:   0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.06);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* File input is off-screen but reachable — the <label for> association
   triggers it natively without any JS .click() workaround. */
.file-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ─── Shared Header ─────────────────────────────────────── */
.header, .editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.logo-mark { width: 24px; height: 24px; object-fit: contain; }
.logo-text  { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; color: var(--text); }

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.file-name {
  color: var(--muted);
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Landing ───────────────────────────────────────────── */
.landing-main {
  max-width: 580px;
  margin: 0 auto;
  padding: 60px 24px 80px;
  text-align: center;
}

.hero-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 18px;
}
.hero-sub {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 48px;
}

/* Drop Zone */
.drop-zone {
  cursor: pointer;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 32px;
  cursor: pointer;
  margin-bottom: 40px;
  transition: border-color 0.18s, background 0.18s;
  outline: none;
}
.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--accent); background: #eef2ff; }
.drop-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.drop-inner { pointer-events: none; }

.drop-icon  { font-size: 44px; margin-bottom: 12px; }
.drop-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.drop-sub   { color: var(--muted); font-size: 14px; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* Features */
.features {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}
.feature {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}
.feat-icon { font-size: 15px; }

/* ─── Editor Layout ─────────────────────────────────────── */
#editor { display: flex; flex-direction: column; height: 100vh; }

.editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ─── Preview Panel ─────────────────────────────────────── */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 10px;
  overflow: auto;
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(:disabled) { background: var(--bg); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-info { font-size: 13px; color: var(--muted); min-width: 80px; text-align: center; }

.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.canvas-container {
  position: relative;
  display: inline-block;
  box-shadow: var(--shadow);
  border-radius: 2px;
}

#pdf-canvas {
  display: block;
  border-radius: 2px;
}

.drag-hint {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

/* ─── Stamp Overlay ─────────────────────────────────────── */
.stamp-overlay {
  position: absolute;
  cursor: grab;
  user-select: none;
  pointer-events: auto;
  /* transform-origin: 0 0 is set in JS; using translate(-50%,-50%) + rotate
     keeps the visual center fixed at the (left, top) anchor point */
  transform-origin: 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 18px;
  border: 3px solid currentColor;
  border-radius: 3px;
  white-space: nowrap;
  line-height: 1.1;
}
.stamp-overlay:active { cursor: grabbing; }

.stamp-text {
  font-weight: 900;
  font-family: 'Inter', Arial, sans-serif;
  letter-spacing: 0.12em;
  line-height: 1;
}
.stamp-sub-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 5px;
  opacity: 0.9;
}

/* ─── Controls Panel ────────────────────────────────────── */
.controls-panel {
  width: 272px;
  min-width: 272px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.controls-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.val-badge {
  background: var(--bg);
  color: var(--text);
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

/* Stamp type grid */
.stamp-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.stamp-type-btn {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 9px 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface);
  color: var(--muted);
  transition: all 0.12s;
  letter-spacing: 0.05em;
  font-family: inherit;
}
.stamp-type-btn:hover { border-color: var(--text); color: var(--text); }

.stamp-type-btn[data-type="PAID"]   { color: #16a34a; }
.stamp-type-btn[data-type="UNPAID"] { color: #ea580c; }
.stamp-type-btn[data-type="VOID"]   { color: #dc2626; }
.stamp-type-btn[data-type="CUSTOM"] { color: #6366f1; }

.stamp-type-btn[data-type="PAID"].active   { border-color: #16a34a; background: #f0fdf4; }
.stamp-type-btn[data-type="UNPAID"].active { border-color: #ea580c; background: #fff7ed; }
.stamp-type-btn[data-type="VOID"].active   { border-color: #dc2626; background: #fef2f2; }
.stamp-type-btn[data-type="CUSTOM"].active { border-color: #6366f1; background: #eef2ff; }

/* Color row */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, border-color 0.12s;
}
.swatch:hover   { transform: scale(1.2); }
.swatch.active  { border-color: var(--text); transform: scale(1.15); }

.color-picker {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  background: none;
  flex-shrink: 0;
}
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border-radius: 50%; border: none; }

/* Sliders */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* Toggle switches */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.toggle-input { display: none; }
.toggle-track {
  width: 34px;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  position: relative;
  transition: background 0.18s;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.toggle-input:checked + .toggle-track             { background: var(--accent); }
.toggle-input:checked + .toggle-track::after      { transform: translateX(16px); }
.toggle-label { font-size: 13px; }

/* Text inputs */
.text-input {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--accent); }

/* Radio group */
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.radio-row input[type="radio"] { accent-color: var(--accent); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: white;
  padding: 11px 22px;
}
.btn-primary:hover   { background: #4f46e5; }
.btn-primary:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}
.btn-success,
.btn-success:disabled,
.btn-success:hover {
  background: #16a34a !important;
  color: white !important;
  cursor: default;
  transform: none;
}

.btn-ghost {
  background: none;
  color: var(--muted);
  padding: 7px 12px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-large { width: 100%; padding: 14px; font-size: 15px; border-radius: 10px; }
.btn-sm    { font-size: 12px; padding: 5px 10px; font-weight: 500; }

.controls-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Save toast ─────────────────────────────────────────── */
.save-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 12px;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.save-toast-icon  { font-size: 15px; color: #16a34a; flex-shrink: 0; font-weight: 700; }
.save-toast-body  { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.save-toast-title { font-size: 12px; font-weight: 700; color: #15803d; }
.save-toast-file  {
  font-size: 11px;
  color: #166534;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.save-toast-action {
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font: 600 11px/1 inherit;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.save-toast-action:hover { background: #15803d; }
.save-toast-close {
  background: none;
  border: none;
  color: #86efac;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  flex-shrink: 0;
  line-height: 1;
}
.save-toast-close:hover { color: #15803d; }

/* ─── Nag / Thanks Banners ──────────────────────────────── */
.nag-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px 0;
  text-align: center;
}
.nag-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.nag-link:hover { color: #4f46e5; }

.thanks-banner {
  font-size: 12px;
  color: #16a34a;
  text-align: center;
  padding: 8px 4px 0;
}

/* ─── Thanks Toast ──────────────────────────────────────── */
.thanks-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #16a34a;
  color: white;
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  z-index: 2000;
  max-width: 400px;
  width: max-content;
}
.thanks-toast-icon { font-size: 22px; }
.thanks-toast strong { display: block; font-size: 14px; margin-bottom: 2px; }
.thanks-toast p { font-size: 12px; opacity: 0.88; margin: 0; }

/* ─── About Modal ───────────────────────────────────────── */
.about-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.about-version { font-size: 12px; color: var(--muted); margin-top: 2px; }

.about-rows { display: flex; flex-direction: column; gap: 0; }
.about-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.about-row:last-child { border-bottom: none; }
.about-label { color: var(--muted); }

.text-link { color: var(--accent); text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* Update dot on About button */
.about-btn { position: relative; }
.update-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  background: #ea580c;
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* ─── License Modal ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  padding: 32px;
  width: min(480px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-body  { color: var(--muted); font-size: 13px; line-height: 1.6; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.license-msg          { font-size: 12px; min-height: 16px; }
.license-msg--error   { color: #dc2626; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  .editor-body { flex-direction: column; }
  .controls-panel { width: 100%; min-width: unset; border-left: none; border-top: 1px solid var(--border); max-height: 50vh; }
  .preview-panel { flex: none; height: 50vh; }
  .hero-title { font-size: 30px; }
}
