/* =====================================================================
   รอบ 72: ตัวแก้ไขเว็บไซต์องค์กร (/website — WebsiteAdmin + WsPagesTab/WsPostsTab/WsMediaTab/WsInboxTab/WsSettingsTab/WsBlockForm/WsImagePick)
   prefix wsa- · สีใช้ตัวแปรของธีมหลังร้าน (รองรับโหมดมืด) · จอคอมพอดีจอ (fit) มือถือเลื่อนทั้งหน้า
   ===================================================================== */

/* ---------- หัว + แท็บ ---------- */
.wsa-head h1 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.wsa-tools .btn { display: inline-flex; align-items: center; gap: 6px; }
.wsa-st {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: var(--chip); color: var(--muted);
}
.wsa-st.is-on { background: var(--ok-soft); color: var(--ok); }
.wsa-st.is-blocked { background: var(--danger-soft); color: var(--danger); }
.wsa-tabs {
  flex: none; display: flex; gap: 4px; padding: 4px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  background: var(--chip); border-radius: 14px; align-self: flex-start;
}
.wsa-tabs::-webkit-scrollbar { display: none; }
.wsa-tabs button {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.wsa-tabs button:hover { color: var(--ink); }
.wsa-tabs button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.wsa-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink, #fff); font-size: .72rem; font-weight: 700;
}

/* ---------- เริ่มต้น ---------- */
.wsa-start { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 32px 24px; }
.wsa-start h2 { margin: 0; }
.wsa-start p { margin: 0; }
.wsa-start-ico { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 24px; background: var(--brand-soft); color: var(--brand); }
.wsa-start-list { text-align: left; margin: 6px 0 10px; padding-left: 1.2em; color: var(--ink); }
.wsa-start-list li { margin: 4px 0; }

