/* ============================================================
   囍帖製作所 後台（/app/）樣式
   沿用 shared/base.css 的 design tokens（骨白 × 深森林綠）
   ============================================================ */

body {
  font-family: var(--font-serif-tc);
  font-size: var(--text-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100dvh;
}

/* ── 頂欄 ── */
.ap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--gutter);
  border-bottom: 1px solid var(--hairline);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.ap-brand {
  letter-spacing: .25em;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-small);
}
.ap-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: var(--text-small);
  color: var(--ink-soft);
}
.ap-user button {
  font: inherit;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.ap-main {
  max-width: 44rem;
  margin-inline: auto;
  padding: clamp(2rem, 6vw, 3.5rem) var(--gutter) 4rem;
}
.ap-main.is-wide { max-width: 62rem; }

.ap-title { font-size: var(--text-h2); font-weight: 600; letter-spacing: .12em; }
.ap-lead { color: var(--ink-soft); margin-top: .75rem; }

/* ── 卡片 ── */
.ap-card {
  background: var(--paper-raise, #fff);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--hairline);
  padding: clamp(1.5rem, 4vw, 2.25rem);
  margin-top: 1.5rem;
}
.ap-card h2 { font-size: var(--text-h3); font-weight: 600; letter-spacing: .1em; }
.ap-card + .ap-card { margin-top: 1rem; }

/* 狀態徽章 */
.ap-badges { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.badge {
  display: inline-block;
  font-size: var(--text-tiny);
  letter-spacing: .15em;
  padding: .3em .9em;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--ink-soft);
}
.badge.is-on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }

.ap-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

.ap-url {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
.ap-url code {
  font-size: var(--text-small);
  background: var(--paper);
  padding: .4em .8em;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--hairline);
  word-break: break-all;
}

/* ── 訊息 ── */
.ap-note { color: var(--ink-soft); font-size: var(--text-small); margin-top: 1rem; }
.ap-error {
  background: #fdf1f0;
  color: #9a3b31;
  border-radius: 8px;
  padding: .8em 1em;
  margin-top: 1rem;
  font-size: var(--text-small);
}

/* ── 登入畫面 ── */
.ap-login {
  min-height: 70dvh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 1rem;
  padding: var(--gutter);
}
.ap-login h1 { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 700; letter-spacing: .08em; }
.ap-login p { color: var(--ink-soft); max-width: 26em; }
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  margin-inline: auto;
  margin-top: .5rem;
}
.btn-google svg { width: 1.1em; height: 1.1em; }

/* ── 編輯器版面 ── */
.ed-layout { display: grid; gap: 1.5rem; }
@media (min-width: 1100px) {
  .ed-layout { grid-template-columns: minmax(24rem, 30rem) 1fr; align-items: start; }
}
.ed-form-col { display: grid; gap: 1rem; }
.ed-preview-col {
  position: sticky;
  top: 4.5rem;
  display: none;
}
@media (min-width: 1100px) { .ed-preview-col { display: block; } }
.ed-preview-frame {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: calc(100dvh - 6rem);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  background: #fff;
}
.ed-preview-note { font-size: var(--text-tiny); color: var(--ink-soft); text-align: center; margin-top: .5rem; letter-spacing: .1em; }

/* 手機版預覽按鈕（開新分頁） */
.ed-mobile-preview { display: block; }
@media (min-width: 1100px) { .ed-mobile-preview { display: none; } }

