/* =========================================
   🎨 CORE SYSTEM (ค่าพื้นฐาน)
   ========================================= */
:root {
    --transition-speed: 0.3s ease;
    --gold-color: #c5a059; /* กำหนดตัวแปรสีทองไว้ใช้ง่ายๆ */
}

/* ตั้งค่าพื้นฐานการ์ด (Reset) */
.book-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all var(--transition-speed);
    overflow: hidden;
    background: #fff; /* Default */
    
    /* ✅ เพิ่มขอบสีทอง 1px ตามที่ขอครับ */
    border: 1px solid var(--gold-color);
}

.book-card .card-img-wrapper {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Overlay ปุ่มอ่าน (พื้นฐาน) */
.book-card .card-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease;
}
.book-card:hover .card-overlay { opacity: 1; }

.btn-read-now {
    background: #fff; color: #333; padding: 8px 20px; border-radius: 50px;
    font-weight: 800; font-size: 0.9rem; transform: translateY(20px);
    transition: transform 0.3s ease; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.book-card:hover .btn-read-now { transform: translateY(0); }

/* ปุ่ม Action Row */
.action-row { display: flex; gap: 8px; margin-top: auto; }
.btn-action {
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; border: 1px solid #eee; color: #666; background: #fff;
    transition: all 0.2s; font-size: 0.85rem; cursor: pointer;
}
.btn-action:hover { transform: scale(1.15); border-color: transparent; color: #fff; }

/* สีปุ่มเฉพาะเมื่อ Hover */
.btn-action.read:hover { background: #fd7e14; }
.btn-action.pdf:hover { background: #dc3545; }
.btn-action.fb:hover { background: #1877f2; }
.btn-action.mail:hover { background: #198754; }
.btn-action.view:hover { background: #0d6efd; }
.btn-action.copy:hover { background: #6c757d; }


/* =========================================
   1. 🏛️ THEME: CLASSIC (มาตรฐาน ยืนหนึ่ง)
   ========================================= */
.theme-classic { background-color: #f8f9fa !important; }
.theme-classic .book-card {
    /* ใช้ขอบทองจาก Core System */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.theme-classic .book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.theme-classic .card-img-top { height: 260px; object-fit: cover; }
.theme-classic .card-body { padding: 15px; }
.theme-classic .book-title { font-weight: 700; color: #333; font-size: 1.1rem; margin-bottom: 8px; }


/* =========================================
   2. 🔮 THEME: GLASS (กระจกฟุ้งๆ - หรูหรา)
   ========================================= */
.theme-glass { 
    background: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%) !important;
    min-height: 100vh;
}
.theme-glass .book-card {
    background: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
}
.theme-glass .book-card:hover { 
    transform: translateY(-10px); 
    background: rgba(255, 255, 255, 0.9) !important;
}
.theme-glass .card-img-top { border-radius: 20px 20px 0 0; height: 250px; object-fit: cover; }
.theme-glass .card-body { padding: 20px; }
.theme-glass .book-title { color: #1a237e; font-weight: 800; letter-spacing: 0.5px; }


/* =========================================
   3. 🎬 THEME: DARK POSTER (มืด ดุดัน มีแสงทอง)
   ========================================= */
.theme-dark-poster { 
    background-color: #121212 !important; 
    color: #e0e0e0 !important; 
}
/* บังคับตัวหนังสือหน้าเว็บให้ขาว */
.theme-dark-poster h1, .theme-dark-poster .display-6, .theme-dark-poster p.text-muted { color: #f8f9fa !important; }

.theme-dark-poster .book-card {
    background: #1e1e1e !important;
    color: #fff;
    border: 1px solid #333; /* ทับขอบทองด้วยสีเทาเข้มเพื่อให้เข้ากับธีมมืด */
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.theme-dark-poster .book-card:hover {
    border-color: #c5a059; /* เมื่อ Hover ค่อยเป็นขอบทอง */
    box-shadow: 0 0 25px rgba(197, 160, 89, 0.5);
    transform: scale(1.02);
}
.theme-dark-poster .card-body { background: #1e1e1e !important; }
.theme-dark-poster .book-title { color: #fff !important; font-size: 1.1rem; }
.theme-dark-poster .text-muted { color: #aaa !important; }
.theme-dark-poster .btn-action { background: #333 !important; color: #fff !important; border-color: #555 !important; }
.theme-dark-poster .btn-action:hover { background: #c5a059 !important; color: #000 !important; }


/* =========================================
   4. 🏢 THEME: CORPORATE (ทางการ น้ำเงิน-ขาว)
   ========================================= */
.theme-corporate { background-color: #f4f7f6 !important; }
.theme-corporate .book-card {
    border: none; /* ลบขอบทองออก */
    border-top: 5px solid #0056b3; /* ใช้แถบน้ำเงินแทน */
    border-bottom: 1px solid #ddd;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.theme-corporate .book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
    border-top-color: #0d6efd;
}
.theme-corporate .card-img-top { height: 240px; object-fit: cover; margin: 15px 15px 0 15px; width: calc(100% - 30px); border: 1px solid #eee; }
.theme-corporate .book-title { 
    color: #0056b3; 
    font-weight: 700; 
    border-bottom: 2px solid #eee; 
    padding-bottom: 10px; margin-bottom: 10px; 
}


/* =========================================
   5. 📑 THEME: LIST HORIZONTAL (แนวนอน)
   ========================================= */
@media (min-width: 768px) {
    .theme-list-horizontal .book-card {
        flex-direction: row; height: 200px;
        border: 1px solid #e0e0e0; border-left: 5px solid #6c757d;
        border-radius: 4px;
    }
    .theme-list-horizontal .book-card:hover {
        border-left-color: #198754;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        transform: translateX(5px);
    }
    .theme-list-horizontal .card-img-wrapper { width: 160px; flex-shrink: 0; }
    .theme-list-horizontal .card-img-top { height: 100%; object-fit: cover; }
    .theme-list-horizontal .card-body { padding: 20px; width: 100%; justify-content: center; }
    .theme-list-horizontal .book-title { font-size: 1.25rem; }
    .theme-list-horizontal .book-desc { -webkit-line-clamp: 2; }
}


/* =========================================
   6. ⚪ THEME: MATERIAL ROUND (กลมมน ลอยเด่น)
   ========================================= */
.theme-material-round { background-color: #eceff1 !important; }
.theme-material-round .book-card {
    border: none; /* ลบขอบทอง */
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 4px 6px rgba(50,50,93,0.11), 0 1px 3px rgba(0,0,0,0.08);
}
.theme-material-round .book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.theme-material-round .card-img-top { height: 260px; object-fit: cover; border-radius: 24px 24px 0 0; }
.theme-material-round .card-body { padding: 20px; }
.theme-material-round .book-title { font-weight: 600; color: #263238; }


/* =========================================
   7. 🎮 THEME: NEON TECH (ไซเบอร์พังค์ ดำ-เขียว)
   ========================================= */
.theme-neon-tech { background-color: #000 !important; color: #0f0 !important; font-family: 'Courier New', monospace !important; }
.theme-neon-tech h1, .theme-neon-tech .display-6, .theme-neon-tech .text-muted { color: #0f0 !important; text-shadow: 0 0 5px #0f0; }

.theme-neon-tech .book-card {
    background: #050505 !important;
    border: 1px solid #0f0 !important; /* ขอบเขียว */
    border-radius: 0;
    box-shadow: 0 0 5px #0f0;
}
.theme-neon-tech .book-card:hover {
    box-shadow: 0 0 20px #0f0, inset 0 0 10px #0f0;
    transform: scale(1.02);
}
.theme-neon-tech .card-img-top { height: 280px; object-fit: cover; filter: grayscale(100%) contrast(1.2); border-bottom: 1px solid #0f0; }
.theme-neon-tech .book-card:hover .card-img-top { filter: grayscale(0%); }
.theme-neon-tech .card-body { background: #000 !important; }
.theme-neon-tech .book-title { color: #0f0 !important; text-transform: uppercase; letter-spacing: 2px; }
.theme-neon-tech .text-muted { color: #0a0 !important; }
.theme-neon-tech .btn-action { background: #000 !important; border: 1px solid #0f0 !important; color: #0f0 !important; border-radius: 0 !important; }
.theme-neon-tech .btn-action:hover { background: #0f0 !important; color: #000 !important; }


/* =========================================
   8. 🖼️ THEME: MINIMAL GALLERY (คลีนสุดๆ ไร้ขอบ)
   ========================================= */
.theme-minimal-gallery { background-color: #fff !important; }
.theme-minimal-gallery .book-card {
    background: transparent !important;
    border: none; /* ลบขอบทอง */
    box-shadow: none;
    overflow: visible;
}
.theme-minimal-gallery .card-img-wrapper {
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s;
}
.theme-minimal-gallery .book-card:hover .card-img-wrapper {
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    transform: translateY(-8px);
}
.theme-minimal-gallery .card-img-top { height: 320px; object-fit: cover; }
.theme-minimal-gallery .card-body { padding: 15px 0 0 0; background: transparent !important; }
.theme-minimal-gallery .book-title { font-size: 1rem; font-weight: 500; color: #000; text-align: center; }
.theme-minimal-gallery .book-meta { text-align: center; font-size: 0.8rem; }
.theme-minimal-gallery .action-row { justify-content: center; opacity: 0; transition: 0.3s; }
.theme-minimal-gallery .book-card:hover .action-row { opacity: 1; }


/* =========================================
   9. 📜 THEME: VINTAGE PAPER (กระดาษเก่า)
   ========================================= */
.theme-vintage-paper { background-color: #eaddcf !important; } 
.theme-vintage-paper .book-card {
    background: #fffef0 !important; 
    border: 1px double #8d7b65; /* ขอบเส้นคู่ */
    border-radius: 2px;
    box-shadow: 5px 5px 0px rgba(141, 123, 101, 0.4); 
}
.theme-vintage-paper .book-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 8px 8px 0px rgba(141, 123, 101, 0.6);
}
.theme-vintage-paper .card-img-top { 
    height: 260px; object-fit: cover; 
    padding: 10px; background: #fffef0; 
    border-bottom: 1px double #8d7b65;
    filter: sepia(0.4);
}
.theme-vintage-paper .card-body { padding: 15px; }
.theme-vintage-paper .book-title { color: #5c4b37; font-weight: bold; }
.theme-vintage-paper .btn-action { border-radius: 3px; border: 1px solid #8d7b65; color: #8d7b65; }


/* =========================================
   10. 🌈 THEME: VIBRANT GRADIENT (ขอบสีรุ้ง)
   ========================================= */
.theme-vibrant-gradient .book-card {
    background: #fff;
    position: relative;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    
    border: 3px solid transparent;
    background-image: linear-gradient(white, white), linear-gradient(45deg, #f093fb, #f5576c, #4facfe);
    background-origin: border-box;
    background-clip: content-box, border-box;
}
.theme-vibrant-gradient .book-card:hover { transform: scale(1.03); box-shadow: 0 15px 35px rgba(245, 87, 108, 0.2); }
.theme-vibrant-gradient .card-img-top { height: 250px; object-fit: cover; border-radius: 16px 16px 0 0; }
.theme-vibrant-gradient .card-body { padding: 15px; }
.theme-vibrant-gradient .book-title { 
    background: linear-gradient(45deg, #f093fb, #f5576c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}


/* =========================================
   📱 MOBILE OPTIMIZATION (FORCED 100%)
   ========================================= */
@media (max-width: 576px) {
    .book-card {
        display: flex !important; flex-direction: row !important;
        height: 140px !important; min-height: 140px !important; max-height: 140px !important;
        padding: 0 !important; margin-bottom: 15px; border-radius: 12px !important;
        background: #fff !important; box-shadow: 0 4px 10px rgba(0,0,0,0.05) !important;
        border: 1px solid #eee !important;
    }

    /* Override สีพื้นหลังมือถือเฉพาะธีม Dark */
    .theme-dark-poster .book-card, .theme-neon-tech .book-card { 
        background: #222 !important; border-color: #444 !important; 
    }
    
    .book-card .card-img-wrapper { width: 35% !important; height: 100% !important; flex-shrink: 0; margin: 0 !important; }
    .book-card .card-img-top { width: 100% !important; height: 100% !important; object-fit: cover !important; border-radius: 0 !important; padding: 0 !important; border: none !important; filter: none !important; }
    .book-card .card-overlay { display: none !important; }

    .book-card .card-body {
        width: 65% !important; height: 100% !important; padding: 10px !important;
        display: flex; flex-direction: column; justify-content: center;
        background: transparent !important;
    }

    .book-title {
        font-size: 0.95rem !important; margin-bottom: 4px; line-height: 1.3;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
        color: #333 !important; text-shadow: none !important; -webkit-text-fill-color: #333 !important; background: none !important;
    }
    
    /* แก้สีตัวหนังสือในมือถือสำหรับธีมมืด */
    .theme-dark-poster .book-title, .theme-neon-tech .book-title { color: #fff !important; -webkit-text-fill-color: #fff !important; }

    .book-meta { font-size: 0.75rem; color: #888; margin-bottom: 4px; }
    .action-row { margin-top: auto; gap: 6px; opacity: 1 !important; justify-content: flex-start !important; }
    .btn-action {
        width: 28px !important; height: 28px !important; font-size: 0.7rem !important;
        background: #fff !important; color: #666 !important; border: 1px solid #eee !important; border-radius: 50% !important;
    }
}