/* ============================================================
   THAILAWBOOK — Stylesheet
   ธีมโทนน้ำเงินเข้ม/ทอง สื่อถึงความน่าเชื่อถือด้านกฎหมาย
   ============================================================ */

:root {
  --navy: #14284a;
  --navy-dark: #0d1b33;
  --navy-light: #1e3a5f;
  --gold: #c9a24b;
  --gold-light: #e0c375;
  --red: #b03a2e;
  --green: #1e8449;
  --bg: #f4f6f9;
  --white: #ffffff;
  --gray: #6b7280;
  --gray-light: #e5e7eb;
  --text: #1f2937;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(20, 40, 74, 0.08);
  --shadow-lg: 0 8px 30px rgba(20, 40, 74, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Sarabun', 'Prompt', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy-dark);
  color: #cbd5e1;
  font-size: 13px;
  padding: 6px 0;
}
.topbar .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.topbar a:hover { color: var(--gold-light); }

/* ---------- Header ---------- */
.header {
  background: var(--navy);
  color: var(--white);
  padding: 14px 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header .container { display: flex; align-items: center; gap: 24px; }
.logo { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--navy-dark); font-size: 20px;
}
.logo-text b { font-size: 20px; letter-spacing: .5px; display: block; line-height: 1.1; }
.logo-text span { font-size: 11px; color: var(--gold-light); letter-spacing: 2px; }

.search-bar { flex: 1; display: flex; max-width: 560px; }
.search-bar input {
  flex: 1; border: none; padding: 11px 16px;
  border-radius: 8px 0 0 8px; font-size: 15px; font-family: inherit;
}
.search-bar button {
  background: var(--gold); border: none; color: var(--navy-dark);
  padding: 0 20px; border-radius: 0 8px 8px 0; font-weight: 700; font-size: 15px;
}
.search-bar button:hover { background: var(--gold-light); }

.header-actions { display: flex; align-items: center; gap: 18px; }
.header-actions button {
  background: none; border: none; color: var(--white);
  font-size: 14px; display: flex; align-items: center; gap: 6px; position: relative;
}
.header-actions button:hover { color: var(--gold-light); }
.cart-count {
  position: absolute; top: -8px; right: -10px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- Nav ---------- */
.mainnav { background: var(--navy-light); }
.mainnav .container { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a {
  color: #dbe4f0; padding: 11px 16px; font-size: 14px; font-weight: 500;
  border-bottom: 3px solid transparent;
}
.mainnav a:hover, .mainnav a.active { color: var(--white); border-color: var(--gold); }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white); padding: 48px 0; position: relative; overflow: hidden;
}
.hero::after {
  content: "§"; position: absolute; right: -20px; top: -40px;
  font-size: 320px; color: rgba(201, 162, 75, 0.08); font-weight: 800;
}
.hero h1 { font-size: 34px; margin-bottom: 12px; max-width: 640px; }
.hero p { font-size: 17px; color: #cbd5e1; max-width: 560px; margin-bottom: 22px; }
.hero .btn-gold { font-size: 16px; padding: 12px 28px; }

/* ---------- Buttons ---------- */
.btn-gold {
  background: var(--gold); color: var(--navy-dark); border: none;
  padding: 10px 22px; border-radius: 8px; font-weight: 700; font-size: 15px;
}
.btn-gold:hover { background: var(--gold-light); }
.btn-outline {
  background: transparent; color: var(--navy); border: 1.5px solid var(--navy);
  padding: 9px 20px; border-radius: 8px; font-weight: 600;
}
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-full { width: 100%; text-align: center; }

/* ---------- Section ---------- */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.section-head h2 { font-size: 24px; color: var(--navy); position: relative; padding-left: 14px; }
.section-head h2::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 5px; background: var(--gold); border-radius: 3px;
}
.section-head a { color: var(--gold); font-weight: 600; font-size: 14px; }

/* ---------- Category chips ---------- */
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.chip {
  background: var(--white); border: 1.5px solid var(--gray-light);
  padding: 8px 16px; border-radius: 20px; font-size: 14px; color: var(--text);
}
.chip:hover { border-color: var(--gold); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Book grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px; }
.book-card {
  background: var(--white); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s;
  display: flex; flex-direction: column; cursor: pointer;
}
.book-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.book-cover {
  aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center;
  padding: 18px; text-align: center; position: relative;
}
.book-cover .cover-title { color: #fff; font-weight: 700; font-size: 15px; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.book-cover .cover-sub { color: rgba(255,255,255,.75); font-size: 11px; margin-top: 8px; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 5px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 5px; color: #fff; }
.badge-new { background: var(--green); }
.badge-best { background: var(--red); }
.badge-set { background: var(--gold); color: var(--navy-dark); }
.book-body { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.book-title { font-size: 15px; font-weight: 600; color: var(--navy); margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 44px; }
.book-author { font-size: 12px; color: var(--gray); margin-bottom: 8px; }
.book-meta { font-size: 12px; color: var(--gray); margin-bottom: 8px; display: flex; gap: 10px; }
.book-price { margin-top: auto; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price-now { font-size: 19px; font-weight: 800; color: var(--red); }
.price-old { font-size: 13px; color: var(--gray); text-decoration: line-through; }
.price-off { font-size: 11px; background: #fde8e6; color: var(--red); padding: 2px 6px; border-radius: 4px; font-weight: 700; }
.format-tags { display: flex; gap: 5px; margin-top: 8px; }
.format-tag { font-size: 11px; border: 1px solid var(--gray-light); border-radius: 4px; padding: 2px 7px; color: var(--gray); }

/* ---------- Filter layout ---------- */
.catalog-layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.filter-box { background: var(--white); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); align-self: start; position: sticky; top: 90px; }
.filter-box h3 { font-size: 15px; color: var(--navy); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--gray-light); }
.filter-group { margin-bottom: 20px; }
.filter-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14px; cursor: pointer; }
.filter-item input { accent-color: var(--navy); width: 16px; height: 16px; }
.result-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.result-info select { padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--gray-light); font-family: inherit; font-size: 14px; }

/* ---------- Book detail ---------- */
.detail { display: grid; grid-template-columns: 340px 1fr; gap: 40px; background: var(--white); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.detail-cover { aspect-ratio: 3/4; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; box-shadow: var(--shadow-lg); }
.detail-info h1 { font-size: 26px; color: var(--navy); margin-bottom: 8px; }
.detail-author { color: var(--gray); margin-bottom: 14px; }
.detail-price { font-size: 32px; font-weight: 800; color: var(--red); margin: 16px 0; }
.detail-price small { font-size: 16px; color: var(--gray); text-decoration: line-through; font-weight: 400; margin-left: 10px; }
.option-block { margin: 18px 0; }
.option-block label.head { font-weight: 700; color: var(--navy); display: block; margin-bottom: 8px; }
.format-choice { display: flex; gap: 12px; }
.format-choice .opt {
  flex: 1; border: 2px solid var(--gray-light); border-radius: 8px; padding: 12px;
  cursor: pointer; text-align: center; transition: .15s;
}
.format-choice .opt.selected { border-color: var(--gold); background: #fdf6e7; }
.format-choice .opt b { display: block; color: var(--navy); }
.format-choice .opt span { font-size: 13px; color: var(--red); font-weight: 700; }
.shelf-list { border: 1.5px solid var(--gray-light); border-radius: 8px; overflow: hidden; }
.shelf-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--gray-light); font-size: 14px; }
.shelf-item:last-child { border-bottom: none; }
.shelf-item input { accent-color: var(--gold); width: 18px; height: 18px; }
.shelf-item .sp { margin-left: auto; color: var(--red); font-weight: 700; font-size: 13px; }
.qty { display: flex; align-items: center; gap: 0; width: fit-content; border: 1.5px solid var(--gray-light); border-radius: 8px; overflow: hidden; }
.qty button { width: 38px; height: 38px; background: var(--bg); border: none; font-size: 18px; color: var(--navy); }
.qty input { width: 50px; text-align: center; border: none; font-size: 15px; }
.detail-actions { display: flex; gap: 12px; margin-top: 22px; }
.detail-tabs { margin-top: 30px; }
.detail-tabs .tab-head { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-light); }
.detail-tabs .tab-head button { background: none; border: none; padding: 10px 18px; font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--gray); }
.detail-tabs .tab-head button.active { color: var(--navy); border-color: var(--gold); font-weight: 600; }
.detail-tabs .tab-body { padding: 18px 4px; }
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table td { padding: 8px 12px; border-bottom: 1px solid var(--gray-light); font-size: 14px; }
.spec-table td:first-child { color: var(--gray); width: 160px; }

