/* ======================================================================
   Biodata Builder — editorial shell (aligned to landing page)
   ====================================================================== */

:root {
  --ink: #1c1a17;
  --ink-soft: #4a4640;
  --muted: #7f776d;
  --line: #ddd6cb;
  --line-strong: #cbbfaf;
  --paper: #fbfaf6;
  --paper-2: #f3eee4;
  --paper-3: #efe8db;
  --accent: #2f7a74;
  --accent-2: #225e59;
  --danger: #a24646;
  --radius: 10px;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at 15% -20%, #fffefb 0, var(--paper) 45%, #f6f1e8 100%);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  display: grid;
  grid-template-columns: minmax(360px, 470px) 1fr;
  height: 100vh;
}

/* ============ EDITOR ============ */
.editor {
  background: linear-gradient(180deg, #fdfbf7 0%, var(--paper-2) 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.editor-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-back {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  font-size: 14px;
  transition: all 0.18s ease;
}
.editor-back:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.85);
}

.editor-header h1 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 30px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form {
  padding: 18px 20px 80px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

fieldset.section {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  backdrop-filter: blur(3px);
  box-shadow: 0 12px 24px -22px rgba(63, 57, 47, 0.45);
  padding: 14px 13px 12px;
}

fieldset.section > legend {
  padding: 0 7px;
  font-family: "Cormorant Garamond", serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--ink);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 11px;
}
.field:last-child { margin-bottom: 0; }

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="date"],
.field input[type="time"],
.field textarea,
.field select,
.template-select,
.row input[type="text"],
.row input[type="date"],
.row input[type="time"],
.row select {
  width: 100%;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.field select,
.row select,
.template-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, #7c7266 50%),
    linear-gradient(135deg, #7c7266 50%, transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 240, 231, 0.92));
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 13px) calc(50% - 2px),
    0 0;
  background-size: 5px 5px, 5px 5px, 100% 100%;
  background-repeat: no-repeat;
}

.field input[type="date"],
.field input[type="time"],
.row input[type="date"],
.row input[type="time"] {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 10px;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.template-select:focus,
.row input:focus {
  outline: none;
  border-color: #b9aa95;
  box-shadow: 0 0 0 3px rgba(216, 204, 186, 0.45);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1.35fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 7px;
}

.row-actions {
  display: flex;
  gap: 5px;
}

.row-actions button,
.photo-slot .photo-actions button,
.add-row {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.row-actions button,
.photo-slot .photo-actions button {
  font-size: 12px;
  padding: 5px 8px;
}

.row-actions button:hover,
.photo-slot .photo-actions button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.add-row {
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
}
.add-row:hover {
  border-color: var(--line-strong);
  background: #fefcf8;
}

.photos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-slot {
  background: rgba(255, 255, 255, 0.85);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.photo-slot img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line);
}

.photo-slot-empty {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 7px;
  background: #fffcf8;
  border: 1px solid var(--line);
  font-size: 12px;
}

.photo-slot label {
  font-size: 11px;
  color: var(--ink-soft);
  cursor: pointer;
}

.photo-slot input[type="file"] { display: none; }

.photo-slot .photo-actions {
  display: flex;
  gap: 6px;
}

/* ============ BUTTONS ============ */
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: #b9aa95;
}

.btn--primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border-color: transparent;
}

.btn--primary:hover {
  filter: brightness(1.03);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.74);
}

.btn[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

/* ============ PREVIEW ============ */
.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, #f4eee2 0%, #efe8da 100%);
}

.preview-bar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(251, 248, 240, 0.85);
}

.preview-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-title {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 600;
}

.template-select {
  width: auto;
  min-width: 220px;
  cursor: pointer;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.preview-stage {
  flex: 1;
  overflow: auto;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background:
    radial-gradient(circle at 100% 0, rgba(255, 255, 255, 0.52) 0, rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #f2ebde 0%, #ebe1d0 100%);
}

.preview-scale {
  transform-origin: top center;
}

#preview-root .page {
  width: 794px;
  margin: 0;
  box-shadow: 0 18px 40px -24px rgba(43, 36, 26, 0.55);
  color: #1a1a1a;
}

#preview-root .page.preview-watermarked {
  position: relative;
  overflow: hidden;
}

.preview-watermark-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  user-select: none;
}

.preview-watermark-mark {
  position: absolute;
  transform: rotate(-28deg);
  transform-origin: center;
  font-family: "Cormorant Garamond", serif;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 1.8px;
  color: rgba(70, 63, 55, 0.2);
  white-space: nowrap;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fefcf8;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 10px 15px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 18px 30px -26px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(36, 30, 23, 0.36);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(540px, 100%);
  background: linear-gradient(180deg, #fffdf8 0%, #f8f2e8 100%);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 32px 50px -34px rgba(0, 0, 0, 0.55);
  padding: 20px 18px 16px;
}

.modal-title {
  margin: 0 0 8px;
  font-family: "Cormorant Garamond", serif;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.2px;
}

.modal-copy {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1040px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  html,
  body {
    height: auto;
  }

  .editor {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .preview {
    min-height: 70vh;
  }

  .preview-stage {
    padding: 20px 12px 32px;
  }

  .preview-bar {
    flex-wrap: wrap;
  }

  .template-select {
    min-width: 190px;
  }
}
