/* ==========================================================================
   NP E-Book — Authentic AnyFlip Style Bookshelf & 3D Book Mockup
   โรงเรียนหนองไผ่ (nongphai.ac.th)
   ดีไซน์ตู้ไม้เสมือนจริง สันหนังสือ 3D ขอบซ้ายไม่ทับหน้าปก ช่องค้นหา & แชร์
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. The Main Bookcase Wooden Cabinet (โครงสร้างตู้หนังสือ)
   -------------------------------------------------------------------------- */
.library-bookcase {
  margin-bottom: 3rem;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 
    0 12px 35px rgba(15, 23, 42, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.08);
  border: 4px solid #8d531b;
  transition: all 0.3s ease;
}

/* --------------------------------------------------------------------------
   2. Top Wooden Frame (ขอบตู้ด้านบน — Search, Title, Sort, Share)
   -------------------------------------------------------------------------- */
.shelf-top-frame {
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Left: Quick Search within Shelf */
.shelf-search-wrap {
  position: relative;
  width: 200px;
  max-width: 25vw;
}

.shelf-search-input {
  width: 100%;
  padding: 0.38rem 0.8rem 0.38rem 2.1rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  transition: all 0.2s ease;
}

.shelf-search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.shelf-search-input:focus {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.shelf-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

/* Center: Shelf Title & Optional Category Dropdown */
.shelf-center-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  justify-content: center;
  text-align: center;
}

.shelf-main-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 1px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shelf-category-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}

.shelf-category-select option {
  background: #1e293b;
  color: #fff;
}

/* Right: Actions (Sort Name, Sort Date, Share) */
.shelf-actions-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.shelf-action-btn {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.shelf-action-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.shelf-action-btn.active {
  background: rgba(255, 255, 255, 0.35);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

/* --------------------------------------------------------------------------
   3. Shelf Chamber & Wooden Tiers (ห้องชั้นวางและคานไม้รองรับหนังสืออัจฉริยะ)
   -------------------------------------------------------------------------- */
.library-chamber {
  padding: 2.2rem 2rem 1.8rem;
  position: relative;
  perspective: 1200px;
  min-height: 250px;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 3.2rem;
  transition: all 0.3s ease;
  /* Top ceiling overhang depth & bottom chamber base shadow */
  box-shadow: 
    inset 0 18px 24px -6px rgba(0, 0, 0, 0.75), 
    inset 0 -10px 18px -4px rgba(0, 0, 0, 0.5);
}

/* 3D Bookcase Authentic Inner Side Walls (เสาข้างตู้ไม้ 3D มีมิติความลึก ตามแบบ AnyFlip) */
.library-chamber::before,
.library-chamber::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(16px, 2.5vw, 24px);
  z-index: 4;
  pointer-events: none;
  box-sizing: border-box;
}

/* ผนังข้างซ้าย (Left 3D Wall Perspective) */
.library-chamber::before {
  left: 0;
  background: 
    repeating-linear-gradient(180deg,
      transparent 0px,
      transparent 24px,
      rgba(0, 0, 0, 0.05) 25px,
      transparent 26px
    ),
    linear-gradient(90deg, 
      rgba(255, 255, 255, 0.48) 0px,
      rgba(255, 255, 255, 0.18) 2px,
      rgba(215, 148, 52, 0.96) 3px,
      rgba(165, 102, 22, 0.96) 38%,
      rgba(105, 58, 10, 0.98) 78%,
      rgba(36, 18, 5, 1) 100%
    );
  border-right: 1.5px solid rgba(0, 0, 0, 0.65);
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 
    7px 0 16px -2px rgba(0, 0, 0, 0.7),
    inset 1px 0 0 rgba(255, 255, 255, 0.3);
}

/* ผนังข้างขวา (Right 3D Wall Perspective) */
.library-chamber::after {
  right: 0;
  background: 
    repeating-linear-gradient(180deg,
      transparent 0px,
      transparent 24px,
      rgba(0, 0, 0, 0.05) 25px,
      transparent 26px
    ),
    linear-gradient(270deg, 
      rgba(255, 255, 255, 0.48) 0px,
      rgba(255, 255, 255, 0.18) 2px,
      rgba(215, 148, 52, 0.96) 3px,
      rgba(165, 102, 22, 0.96) 38%,
      rgba(105, 58, 10, 0.98) 78%,
      rgba(36, 18, 5, 1) 100%
    );
  border-left: 1.5px solid rgba(0, 0, 0, 0.65);
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 
    -7px 0 16px -2px rgba(0, 0, 0, 0.7),
    inset -1px 0 0 rgba(255, 255, 255, 0.3);
}

.bookshelf-tier {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(0.8rem, 2vw, 2.2rem);
  padding: 0 clamp(1.8rem, 3.8vw, 3.2rem) 22px; /* Sits naturally inside 3D side walls */
  margin-bottom: 0;
  overflow: visible;
  width: 100%;
  box-sizing: border-box;
}

.bookshelf-tier.tier-full {
  justify-content: space-between;
}

.bookshelf-tier.tier-balanced {
  justify-content: space-evenly;
}

/* คานไม้รองรับหนังสือเสมือนจริง (Realistic 3D Shelf Plank) */
.shelf-plank {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22px;
  z-index: 2;
  pointer-events: none;
}

/* หน้าผิวด้านบนของแผ่นไม้ (Top bevel with reflection & depth) */
.shelf-plank::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 10px;
  background: linear-gradient(180deg, 
    rgba(0, 0, 0, 0.3) 0%, 
    rgba(255, 255, 255, 0.18) 20%, 
    rgba(255, 255, 255, 0.5) 80%, 
    rgba(255, 255, 255, 0.7) 100%
  );
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.75);
  border-top: 1px solid rgba(0, 0, 0, 0.35);
}

