/* ===== ธีมมืด / สว่าง — ใช้ร่วมกันทุกหน้า ===== */

/* ปุ่มสลับธีม */
.theme-toggle { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.theme-toggle:hover { background: var(--chip-bg); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* บัญชีที่ล็อกอินอยู่ (มุมขวาบน) */
.account { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 6px; margin-left: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); max-width: 280px; }
.account-admin { flex: none; padding: 4px 10px; border-radius: 8px; background: #fff4d6; color: #a16207; font-size: 12.5px; font-weight: 700; }
.account-admin:hover { background: #ffe9a8; }
:root[data-theme="dark"] .account-admin { background: #3a2e10; color: #facc15; }
.account-avatar { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary); color: var(--primary-text); font-weight: 700; font-size: 14px; }
.account-email { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.account-pro { flex: none; padding: 2px 8px; border-radius: 6px; background: linear-gradient(90deg, #ff4b3e, #ff7a45); color: #fff; font-size: 11.5px; font-weight: 800; letter-spacing: .3px; }
.account-logout { flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.account-logout:hover { background: var(--chip-bg); color: var(--text); }
.account-logout svg { width: 17px; height: 17px; }
@media (max-width: 680px) {
  .account { margin-left: 0; }
  .account-email { display: none; }
}

/* รูปปกที่แอดมินอัปโหลด / ปกตัวอักษร (ตอนยังไม่มีรูป) */
.cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-text { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: linear-gradient(135deg, #1b1530, #ff5a3c); color: #fff; font-size: 24px; font-weight: 800; line-height: 1.35; }
.cover-text span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ป้ายปักหมุดบนการ์ด */
.badge.pin { right: 12px; display: inline-flex; align-items: center; gap: 5px; background: #111113; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.badge.pin svg { width: 13px; height: 13px; }
:root[data-theme="dark"] .badge.pin { background: #f4f4f5; color: #111113; }

/* ===== ปุ่มสลับมุมมอง + มุมมองแบบแถบ (หน้าคอร์ส) ===== */
.view-toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--chip-bg); margin-left: 6px; }
.view-toggle button { width: 36px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.view-toggle button:hover { color: var(--text); }
.view-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.view-toggle svg { width: 18px; height: 18px; }

.grid.list { grid-template-columns: 1fr; gap: 14px; }
.grid.list .card { flex-direction: row; border-radius: 18px; }
.grid.list .card:hover { transform: translateY(-2px); }
.grid.list .cover { flex: none; width: 260px; }
.grid.list .card-body { padding: 18px 22px; justify-content: center; min-width: 0; }
.grid.list .card-title { font-size: 17px; }
.grid.list .card-desc { margin-top: 6px; }
.grid.list .card-foot { margin-top: 0; padding-top: 14px; }
.grid.list .lock-circle { width: 44px; height: 44px; }
.grid.list .lock-circle svg { width: 22px; height: 22px; }
.grid.list .lock-text { display: none; }
.grid.list .badge { top: 8px; padding: 2px 8px; font-size: 11.5px; }
.grid.list .badge.pin { right: 8px; }
@media (max-width: 680px) {
  .grid.list { gap: 12px; }
  .grid.list .card { border-radius: 14px; }
  .grid.list .cover { width: 128px; aspect-ratio: auto; }
  .grid.list .cover > svg { position: absolute; inset: 0; }
  .grid.list .card-body { padding: 12px 14px; }
  .grid.list .card-title { font-size: 15px; line-height: 1.45; }
  .grid.list .card-desc { display: none; }
  .grid.list .card-foot { padding-top: 8px; gap: 6px; }
  .grid.list .tag { font-size: 12px; padding: 3px 8px; }
  .grid.list .tag.soft { display: none; }
  .grid.list .badge.pin { font-size: 0; gap: 0; padding: 4px; }
  .grid.list .lock-circle { width: 34px; height: 34px; }
  .grid.list .lock-circle svg { width: 17px; height: 17px; }
}

body, .header, .card, .chip, .search input, .nav a { transition: background-color .2s, color .2s, border-color .2s; }

/* ===== โทนสีธีมมืด ===== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e11;
  --surface: #18181c;
  --chip-bg: #24242a;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --border: #2e2e35;
  --primary: #f4f4f5;
  --primary-text: #111113;
  --sale-bg: #3a1618;
  --sale-text: #ff7b7f;
  --launch-bg: #3a2414;
  --launch-text: #ff9b6b;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.45);
  --shadow-hover: 0 2px 4px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.6);
}

/* ส่วนที่ใช้สีตายตัวในหน้า ต้องปรับเองในธีมมืด */
:root[data-theme="dark"] .header { background: rgba(14,14,17,.85); }
:root[data-theme="dark"] .nav a { color: #c4c4cc; }
:root[data-theme="dark"] .nav a:hover { background: #1c1c21; }
:root[data-theme="dark"] .nav a.active { color: var(--text); }
:root[data-theme="dark"] .menu-toggle,
:root[data-theme="dark"] .lang { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .search input { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .search input:focus { border-color: #4a4a52; box-shadow: 0 0 0 4px rgba(255,255,255,.06); }
:root[data-theme="dark"] .chip { color: #d4d4d8; }
:root[data-theme="dark"] .chip:hover { background: #2e2e35; }
:root[data-theme="dark"] .chip.active { color: var(--primary-text); }
:root[data-theme="dark"] .tag { color: var(--primary-text); }
:root[data-theme="dark"] .tag.soft { color: #d4d4d8; }
/* ป้าย "เฉพาะ Pro" บนการ์ด: สีส้มไล่เฉด ให้เด่นทั้งโหมดสว่างและมืด */
.tag.pro, :root[data-theme="dark"] .tag.pro { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(90deg, #ff4b3e, #ff8a3d); color: #fff; font-weight: 700; box-shadow: 0 3px 10px rgba(255, 90, 60, .35); }
.tag.pro::before { content: "★"; font-size: 12px; }
/* ป้าย "ฟรี": สีเขียว เด่นทั้งโหมดสว่างและมืด */
.tag.free, :root[data-theme="dark"] .tag.free { background: #16a34a; color: #fff; font-weight: 700; box-shadow: 0 3px 10px rgba(22, 163, 74, .3); }
:root[data-theme="dark"] .price-old { color: #71717a; }
:root[data-theme="dark"] .cover { background: var(--surface); }
:root[data-theme="dark"] .cover > svg { filter: brightness(.92); }
:root[data-theme="dark"] .content p { color: #d4d4d8; }
:root[data-theme="dark"] .prompt-box { background: #050507; border: 1px solid var(--border); }
:root[data-theme="dark"] .content .buy-note { color: #ff6b70; }
@media (max-width: 920px) {
  :root[data-theme="dark"] .nav { background: var(--bg); }
}