/* ---------- แผง ---------- */
.wsa-pane { margin: 0; min-width: 0; padding: 16px; }
.wsa-wide { max-width: 1100px; }
.wsa-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin: 0 0 12px; }
.wsa-pane-head h2 { margin: 0; font-size: 1.05rem; }
.wsa-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.wsa-chip {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--chip); color: var(--muted); font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.wsa-chip-draft { background: var(--warn-soft); color: var(--warn-text, #7a5300); }
.wsa-chip-on { background: var(--ok-soft); color: var(--ok); }
.wsa-warn { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn-text, #7a5300); font-size: .88rem; }

/* ---------- หน้าเว็บ: รายการหน้า + บล็อก ---------- */
.wsa-pages { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; min-width: 0; }
@media (min-width: 1025px) { .wsa-pages { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); } }
.wsa-plist-ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.wsa-plist-ul li { display: flex; align-items: stretch; gap: 4px; border-radius: 12px; }
.wsa-plist-ul li.on { background: var(--brand-tint); box-shadow: inset 0 0 0 1.5px var(--brand); }
.wsa-pitem {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px;
  border: 0; border-radius: 12px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.wsa-pitem:hover { background: rgba(127,127,127,.08); }
.wsa-pitem strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsa-pmove { display: flex; flex-direction: column; justify-content: center; }
.wsa-pmove .icon-btn { width: 32px; height: 28px; }

.wsa-phead { align-items: flex-start; }
.wsa-phead-title { display: flex; flex-direction: column; min-width: 0; }
.wsa-phead-title h2 { overflow-wrap: anywhere; }
.wsa-phead-tools { display: flex; flex-wrap: wrap; gap: 6px; }

.wsa-blocks { display: flex; flex-direction: column; gap: 8px; }
.wsa-block {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.wsa-block.is-hidden { opacity: .62; border-style: dashed; }
.wsa-block-ico { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.wsa-block-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.wsa-block-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsa-block-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.wsa-block-tools .icon-btn { width: 34px; height: 34px; }

.wsa-add { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 14px; }
.wsa-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 8px; width: 100%; }
.wsa-type {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.wsa-type:hover { border-color: var(--brand); background: var(--brand-tint); }
.wsa-type svg { color: var(--brand); }
.wsa-type small { font-size: .78rem; line-height: 1.35; }

/* ---------- ฟอร์ม ---------- */
.wsa-form, .wsa-bform { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.wsa-bi { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 640px) { .wsa-bi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wsa-langbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; position: sticky; top: -1px; z-index: 2; padding: 4px 0; background: var(--surface); }
.wsa-lang { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--chip); }
.wsa-lang button {
  min-height: 34px; padding: 0 16px; border: 0; border-radius: 999px; background: none; color: var(--muted);
  font: inherit; font-weight: 700; cursor: pointer;
}
.wsa-lang button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.wsa-markup-help { margin: -4px 0 0; }
.wsa-items { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--chip); }
.wsa-items-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wsa-item { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.wsa-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wsa-item-no { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .8rem; }
.wsa-item-tools { display: flex; gap: 2px; }
.wsa-item-tools .icon-btn { width: 32px; height: 32px; }
.wsa-item-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 640px) { .wsa-item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.wsa-item-act { display: flex; justify-content: flex-end; }

/* ---------- เลือกรูป ---------- */
.wsa-pick { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wsa-pick-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.wsa-pick-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.wsa-pick-none { color: var(--muted); font-size: .85rem; }
.wsa-pick-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.wsa-pick-up { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.wsa-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; max-height: 260px; overflow: auto; }
.wsa-pick-item { padding: 0; border: 2px solid transparent; border-radius: 10px; background: none; cursor: pointer; overflow: hidden; }
.wsa-pick-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.wsa-pick-item.on { border-color: var(--brand); }
.wsa-upload { position: relative; overflow: hidden; display: inline-flex; align-items: center; cursor: pointer; }
.wsa-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* ---------- ข่าวสาร ---------- */
.wsa-posts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wsa-post { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.wsa-post-img { width: 64px; height: 48px; flex: none; object-fit: cover; border-radius: 8px; background: var(--chip); }
.wsa-post-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.wsa-post-main strong, .wsa-post-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- คลังรูป ---------- */
.wsa-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 150px), 1fr)); gap: 10px; }
.wsa-media-item { margin: 0; display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.wsa-media-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.wsa-media-item figcaption { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.wsa-media-act { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- ข้อความติดต่อ ---------- */
.wsa-inbox { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wsa-msg { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.wsa-msg.unread { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.wsa-msg-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.wsa-msg-text { margin: 8px 0; overflow-wrap: anywhere; }
.wsa-msg-act { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- ตั้งค่า ---------- */
.wsa-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 14px; align-items: start; }
.wsa-card { margin: 0; display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.wsa-card h2 { margin: 0; font-size: 1.05rem; }
.wsa-switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.wsa-switch input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.wsa-switch span { display: flex; flex-direction: column; }
.wsa-links p { margin: 0 0 4px; overflow-wrap: anywhere; }
.wsa-themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wsa-theme {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.wsa-theme.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.wsa-theme small { font-size: .76rem; line-height: 1.35; }
.wsa-savebar {
  position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
  margin-top: 14px; padding: 10px 0; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.wsa-savebar .alert { margin: 0; padding: 8px 12px; }

/* ตัวอย่างธีม (วาดด้วย CSS — สีหลักของร้าน) */
.wsa-thumb {
  position: relative; display: flex; flex-direction: column; width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: 10px; background: #FFFFFF; border: 1px solid var(--line);
}
.wsa-thumb .t-head { height: 14%; background: #FFFFFF; border-bottom: 1px solid #E6E8EC; flex: none; }
.wsa-thumb .t-hero {
  flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 12%;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong, var(--brand)));
}
.wsa-thumb .t-line { display: block; width: 70%; height: 7px; border-radius: 4px; background: rgba(255,255,255,.95); }
.wsa-thumb .t-line.s { width: 45%; height: 5px; opacity: .8; }
.wsa-thumb .t-btn { display: block; width: 28%; height: 9px; margin-top: 4px; border-radius: 6px; background: #FFFFFF; }
.wsa-thumb .t-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5%; height: 26%; padding: 5% 8%; flex: none; }
.wsa-thumb .t-cards span { border-radius: 4px; background: #EEF0F3; }
.wsa-thumb-classic .t-head { background: var(--brand); border: 0; }
.wsa-thumb-modern { background: #F2F4FA; }
.wsa-thumb-modern .t-head { background: transparent; border: 0; }
.wsa-thumb-modern .t-hero { margin: 0 6%; border-radius: 10px; background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--brand) 65%, #fff), var(--brand) 50%, var(--brand-strong, var(--brand))); }
.wsa-thumb-modern .t-cards span { background: #FFFFFF; box-shadow: 0 2px 6px rgba(20,30,60,.12); border-radius: 6px; }
.wsa-thumb-bold .t-head { background: #111216; border: 0; }
.wsa-thumb-bold .t-hero { background: var(--brand); }
.wsa-thumb-bold .t-line { height: 9px; width: 80%; }
.wsa-thumb-bold .t-cards { background: #111216; }
.wsa-thumb-bold .t-cards span { background: #2A2D35; }
.wsa-thumb-minimal .t-hero { background: #FFFFFF; border-bottom: 1px solid #E6E8EC; }
.wsa-thumb-minimal .t-line { background: #1F2229; }
.wsa-thumb-minimal .t-line.s { background: #9AA0AB; }
.wsa-thumb-minimal .t-btn { background: var(--brand); }
.wsa-thumb-minimal .t-cards span { background: transparent; border: 1px solid #E3E6EB; }

/* มือถือ */
@media (max-width: 760px) {
  .wsa-tools { flex-wrap: wrap; }
  .wsa-pane { padding: 12px; }
  .wsa-block-tools { margin-left: 0; width: 100%; justify-content: flex-end; }
  .wsa-themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* จอคอม: แผงหน้าเว็บเลื่อนแยกกัน */
@media screen and (min-width: 1025px) {
  .wsa-body:has(> .wsa-pages) { overflow: hidden; display: flex; }
  .wsa-body > .wsa-pages { flex: 1 1 auto; min-height: 0; align-items: stretch; }
  .wsa-pages > .wsa-pane { min-height: 0; overflow: auto; overscroll-behavior: contain; }
}