/* สันขอบหน้าของแผ่นไม้ พร้อมเงาทอดลงด้านล่าง */
.shelf-plank::after {
  content: '';
  position: absolute;
  top: 10px; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, 
    rgba(0, 0, 0, 0.06) 0%, 
    rgba(0, 0, 0, 0.35) 60%, 
    rgba(0, 0, 0, 0.6) 100%
  );
  border-top: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7), 0 2px 5px rgba(0, 0, 0, 0.45);
}

/* --------------------------------------------------------------------------
   4. NEW 3D BOOK MOCKUP (โมเดลหนังสือ 3D สมจริง สันซ้ายไม่ทับหน้าปก)
   -------------------------------------------------------------------------- */
.library-book-item {
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  perspective: 900px;
}

/* โครงสร้างตัวเล่ม 3D */
.book-3d-wrapper {
  position: relative;
  /* ปรับขนาดตามความสูงชั้นอย่างยืดหยุ่น (Responsive Height) */
  height: clamp(180px, 22vw, 225px);
  aspect-ratio: 1 / 1.414;
  display: flex;
  align-items: stretch;
  transform-style: preserve-3d;
  transform: rotateY(-6deg) rotateX(1deg);
  transition: all 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* สันหนังสือ 3D ฝั่งซ้าย (แยกออกจากหน้าปก 100% ไม่ทับเนื้อหาปก!) */
.book-3d-spine {
  position: absolute;
  left: -10px;
  top: 0;
  bottom: 0;
  width: 11px;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(90deg, 
    rgba(25, 25, 25, 0.75) 0%, 
    rgba(255, 255, 255, 0.3) 45%, 
    rgba(30, 30, 30, 0.5) 100%
  ), #2d3748;
  box-shadow: 
    inset -1px 0 2px rgba(0, 0, 0, 0.45),
    -3px 4px 10px rgba(0, 0, 0, 0.4);
  transform-origin: right center;
  transform: rotateY(-65deg);
  z-index: 1;
}

/* หน้าปกหนังสือ (The Front Cover Face) — แสดงภาพปกเต็ม 100% คมชัด สไตล์หนังสือ 3D สมจริงตาม Image 4 */
.book-3d-cover {
  width: 100%;
  height: 100%;
  border-radius: 0 8px 8px 0; /* มุมซ้ายฉากสันปก มุมขวามน */
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  box-shadow: 
    1.5px 0 0 #f8fafc,
    3px 0 0 #e2e8f0,
    4.5px 0 0 #cbd5e1,
    8px 12px 24px rgba(0, 0, 0, 0.6),
    -3px 4px 10px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem 0.85rem;
  z-index: 2;
  transition: all 0.28s ease;
}

/* แสงสันปก 3D (Cylinder Spine Lighting) โค้งนูนและเงาร่องพับแบบสมจริง ปราศจากเส้นดำ */
.book-3d-cover::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 24px;
  background: linear-gradient(90deg, 
    rgba(0, 0, 0, 0.38) 0%, 
    rgba(0, 0, 0, 0.14) 14%, 
    rgba(255, 255, 255, 0.28) 28%, 
    rgba(0, 0, 0, 0.12) 48%, 
    rgba(0, 0, 0, 0.02) 76%, 
    transparent 100%
  );
  pointer-events: none;
  z-index: 4;
}

