/* Dashboard UI (the posters themselves are styled in templates.css) */
:root {
  --primary: #3a21a3;
  --primary-2: #4f35c9;
  --primary-soft: #efebfc;
  --secondary: #525060;
  --ink: #1d1a2e;
  --muted: #6d6a7c;
  --line: #e4e1ee;
  --bg: #f6f5fb;
  --panel: #ffffff;
  --danger: #c2334d;
  --radius: 10px;
  font-family: 'Inter', 'Noto Sans Malayalam', system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

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

/* ---------- Nav ---------- */
.nav {
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 24px;
}
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.nav-brand img { width: 34px; height: 37px; filter: brightness(0) invert(1); }
.nav-brand b { display: block; font-size: 17px; font-weight: 700; }
.nav-brand span { display: block; font-size: 12px; font-weight: 300; opacity: .8; }
.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 0; border-radius: 8px;
  background: transparent; color: rgba(255,255,255,.82);
  font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
}
.nav-link svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: #fff; color: var(--primary); font-weight: 600; }
.nav-foot { margin-top: auto; font-size: 12px; padding: 0 6px; line-height: 1.5; }

/* ---------- Editor ---------- */
.editor {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
.editor-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 12px;
}
.editor-head h1 { margin: 0; font-size: 20px; font-weight: 700; color: var(--primary); }
.editor-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.doc-actions { display: flex; gap: 8px; }
.doc-actions[hidden] { display: none; }
.saved-select {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; background: #fff; font-size: 13px;
}

.form { overflow-y: auto; padding: 6px 20px 40px; flex: 1; }

.sec { border-bottom: 1px solid var(--line); padding: 16px 0; }
.sec:last-child { border-bottom: 0; }
.sec-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--secondary); margin: 0 0 12px;
}
.sec-hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; line-height: 1.45; }

.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 10px; }
.fld { grid-column: span 6; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld.w3 { grid-column: span 3; }
.fld.w2 { grid-column: span 2; }
.fld.w4 { grid-column: span 4; }
.fld label { font-size: 12px; font-weight: 600; color: var(--secondary); }
.fld .hint { font-size: 11.5px; color: var(--muted); }
.fld input[type=text], .fld input[type=number], .fld input[type=date], .fld select, .fld textarea {
  width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; background: #fff;
  outline: none;
}
.fld textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(79,53,201,.15);
}

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 6px;
  padding: 7px 6px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(29,26,46,.12); }

.seg.multi { flex-wrap: wrap; }
.seg.multi button { flex: 0 0 auto; padding: 7px 12px; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatch {
  border: 2px solid transparent; border-radius: 10px; padding: 0; cursor: pointer;
  background: none; text-align: center; font-size: 12px; font-weight: 600; color: var(--secondary);
}
.swatch i { display: block; height: 46px; border-radius: 8px; margin-bottom: 5px; border: 1px solid var(--line); }
.swatch.on { color: var(--primary); }
.swatch.on i { outline: 2px solid var(--primary); outline-offset: 2px; }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--primary); }

.img-field { display: flex; gap: 10px; align-items: center; }
.img-thumb {
  width: 64px; height: 48px; border-radius: 6px; border: 1px dashed var(--line);
  background: var(--bg) center/cover no-repeat; flex: none;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.li { border: 1px solid var(--line); border-radius: var(--radius); background: #fcfbff; }
.li-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--line);
}
.li-title { flex: 1; font-size: 13px; font-weight: 600; color: var(--primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-body { padding: 10px 12px 12px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn.del:hover { background: #fbe9ec; color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

.btn {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary-2); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); color: #fff; }
.btn.add { width: 100%; border-style: dashed; color: var(--primary); background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: wait; }

/* ---------- Preview ---------- */
.preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.preview-info { font-size: 13px; color: var(--muted); }
.preview-actions { display: flex; gap: 8px; }
.stage-wrap { flex: 1; overflow: auto; padding: 28px; min-height: 0; }
.stage { margin: 0 auto; display: flex; flex-direction: column; gap: 24px; align-items: center; }
.stage-item { position: relative; flex: none; box-shadow: 0 10px 40px rgba(29,26,46,.18); border-radius: 4px; overflow: hidden; }
.stage-item > .scaler { transform-origin: top left; position: absolute; top: 0; left: 0; }

/* Off-screen area used to measure pages and render exports at full size */
.offscreen { position: fixed; left: -20000px; top: 0; pointer-events: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; opacity: 0; transition: .25s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Settings view has no preview */
.app.no-preview { grid-template-columns: 220px minmax(340px, 640px) 1fr; }
.app.no-preview .preview { visibility: hidden; }

@media (max-width: 1100px) {
  .app, .app.no-preview { grid-template-columns: 1fr; grid-template-rows: auto auto auto; height: auto; }
  .nav { flex-direction: row; align-items: center; padding: 10px 16px; gap: 16px; overflow-x: auto; }
  .nav-links { flex-direction: row; }
  .nav-link span { white-space: nowrap; }
  .editor { border-right: 0; }
  .form { overflow: visible; }
  .stage-wrap { padding: 16px; min-height: 70vh; }
  .app.no-preview .preview { display: none; }
}
