/* Giao diện trang chủ / trang quản trị (không phải thiệp) */
:root {
  --bg: #faf7f5; --panel: #ffffff; --line: #ebe3df; --text: #2d2424; --muted: #8a7d7a;
  --brand: #b4485c; --brand-2: #f3d3d8; --ok: #2f7d55; --warn: #b26a00; --err: #b3261e;
  --radius: 14px; --shadow: 0 6px 24px rgba(60, 30, 30, .08);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .container { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.logo { font-weight: 700; color: var(--brand); text-decoration: none; display: flex; gap: 8px; align-items: center; font-size: 1.05rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 10px 18px; border-radius: 999px; font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
.muted { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* trang chủ */
.hero { text-align: center; padding: 56px 0 32px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
.hero p { max-width: 620px; margin: 0 auto 22px; color: var(--muted); }
/* trang chọn mẫu: mỗi ô là bìa thiệp thật khổ điện thoại, tên mẫu gọn bên dưới */
.gallery-head { text-align: center; margin: 8px 0 22px; scroll-margin-top: 80px; }
.gallery-head h2 { margin: 0 0 4px; }
.gallery-head p { margin: 0; color: var(--muted); font-size: .92rem; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 26px 18px; padding-bottom: 60px; }
.theme-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.theme-thumb { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 22px rgba(40,20,30,.10); transition: transform .35s ease, box-shadow .35s ease; }
.theme-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.theme-thumb:not(.is-cover) img { object-position: center; }
.theme-thumb:hover { transform: translateY(-4px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 16px 34px rgba(40,20,30,.18); }
.theme-badge { position: absolute; top: 8px; right: 8px; z-index: 1; font-size: .7rem; font-weight: 600; background: rgba(255,255,255,.92);
  color: #333; padding: 2px 9px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.theme-hover { position: absolute; inset: 0; display: grid; place-items: end center; padding-bottom: 18px; opacity: 0;
  background: linear-gradient(transparent 55%, rgba(0,0,0,.45)); transition: opacity .3s ease; }
.theme-hover em { font-style: normal; font-size: .85rem; font-weight: 600; background: #fff; color: var(--brand); padding: 7px 18px; border-radius: 999px; }
.theme-thumb:hover .theme-hover, .theme-thumb:focus-visible .theme-hover { opacity: 1; }
.theme-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 2px; }
.theme-meta h3 { margin: 0; font-size: .98rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-use { flex-shrink: 0; font-size: .82rem; font-weight: 600; color: var(--brand); text-decoration: none; }
.theme-use:hover { text-decoration: underline; }
@media (max-width: 560px) { .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; } }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: .75rem; background: var(--brand-2); color: var(--brand); padding: 2px 8px; border-radius: 999px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 0 0 40px; }
.feature { padding: 14px 16px; font-size: .92rem; }
.feature b { display: block; margin-bottom: 2px; }

/* trang quản trị: tạo / sửa thiệp */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; padding: 22px 16px 120px; max-width: 1180px; margin: 0 auto; }
.editor-form { display: grid; gap: 16px; }
.step { padding: 18px; }
.step h2 { font-size: 1.1rem; display: flex; gap: 10px; align-items: center; }
.step h2 .num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: .85rem; }
.step .hint { margin: -4px 0 12px; color: var(--muted); font-size: .88rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; font-size: .88rem; font-weight: 500; }
.field input, .field select, .field textarea { font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand-2); border-color: var(--brand); }
.field .err { color: var(--err); font-size: .8rem; font-weight: 400; }
.sub { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; position: relative; }
.sub + .sub { margin-top: 10px; }
.sub-title { font-weight: 600; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; }
.link-btn { background: none; border: 0; color: var(--err); cursor: pointer; font: inherit; font-size: .85rem; }

.theme-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.theme-opt { border: 2px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; text-align: left; padding: 0; font: inherit; }
.theme-opt.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-2); }
.theme-opt .sw { height: 54px; display: flex; }
.theme-opt .sw i { flex: 1; }
.theme-opt .meta { padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.theme-opt .meta b { font-size: .92rem; }
.theme-opt .meta a { font-size: .8rem; white-space: nowrap; }

.opt-group { margin-bottom: 14px; }
.opt-group > span { display: block; font-size: .88rem; font-weight: 500; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 6px; background: #fff; cursor: pointer; font: inherit; font-size: .85rem; display: inline-flex; gap: 6px; align-items: center; }
.chip.is-on { border-color: var(--brand); background: var(--brand-2); }
.chip .dots { display: inline-flex; }
.chip .dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; margin-left: -5px; }
.chip .dots i:first-child { margin-left: 0; }
.chip.fx::before { content: "✦"; color: var(--brand); padding-left: 6px; }

.uploads { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; display: block; font-size: .9rem; }
.drop:hover { border-color: var(--brand); color: var(--brand); }
.drop input { display: none; }
.cover-box { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; }
.cover-box .thumb { aspect-ratio: 3/4; }

.slug-row { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.slug-row span { background: #f4efed; padding: 9px 10px; color: var(--muted); font-size: .88rem; white-space: nowrap; display: flex; align-items: center; }
.slug-row input { border: 0 !important; border-radius: 0 !important; outline: none !important; }
.slug-state { font-size: .82rem; margin-top: 4px; }
.slug-state.ok { color: var(--ok); } .slug-state.bad { color: var(--err); }

.preview-col { position: sticky; top: 76px; align-self: start; display: grid; gap: 10px; justify-items: center; }
.phone { width: 360px; height: 720px; border-radius: 40px; border: 10px solid #1d1b1b; background: #1d1b1b; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.25); position: relative; }
.phone iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 30px; }
.phone .loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.35); font-size: .9rem; }
.phone .loading[hidden] { display: none; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); z-index: 30; }
.actionbar .container { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
.actionbar .msg { font-size: .88rem; }
.msg.err { color: var(--err); } .msg.ok { color: var(--ok); }

.modal { position: fixed; inset: 0; z-index: 90; background: rgba(20,10,10,.6); display: grid; place-items: center; padding: 12px; }
.modal[hidden] { display: none; }
.modal-box { background: #1d1b1b; border-radius: 34px; padding: 10px; position: relative; }
.modal-box iframe { width: min(390px, 92vw); height: min(780px, 82vh); border: 0; border-radius: 26px; background: #fff; display: block; }
.modal-close { position: absolute; top: -12px; right: -12px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: var(--shadow); }
.modal-bar { display: flex; justify-content: center; gap: 8px; padding: 10px 0 2px; flex-wrap: wrap; }

/* trang quản lý thiệp */
.dash { display: grid; gap: 18px; padding: 24px 16px 60px; max-width: 980px; margin: 0 auto; }
.dash .panel { padding: 20px; }
.notice { border-left: 4px solid var(--warn); background: #fff7e6; padding: 12px 14px; border-radius: 8px; font-size: .9rem; }
.linkbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linkbox code { background: #f4efed; padding: 8px 12px; border-radius: 8px; font-size: .95rem; word-break: break-all; flex: 1; min-width: 220px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { text-align: center; padding: 14px; border-radius: 12px; background: var(--bg); }
.stat b { display: block; font-size: 1.8rem; color: var(--brand); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.guest-links { display: grid; gap: 6px; margin-top: 10px; }
.guest-links div { display: flex; gap: 8px; align-items: center; font-size: .88rem; }
.guest-links code { flex: 1; background: #f4efed; padding: 6px 10px; border-radius: 8px; word-break: break-all; }
.qr { width: 150px; height: 150px; }

/* danh sách khách mời */
.guest-tpl { margin: 14px 0 4px; font-size: .9rem; }
.guest-tpl summary { cursor: pointer; color: var(--brand); margin-bottom: 8px; }
.guest-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 10px; }
.guest-tabs { display: inline-flex; flex-wrap: wrap; background: var(--bg); border-radius: 18px; padding: 3px; }
.guest-tabs button { border: 0; background: none; font: inherit; font-size: .85rem; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.guest-tabs button.is-on { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.guest-tabs b { font-weight: 600; color: var(--brand); margin-left: 2px; }
.guest-list { display: grid; gap: 8px; }
.guest-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.guest-row.is-sent { background: #f3faf5; border-color: #cfe8d8; }
.guest-row.is-sent .guest-main b::after { content: " · đã gửi"; color: var(--ok); font-weight: 400; font-size: .8rem; }
.guest-check input { width: 18px; height: 18px; accent-color: var(--ok); }
.guest-main { display: grid; gap: 2px; min-width: 0; }
.guest-main b { font-size: .95rem; }
.guest-open { font-size: .78rem; color: var(--muted); }
.guest-open:empty { display: none; }
.guest-open.is-opened { color: var(--ok); font-weight: 600; }
.guest-open.is-opened::before { content: "👁 "; }
.guest-main code { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .guest-row { grid-template-columns: auto minmax(0, 1fr); }
  .guest-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; }
  .preview-col { display: none; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .cover-box { grid-template-columns: 90px 1fr; }
}

/* thanh trên cùng */
.topnav { display: flex; align-items: center; gap: 14px; }
.topnav-link { font-size: .9rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
@media (max-width: 480px) { .topnav { gap: 10px; } .topnav-link { font-size: .82rem; } .logo { font-size: .95rem; } }

/* đăng nhập, tài khoản, trang thông báo */
.narrow { max-width: 760px; }
.message-box, .auth-box { margin: 48px auto; padding: 28px; max-width: 440px; text-align: center; }
.auth-box { text-align: left; display: grid; gap: 12px; }
.auth-box form { display: grid; gap: 12px; }
.auth-box .msg { margin: 0; min-height: 1.2em; font-size: .88rem; }
.auth-lead { margin: 0; font-size: .88rem; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 999px; padding: 4px; }
.auth-tabs button { border: 0; background: none; font: inherit; font-weight: 600; padding: 8px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.auth-tabs button.is-on { background: var(--panel); color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.g_id_signin { display: flex; justify-content: center; }
[hidden] { display: none !important; }
.account-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.my-cards { display: grid; gap: 12px; }
.my-card { display: grid; grid-template-columns: 90px minmax(0, 1fr); overflow: hidden; }
.my-card-thumb { position: relative; min-height: 120px; }
.my-card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.my-card-body { padding: 12px 14px; display: grid; gap: 6px; }
.my-card-body .muted { font-size: .85rem; word-break: break-all; }
.badge { display: inline-block; font-size: .75rem; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); margin-right: 4px; }
.badge.ok { background: #eaf6ef; color: var(--ok); border-color: #cfe8d8; }
.badge.bad { background: #fdecea; color: var(--err); border-color: #f5c6c2; }

/* gói giá */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plan-card { padding: 18px; display: flex; flex-direction: column; gap: 6px; position: relative; box-shadow: none; }
.plan-card.is-best { border: 2px solid var(--brand); }
.plan-card h3 { margin: 0; font-size: 1.05rem; }
.plan-card ul { margin: 4px 0 10px; padding-left: 18px; font-size: .9rem; flex: 1; }
.plan-card .btn { width: 100%; }
.plan-price { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.plan-price small { font-size: .78rem; font-weight: 400; color: var(--muted); }
.plan-badge { position: absolute; top: -11px; right: 14px; background: var(--brand); color: #fff; font-size: .72rem; padding: 2px 10px; border-radius: 999px; }
.plan-state { margin: 0 0 12px; }
.plan-state.ok { color: var(--ok); } .plan-state.bad { color: var(--err); }
.plan-panel .msg { margin: 8px 0 0; font-size: .9rem; }
.pay-box { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; margin-top: 16px; padding: 16px; border: 1px dashed var(--brand); border-radius: 14px; background: #fffafa; }
.pay-box img { width: 240px; height: auto; border-radius: 10px; background: #fff; }
.pay-info dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0 0 10px; font-size: .92rem; }
.pay-info dt { color: var(--muted); }
.pay-info dd { margin: 0; word-break: break-all; }
.pay-info code { background: #f4efed; padding: 2px 8px; border-radius: 6px; font-size: 1rem; }
.pay-wait { margin: 0; font-weight: 600; color: var(--warn); }
.pay-wait.ok { color: var(--ok); }
@media (max-width: 640px) { .pay-box { grid-template-columns: 1fr; justify-items: center; } }

/* hiệu ứng thuộc gói Cao cấp trong trang tạo thiệp */
.chip.premium::after { content: "★"; color: #c9a227; font-size: .8rem; }

/* trang soạn: chữ trên thiệp */
.label-list { display: grid; gap: 8px; max-height: 460px; overflow-y: auto; padding-right: 4px; }
.label-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.label-row .field { margin: 0; }
.label-orig { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-hide { display: flex; align-items: center; gap: 5px; font-size: .85rem; padding-bottom: 9px; white-space: nowrap; cursor: pointer; }
.label-row.is-hidden .label-orig { text-decoration: line-through; }
.label-row.is-hidden input:not([type]) { opacity: .5; }
#labels-reset { margin-top: 10px; }

/* trang quản trị của chủ trang */
.dash.admin { max-width: 1180px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.admin-stats .stat { font-size: .85rem; color: var(--muted); }
.admin-stats .stat b { font-size: 1.35rem; white-space: nowrap; }
.admin-stats .stat.is-warn { background: #fff7e6; }
.admin-stats .stat.is-warn b { color: var(--warn); }
.admin-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.admin-actions select, .admin-assign input { font: inherit; font-size: .85rem; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.admin-assign { flex-wrap: nowrap; }
.admin-assign input { width: 130px; }
.admin-table td:first-child { min-width: 180px; }
.dash.admin input[type=search] { font: inherit; font-size: .9rem; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; width: 270px; max-width: 100%; }
.dash.admin > * { min-width: 0; }
.dash.admin .badge { white-space: nowrap; }
.admin-config { display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: center; margin-top: 14px; font-size: .85rem; }