/* Corner Curl เล็กๆ ที่มุมล่างขวา เหมือนหนังสือจริงใน Image 4 */
.book-3d-cover-curl {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.12) 50%, #e2e8f0 60%, #ffffff 100%);
  box-shadow: -1.5px -1.5px 4px rgba(0, 0, 0, 0.22);
  border-bottom-right-radius: 8px;
  pointer-events: none;
  z-index: 6;
  transition: width 0.2s ease, height 0.2s ease;
}

.library-book-item:hover .book-3d-cover-curl {
  width: 28px;
  height: 28px;
}

/* แสงสะท้อนบางเบาบนปกจำลองเคลือบมัน (Gloss Highlight) ไม่บดบังข้อความ */
.book-3d-cover::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(115deg, 
    rgba(255, 255, 255, 0.18) 0%, 
    rgba(255, 255, 255, 0.05) 30%, 
    transparent 60%
  );
  pointer-events: none;
  z-index: 3;
}

/* ขอบกระดาษเรียงซ้อนด้านขวาของเล่ม (Stacked Page Edges) */
.book-3d-pages {
  position: absolute;
  right: -5px;
  top: 3px;
  bottom: 3px;
  width: 6px;
  background: repeating-linear-gradient(180deg, #fbfaf5 0px, #dfdbce 1px, #fbfaf5 2px);
  border-radius: 0 2px 2px 0;
  box-shadow: inset 1px 0 2px rgba(0, 0, 0, 0.25);
  transform-origin: left center;
  transform: rotateY(55deg);
  z-index: 1;
}

/* เงาตกกระทบใต้เล่มหนังสือลงบนแผ่นไม้ (Contact Shadow) */
.book-3d-shadow {
  position: absolute;
  bottom: -8px;
  left: 2%;
  right: 2%;
  height: 12px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.65) 0%, transparent 75%);
  filter: blur(3px);
  z-index: 0;
  transition: all 0.28s ease;
}

/* Hover Effect: หนังสือยกตัวขึ้นนูนเด่นและขยับเงานุ่ม */
.library-book-item:hover {
  transform: translateY(-12px);
}

.library-book-item:hover .book-3d-wrapper {
  transform: rotateY(-2deg) rotateX(0deg) scale(1.04);
}

.library-book-item:hover .book-3d-cover {
  box-shadow: 
    -6px 16px 30px rgba(0, 0, 0, 0.6),
    0 0 16px rgba(255, 255, 255, 0.2);
}

.library-book-item:hover .book-3d-shadow {
  transform: scale(1.15) translateY(4px);
  opacity: 0.5;
  filter: blur(5px);
}

/* Fallback Typography หากหนังสือเล่มใดไม่มีภาพปก */
.book-fallback-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.book-fallback-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 0.4rem;
}

.book-fallback-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.35;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-fallback-author {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  padding-top: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ป้ายมุมเล่ม (Hot / New) */
.book-corner-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--np-gold);
  color: #000;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 4;
}