/* 摺疊表單區塊 */
details.ed-section {
  background: var(--paper-raise, #fff);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
details.ed-section > summary {
  cursor: pointer;
  list-style: none;
  padding: 1.1rem 1.4rem;
  font-weight: 600;
  letter-spacing: .1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.ed-section > summary::after { content: "＋"; color: var(--accent); font-weight: 400; }
details.ed-section[open] > summary::after { content: "－"; }
.ed-section-body { padding: 0 1.4rem 1.4rem; display: grid; gap: 1rem; }

.ed-field { display: grid; gap: .35rem; }
.ed-field label { font-size: var(--text-small); color: var(--ink-soft); letter-spacing: .08em; }
.ed-field input[type="text"],
.ed-field input[type="date"],
.ed-field input[type="time"],
.ed-field input[type="datetime-local"],
.ed-field select,
.ed-field textarea {
  font: inherit;
  padding: .6em .8em;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}
.ed-field textarea { resize: vertical; }
.ed-row { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.ed-check { display: flex; align-items: center; gap: .5em; font-size: var(--text-small); color: var(--ink-soft); }
.ed-check input { width: 1.05em; height: 1.05em; accent-color: var(--accent); }

/* 動態列表（故事/場次/交通） */
.ed-list { display: grid; gap: .75rem; }
.ed-list-item {
  border: 1px dashed var(--hairline);
  border-radius: 8px;
  padding: .9rem;
  display: grid;
  gap: .6rem;
  position: relative;
}
.ed-list-item .ed-remove {
  position: absolute;
  top: .4rem;
  right: .5rem;
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: .3em;
}
.ed-list-item .ed-remove:hover { color: #9a3b31; }
.ed-add {
  font: inherit;
  font-size: var(--text-small);
  background: none;
  border: 1px dashed var(--accent);
  color: var(--accent);
  border-radius: 8px;
  padding: .55em 1em;
  cursor: pointer;
  justify-self: start;
}

/* 照片上傳 */
.ed-photo { display: grid; gap: .5rem; }
.ed-photo-thumb {
  width: 100%;
  max-width: 14rem;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--hairline);
  background: var(--paper);
}
.ed-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .75rem; }
.ed-photo-cell { position: relative; display: grid; gap: .4rem; }
.ed-photo-cell img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; box-shadow: inset 0 0 0 1px var(--hairline); }
.ed-photo-cell .ed-remove {
  position: absolute; top: .3rem; right: .3rem;
  background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 999px;
  width: 1.6rem; height: 1.6rem;
  cursor: pointer; line-height: 1;
}
.ed-upload-state { font-size: var(--text-tiny); color: var(--ink-soft); }

/* 底部固定儲存列 */
.ed-savebar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-top: 1px solid var(--hairline);
  padding: .75rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 30;
}
.ed-save-status { font-size: var(--text-small); color: var(--ink-soft); }
.ed-save-status.is-saved { color: var(--accent); }
.ed-savebar .ap-actions { margin-top: 0; }
body.has-savebar { padding-bottom: 5.5rem; }

/* ── 對話框（發布 / 付費牆）── */
dialog.ap-dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.5rem, 5vw, 2.25rem);
  max-width: 26rem;
  width: calc(100vw - 2 * var(--gutter));
  background: var(--paper-raise, #fff);
  color: var(--ink);
}
dialog.ap-dialog::backdrop { background: rgba(30, 36, 28, .45); }
.ap-dialog h3 { font-size: var(--text-h3); font-weight: 600; letter-spacing: .1em; }
.ap-dialog p { color: var(--ink-soft); margin-top: .6rem; font-size: var(--text-small); }
.ap-dialog .price { font-family: var(--font-serif-latin); font-size: 2.2rem; margin-top: .8rem; }
.ap-dialog ul { margin-top: .8rem; display: grid; gap: .4rem; font-size: var(--text-small); }
.ap-dialog li { padding-left: 1.3em; position: relative; }
.ap-dialog li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 600; }
.ap-dialog .ap-actions { margin-top: 1.5rem; }
.ap-dialog .ap-agree { margin-top: 1.1rem; align-items: flex-start; }
.ap-dialog .ap-agree input { margin-top: .3em; flex-shrink: 0; }
.ap-dialog .ap-agree a { color: var(--accent); text-decoration: underline; text-underline-offset: .2em; }

/* ── RSVP 統計 ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: .75rem;
  margin-top: 1.25rem;
}
.stat-cell {
  background: var(--paper-raise, #fff);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--hairline);
  padding: 1rem;
  display: grid;
  gap: .2rem;
}
.stat-cell strong { font-family: var(--font-serif-latin); font-size: 1.9rem; line-height: 1; }
.stat-cell span { font-size: var(--text-tiny); color: var(--ink-soft); letter-spacing: .12em; }

.rsvp-table-wrap { overflow-x: auto; margin-top: 1.5rem; }
table.rsvp-table { width: 100%; border-collapse: collapse; font-size: var(--text-small); }
.rsvp-table th, .rsvp-table td {
  text-align: left;
  padding: .6em .8em;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.rsvp-table td.wrap { white-space: normal; min-width: 14em; }
.rsvp-table th { color: var(--ink-soft); font-weight: 600; letter-spacing: .1em; font-size: var(--text-tiny); }

/* ── 模板選擇器（編輯器） ── */
.ed-tpl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
}
.ed-tpl-card {
  display: grid;
  gap: .35rem;
  justify-items: center;
  padding: .6rem .5rem .7rem;
  border-radius: calc(var(--radius) * .6);
  background: var(--paper-raise, #fff);
  box-shadow: inset 0 0 0 1px var(--hairline);
  text-align: center;
  transition: box-shadow .25s var(--ease-out);
}
.ed-tpl-card:hover { box-shadow: inset 0 0 0 1px var(--ink-soft); }
.ed-tpl-card.is-active { box-shadow: inset 0 0 0 2px var(--accent); }
.ed-tpl-swatch {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius) * .4);
  display: grid;
  place-items: center;
  font-family: var(--font-serif-tc);
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.ed-tpl-name { font-size: var(--text-small); font-weight: 600; letter-spacing: .06em; }
.ed-tpl-desc { font-size: var(--text-tiny); color: var(--ink-soft); letter-spacing: .04em; }
.ed-tpl-hint { font-size: var(--text-tiny); color: var(--ink-soft); margin-top: .75rem; }

/* 通用 */
.hidden { display: none !important; }