/* ---------- Cart / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: none; }
.overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: -440px; width: 420px; max-width: 92vw; height: 100%;
  background: var(--white); z-index: 201; box-shadow: -4px 0 30px rgba(0,0,0,.2);
  transition: right .25s; display: flex; flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-head { padding: 18px 20px; background: var(--navy); color: #fff; display: flex; justify-content: space-between; align-items: center; }
.drawer-head h3 { font-size: 18px; }
.drawer-head button { background: none; border: none; color: #fff; font-size: 24px; line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.cart-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--gray-light); }
.cart-item .ci-cover { width: 56px; height: 74px; border-radius: 6px; flex-shrink: 0; }
.cart-item .ci-info { flex: 1; }
.cart-item .ci-title { font-size: 14px; font-weight: 600; color: var(--navy); }
.cart-item .ci-fmt { font-size: 12px; color: var(--gray); }
.cart-item .ci-price { color: var(--red); font-weight: 700; }
.cart-item .ci-remove { background: none; border: none; color: var(--gray); font-size: 13px; }
.cart-item .ci-remove:hover { color: var(--red); }
.drawer-foot { padding: 18px 20px; border-top: 2px solid var(--gray-light); }
.drawer-foot .total-row { display: flex; justify-content: space-between; font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 14px; }
.empty { text-align: center; color: var(--gray); padding: 50px 20px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--gray-light); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { color: var(--navy); font-size: 20px; }
.modal-head button { background: none; border: none; font-size: 24px; color: var(--gray); }
.modal-body { padding: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--gray-light);
  border-radius: 8px; font-family: inherit; font-size: 15px;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.tab-switch { display: flex; margin-bottom: 20px; border: 1.5px solid var(--gray-light); border-radius: 8px; overflow: hidden; }
.tab-switch button { flex: 1; padding: 10px; background: var(--bg); border: none; font-size: 15px; }
.tab-switch button.active { background: var(--navy); color: #fff; }

/* ---------- Checkout ---------- */
.checkout { display: grid; grid-template-columns: 1fr 380px; gap: 30px; }
.checkout-card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.checkout-card h3 { color: var(--navy); margin-bottom: 16px; font-size: 18px; }
.summary-line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; }
.summary-line.total { border-top: 2px solid var(--gray-light); margin-top: 10px; padding-top: 12px; font-size: 20px; font-weight: 800; color: var(--navy); }
.pay-methods { display: flex; flex-direction: column; gap: 10px; }
.pay-opt { border: 2px solid var(--gray-light); border-radius: 8px; padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.pay-opt.selected { border-color: var(--gold); background: #fdf6e7; }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th { background: var(--navy); color: #fff; padding: 12px; text-align: left; font-size: 14px; }
.admin-table td { padding: 12px; border-bottom: 1px solid var(--gray-light); font-size: 14px; }
.admin-table tr:hover td { background: #f9fafb; }
.admin-table input.disc { width: 70px; padding: 6px 8px; border: 1.5px solid var(--gray-light); border-radius: 6px; text-align: center; }
.admin-note { background: #fdf6e7; border-left: 4px solid var(--gold); padding: 14px 18px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast { background: var(--navy); color: #fff; padding: 13px 22px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; animation: slideup .3s; max-width: 90vw; }
.toast.success { background: var(--green); }
.toast.gold { background: var(--gold); color: var(--navy-dark); font-weight: 600; }
@keyframes slideup { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Email preview ---------- */
.email-preview { border: 1.5px solid var(--gray-light); border-radius: 10px; overflow: hidden; margin-top: 14px; }
.email-preview .eh { background: #f3f4f6; padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--gray-light); }
.email-preview .eb { padding: 18px; font-size: 14px; }

/* ---------- Footer ---------- */
.footer { background: var(--navy-dark); color: #9fb0c8; padding: 40px 0 20px; margin-top: 50px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.5fr; gap: 30px; margin-bottom: 30px; }
.footer h4 { color: #fff; font-size: 15px; margin-bottom: 14px; }
.footer ul { list-style: none; }
.footer li { padding: 4px 0; font-size: 14px; }
.footer a:hover { color: var(--gold-light); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding-top: 18px; text-align: center; font-size: 13px; }

/* ---------- ปุ่มติดต่อลอย LINE / Messenger ---------- */
.float-contact {
  position: fixed; right: 20px; bottom: 22px; z-index: 150;
  display: flex; flex-direction: column; gap: 12px;
}
.fc-btn {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.28);
  transition: transform .15s, box-shadow .15s; position: relative;
}
.fc-btn:hover { transform: scale(1.09); box-shadow: 0 6px 22px rgba(0,0,0,.35); }
.fc-line { background: #06c755; }
.fc-mess { background: #0084ff; }
.fc-btn::after {
  content: attr(title); position: absolute; right: 66px; top: 50%; transform: translateY(-50%);
  background: rgba(20,40,74,.92); color: #fff; font-size: 13px; white-space: nowrap;
  padding: 6px 12px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.fc-btn:hover::after { opacity: 1; }
@media (max-width: 560px) {
  .float-contact { right: 14px; bottom: 16px; }
  .fc-btn { width: 50px; height: 50px; }
  .fc-btn::after { display: none; }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.stars { color: var(--gold); font-size: 13px; }
.breadcrumb { font-size: 13px; color: var(--gray); margin-bottom: 18px; }
.breadcrumb a:hover { color: var(--navy); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .catalog-layout { grid-template-columns: 1fr; }
  .filter-box { position: static; }
  .detail { grid-template-columns: 1fr; }
  .checkout { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .search-bar { order: 3; max-width: 100%; flex-basis: 100%; }
  .header .container { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 26px; }
  .footer-grid { grid-template-columns: 1fr; }
  .detail-actions { flex-direction: column; }
}