/* Glassmorphic View Count Chip on Book (ยอดวิวบนเล่ม สวยงาม คมชัด ไม่รก) */
.book-view-chip {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.48rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.library-book-item:hover .book-view-chip {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

/* --------------------------------------------------------------------------
   5. Bottom Wooden Frame (ขอบล่างตู้ — Book Count & Theme Switcher)
   -------------------------------------------------------------------------- */
.shelf-bottom-frame {
  padding: 0.55rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Oval Book Count Badge */
.shelf-count-badge {
  background: rgba(0, 0, 0, 0.45);
  color: #fef08a;
  border: 1px solid rgba(254, 240, 138, 0.35);
  padding: 0.18rem 1.1rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Theme Switcher Button */
.shelf-theme-wrap {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
}

.shelf-theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shelf-theme-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

/* Theme Swatch Popover (แถบเลือกธีมแบบในรูปที่ 4) */
.shelf-theme-popover {
  position: absolute;
  bottom: 42px;
  right: 0;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 50;
}

.shelf-theme-popover.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.theme-swatch-item {
  width: 38px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.theme-swatch-item:hover {
  transform: scale(1.15);
  border-color: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* --------------------------------------------------------------------------
   6. THEMES (ลายตู้หนังสือ: ลายไม้ไผ่สีทอง, ไม้สัก, ไม้เข้ม, ไม้สว่าง, โมเดิร์น)
   -------------------------------------------------------------------------- */

/* 🎋 ธีมที่ 1: ลายไม้ไผ่สีทอง (Golden Bamboo Heritage) */
.theme-bamboo,
.theme-gold-bamboo {
  border-color: #b8860b !important;
  background: #2a1b0a !important;
}

.theme-bamboo .shelf-top-frame,
.theme-gold-bamboo .shelf-top-frame,
.theme-bamboo .shelf-bottom-frame,
.theme-gold-bamboo .shelf-bottom-frame {
  background: linear-gradient(180deg, #e5b358 0%, #ca9029 45%, #9b6c16 100%) !important;
  border-bottom: 2px solid #85590c !important;
}

.theme-bamboo .shelf-bottom-frame,
.theme-gold-bamboo .shelf-bottom-frame {
  border-bottom: none !important;
  border-top: 2px solid #fed7aa !important;
}

.theme-bamboo .library-chamber,
.theme-gold-bamboo .library-chamber {
  background: 
    repeating-linear-gradient(90deg, 
      #805615 0px, 
      #9b6b1d 22px, 
      #b37e25 45px, 
      #d49b38 65px, 
      #805615 85px
    ) !important;
  box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.6) !important;
}

.theme-bamboo .shelf-plank,
.theme-gold-bamboo .shelf-plank {
  background: linear-gradient(180deg, #dfb76c 0%, #c49a45 35%, #8c651e 100%) !important;
  border-top: 1px solid #ffe082 !important;
}

.theme-bamboo .library-chamber::before,
.theme-gold-bamboo .library-chamber::before {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.05) 25px, transparent 26px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0px, rgba(255, 255, 255, 0.2) 2px, #e5b358 3px, #b37e25 40%, #734808 80%, #2b1802 100%) !important;
  border-right-color: rgba(43, 24, 2, 0.75) !important;
}
.theme-bamboo .library-chamber::after,
.theme-gold-bamboo .library-chamber::after {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.05) 25px, transparent 26px),
    linear-gradient(270deg, rgba(255, 255, 255, 0.5) 0px, rgba(255, 255, 255, 0.2) 2px, #e5b358 3px, #b37e25 40%, #734808 80%, #2b1802 100%) !important;
  border-left-color: rgba(43, 24, 2, 0.75) !important;
}

/* 🪵 ธีมที่ 2: ไม้สักทองไทยร่วมสมัย (Warm Golden Thai Teak Wood — AnyFlip Authentic Look) */
.theme-thai,
.theme-classic-wood {
  border-color: #925319 !important;
  background: #2b1708 !important;
}

.theme-thai .shelf-top-frame,
.theme-classic-wood .shelf-top-frame,
.theme-thai .shelf-bottom-frame,
.theme-classic-wood .shelf-bottom-frame {
  background: linear-gradient(180deg, #dfa547 0%, #c18128 48%, #9b5f14 100%) !important;
  border-bottom: 2px solid #633608 !important;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35) !important;
}

.theme-thai .shelf-bottom-frame,
.theme-classic-wood .shelf-bottom-frame {
  border-bottom: none !important;
  border-top: 2px solid #fed7aa !important;
}

.theme-thai .library-chamber,
.theme-classic-wood .library-chamber {
  background: 
    radial-gradient(ellipse at 50% 50%, rgba(254, 215, 126, 0.18) 0%, rgba(35, 18, 5, 0.45) 100%),
    repeating-linear-gradient(90deg, 
      #945d19 0px, 
      #ae7425 24px, 
      #c48b35 50px, 
      #8e5614 76px, 
      #945d19 100px
    ) !important;
  box-shadow: inset 0 8px 24px rgba(0, 0, 0, 0.55), inset 0 -8px 20px rgba(0, 0, 0, 0.4) !important;
}

.theme-thai .shelf-plank,
.theme-classic-wood .shelf-plank {
  background: linear-gradient(180deg, #e4ad52 0%, #bd7c24 38%, #784409 100%) !important;
  border-top: 1.5px solid #ffedd5 !important;
}

.theme-thai .library-chamber::before,
.theme-classic-wood .library-chamber::before {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.05) 25px, transparent 26px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0px, rgba(255, 255, 255, 0.2) 2px, #dfa547 3px, #b8771f 40%, #683908 80%, #291504 100%) !important;
  border-right-color: rgba(41, 21, 4, 0.8) !important;
}
.theme-thai .library-chamber::after,
.theme-classic-wood .library-chamber::after {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.05) 25px, transparent 26px),
    linear-gradient(270deg, rgba(255, 255, 255, 0.5) 0px, rgba(255, 255, 255, 0.2) 2px, #dfa547 3px, #b8771f 40%, #683908 80%, #291504 100%) !important;
  border-left-color: rgba(41, 21, 4, 0.8) !important;
}

/* 🌲 ธีมที่ 3: ไม้มะฮอกกานีเข้ม (Dark Mahogany) */
.theme-wood-dark {
  border-color: #3b1d11 !important;
  background: #0d0604 !important;
}

.theme-wood-dark .shelf-top-frame,
.theme-wood-dark .shelf-bottom-frame {
  background: linear-gradient(180deg, #451a03 0%, #290f03 50%, #170701 100%) !important;
  border-bottom: 2px solid #000 !important;
}

.theme-wood-dark .shelf-bottom-frame {
  border-bottom: none !important;
  border-top: 2px solid #78350f !important;
}

.theme-wood-dark .library-chamber {
  background: 
    repeating-linear-gradient(90deg, 
      #1f0a02 0px, 
      #290f03 24px, 
      #331405 50px, 
      #1f0a02 75px
    ) !important;
  box-shadow: inset 0 8px 20px rgba(0, 0, 0, 0.8) !important;
}

.theme-wood-dark .shelf-plank {
  background: linear-gradient(180deg, #3d1704 0%, #240c02 40%, #0a0300 100%) !important;
  border-top: 1px solid #78350f !important;
}

.theme-wood-dark .library-chamber::before {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.08) 25px, transparent 26px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0px, rgba(255, 255, 255, 0.08) 2px, #451a03 3px, #290f03 40%, #150601 80%, #050201 100%) !important;
  border-right-color: #000000 !important;
}
.theme-wood-dark .library-chamber::after {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.08) 25px, transparent 26px),
    linear-gradient(270deg, rgba(255, 255, 255, 0.25) 0px, rgba(255, 255, 255, 0.08) 2px, #451a03 3px, #290f03 40%, #150601 80%, #050201 100%) !important;
  border-left-color: #000000 !important;
}

/* 🌾 ธีมที่ 4: ไม้เมเปิ้ลสว่าง (Light Maple Wood) */
.theme-wood-light {
  border-color: #d97706 !important;
  background: #fef3c7 !important;
}

.theme-wood-light .shelf-top-frame,
.theme-wood-light .shelf-bottom-frame {
  background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 50%, #d97706 100%) !important;
  border-bottom: 2px solid #b45309 !important;
}

.theme-wood-light .shelf-bottom-frame {
  border-bottom: none !important;
  border-top: 2px solid #ffffff !important;
}

.theme-wood-light .shelf-main-title {
  color: #451a03 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6) !important;
}

.theme-wood-light .library-chamber {
  background: 
    repeating-linear-gradient(90deg, 
      #fef3c7 0px, 
      #fde68a 25px, 
      #fef3c7 50px
    ) !important;
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.2) !important;
}

.theme-wood-light .shelf-plank {
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 40%, #b45309 100%) !important;
  border-top: 1px solid #ffffff !important;
}

.theme-wood-light .library-chamber::before {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.04) 25px, transparent 26px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.8) 0px, rgba(255, 255, 255, 0.4) 2px, #fde68a 3px, #f59e0b 40%, #d97706 75%, #78350f 100%) !important;
  border-right-color: rgba(120, 53, 15, 0.65) !important;
}
.theme-wood-light .library-chamber::after {
  background: 
    repeating-linear-gradient(180deg, transparent 0px, transparent 24px, rgba(0, 0, 0, 0.04) 25px, transparent 26px),
    linear-gradient(270deg, rgba(255, 255, 255, 0.8) 0px, rgba(255, 255, 255, 0.4) 2px, #fde68a 3px, #f59e0b 40%, #d97706 75%, #78350f 100%) !important;
  border-left-color: rgba(120, 53, 15, 0.65) !important;
}

/* 💎 ธีมที่ 5: โมเดิร์นไซเบอร์ (Cyber Slate & Glass) */
.theme-cyber {
  border-color: #0284c7 !important;
  background: #030712 !important;
}

.theme-cyber .shelf-top-frame,
.theme-cyber .shelf-bottom-frame {
  background: linear-gradient(180deg, #0369a1 0%, #0f172a 60%, #020617 100%) !important;
  border-bottom: 2px solid #0284c7 !important;
}

.theme-cyber .shelf-bottom-frame {
  border-bottom: none !important;
  border-top: 2px solid #38bdf8 !important;
}

.theme-cyber .library-chamber {
  background: radial-gradient(circle at 50% 30%, #082f49 0%, #020617 80%) !important;
  box-shadow: inset 0 8px 24px rgba(0, 0, 0, 0.85) !important;
}

.theme-cyber .shelf-plank {
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 50%, #0284c7 100%) !important;
  box-shadow: 0 0 16px rgba(2, 132, 199, 0.5) !important;
  border-top: 1px solid #e0f2fe !important;
}

.theme-cyber .library-chamber::before {
  background: 
    linear-gradient(90deg, #38bdf8 0px, rgba(56, 189, 248, 0.4) 2px, #0284c7 3px, #0f172a 50%, #020617 100%) !important;
  border-right-color: #0284c7 !important;
  box-shadow: 4px 0 14px rgba(2, 132, 199, 0.4) !important;
}
.theme-cyber .library-chamber::after {
  background: 
    linear-gradient(270deg, #38bdf8 0px, rgba(56, 189, 248, 0.4) 2px, #0284c7 3px, #0f172a 50%, #020617 100%) !important;
  border-left-color: #0284c7 !important;
  box-shadow: -4px 0 14px rgba(2, 132, 199, 0.4) !important;
}

/* --------------------------------------------------------------------------
   7. Share Modal Dialog Styling (AnyFlip QR Code & Open New Window)
   -------------------------------------------------------------------------- */
.shelf-share-dialog {
  max-width: 580px;
}

.share-modal-body {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.5rem;
  align-items: center;
  padding: 1.5rem;
}

.share-qr-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.share-qr-code {
  width: 140px;
  height: 140px;
  display: block;
  object-fit: contain;
}

.share-qr-caption {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 0.5rem;
  text-align: center;
}

.share-info-area {
  display: flex;
  flex-direction: column;
}

.share-field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.share-link-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
}

.share-link-input-group input {
  width: 100%;
  box-sizing: border-box;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 0.65rem 0.8rem;
  border-radius: 6px;
  font-size: 0.84rem;
  color: #1e293b;
  outline: none;
  font-family: monospace;
}

.btn-copy-share {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: #ffffff;
  padding: 0.65rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 12px rgba(219, 39, 119, 0.25);
  transition: all 0.2s ease;
}

.btn-copy-share:hover {
  background: linear-gradient(135deg, #f472b6 0%, #be185d 100%);
  transform: translateY(-1px);
}

.share-social-btns {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.btn-social-share {
  flex: 1;
  padding: 0.45rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  transition: transform 0.15s ease;
}

.btn-social-share:hover {
  transform: translateY(-2px);
}

.btn-social-fb { background: #1877f2; }
.btn-social-x { background: #000000; }
.btn-social-line { background: #06c755; }

/* ปุ่มเปิดชั้นวางในหน้าต่างใหม่ (เต็มจอ) */
.share-open-window-box {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.15);
}

.btn-open-shelf-window {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.7rem 1rem;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff !important;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-open-shelf-window:hover {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

/* Responsive Styles */
@media (max-width: 768px) {
  .shelf-top-frame {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .shelf-search-wrap {
    width: 100%;
    max-width: 100%;
  }
  .shelf-center-area {
    justify-content: flex-start;
  }
  .shelf-actions-wrap {
    justify-content: flex-end;
  }
  .share-modal-body {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .share-qr-area {
    margin: 0 auto;
  }
}

/* --------------------------------------------------------------------------
   AnyFlip Bookcase Temporary Embed (4 Tiers Display)
   -------------------------------------------------------------------------- */
.library-bookcase-anyflip {
  margin-bottom: 3rem;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 
    0 12px 35px rgba(15, 23, 42, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.08);
  background: transparent;
  position: relative;
  transition: all 0.3s ease;
}

.anyflip-shelf-iframe {
  width: 100%;
  height: 640px;
  border: none;
  border-radius: 14px;
  display: block;
}

@media (max-width: 1200px) {
  .anyflip-shelf-iframe {
    height: 635px;
  }
}

@media (max-width: 768px) {
  .anyflip-shelf-iframe {
    height: 580px;
  }
}

@media (max-width: 480px) {
  .anyflip-shelf-iframe {
    height: 520px;
  }
}
