/* assets/css/custom.css */

:root { 
    /* กำหนดค่าเริ่มต้น (กรณี Database มีปัญหา) */
    --main-font: 'Sarabun', sans-serif; 
    --accent-color: #c5a059; 
    --bg-color: #f8f9fa; 
}

body { 
    /* ✅ เรียกใช้ตัวแปร --main-font แทนชื่อฟอนต์ตรงๆ */
    font-family: var(--main-font); 
    background-color: var(--bg-color); 
}

/* --- 2. Navbar --- */
.navbar-glass { 
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(10px); 
    border-bottom: 1px solid rgba(0,0,0,0.05); 
    box-shadow: 0 4px 30px rgba(0,0,0,0.03); 
}

/* --- 3. Card Structure (Updated) --- */
.book-card { 
    position: relative; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    /* Themes จะมา override สีพื้นหลัง/ขอบ ทีหลัง */
}

/* ✅ ส่วนที่ปรับแก้ล่าสุด: ลดความสูง + ชิดขอบบน */
.card-img-wrapper { 
    position: relative; 
    width: 100%; 
    padding-top: 85%; /* ลดจาก 140% เหลือ 85% ให้เตี้ยลง */
    overflow: hidden; 
    cursor: pointer; 
}

.card-img-top { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    object-position: top center; /* บังคับภาพชิดขอบบน */
    object-fit: cover; 
    transition: transform 0.6s ease; 
}

.book-card:hover .card-img-top { transform: scale(1.08); }

.card-overlay { 
    position: absolute; top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.3); opacity: 0; 
    transition: opacity 0.3s; 
    display: flex; align-items: center; justify-content: center; 
}
.book-card:hover .card-overlay { opacity: 1; }

.btn-read-now { 
    background: rgba(255,255,255,0.95); color: #333; 
    padding: 8px 20px; border-radius: 30px; 
    font-weight: 600; font-size: 14px; 
    transform: translateY(20px); transition: all 0.3s; 
}
.book-card:hover .btn-read-now { transform: translateY(0); }

.card-body { 
    padding: 20px; 
    flex-grow: 1; 
    display: flex; flex-direction: column; justify-content: space-between; 
}

.book-title { 
    font-size: 1.08rem; font-weight: 600; margin-bottom: 5px; 
    display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; 
    overflow: hidden; line-height: 1.5; 
	color: #0079e4;
}
.book-meta { 
    font-size: 0.85rem; margin-bottom: 15px; 
    display: flex; justify-content: space-between; align-items: center; 
}

/* --- 4. Action Buttons --- */
.action-row { 
    display: flex; justify-content: center; gap: 10px; 
    padding-top: 15px; border-top: 1px solid rgba(0,0,0,0.05); 
}
.btn-action { 
    width: 36px; height: 36px; border-radius: 50%; border: none; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 14px; transition: all 0.2s; cursor: pointer; 
    color: #555; background: #f0f0f0; text-decoration: none; 
}
.btn-action:hover { transform: scale(1.1); color: white; }
.btn-action.pdf:hover { background: #dc3545; }
.btn-action.fb:hover { background: #1877F2; }
.btn-action.mail:hover { background: #198754; }
.btn-action.read:hover { background: var(--accent-color); }

/* --- 5. Components เฉพาะหน้า (รวมไว้ที่เดียวได้เลย ไม่ตีกัน) --- */

/* Tabs (สำหรับ Index) */
#categoryTabs::-webkit-scrollbar { display: none; }
#categoryTabs { -ms-overflow-style: none; scrollbar-width: none; }
.nav-link { cursor: pointer; transition: all 0.3s; color: #555; }
.nav-link:hover { background-color: #f0f0f0; }
.nav-link.active { 
    background-color: var(--accent-color) !important; 
    color: white !important; 
    border-color: var(--accent-color) !important; 
}

/* Banner (สำหรับ Page) */
.page-banner {
    position: relative; width: 100%; min-height: 280px;
    background-color: #eee; background-size: cover; background-position: center;
    display: flex; align-items: center; justify-content: center; color: white;
    margin-top: 60px; border-radius: 0 0 40px 40px; overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.banner-overlay { 
    position: absolute; top:0; left:0; right:0; bottom:0; 
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.7)); 
}
.banner-content { 
    position: relative; z-index: 2; text-align: center; 
    padding: 20px; max-width: 800px; 
}

/* Pagination (สำหรับ Page) */
.pagination .page-item.active .page-link { 
    background-color: var(--accent-color); border-color: var(--accent-color); 
}
.pagination .page-link { color: #555; border-radius: 5px; margin: 0 3px; }
.pagination .page-link:hover { background-color: #eee; color: #333; }

/* Modals */
.modal-fullscreen .modal-body { height: 100vh; overflow: hidden; padding: 0; background: #2b2b2b; }
/* ✅ บังคับความสูงของกล่องหนังสือ ด้วย CSS (แม่นยำกว่า JS) */
#flipbookContainer {
    /* ความสูงเต็มจอ (100vh) ลบออก 160px (เผื่อที่ให้ Header/Taskbar) */
    height: calc(111vh - 160px) !important;
    
    /* จัดกึ่งกลาง และไม่ให้ชิดขอบเกินไป */
    width: 100% !important;
    margin: 0 auto;
}
.tooltip {
    z-index: 999999 !important;
}

/* =========================================
   ✨ MODERN FOOTER STYLE
   ========================================= */
.site-footer {
    background-color: #1a1a1a; /* พื้นหลังสีเข้ม */
    color: #fff;
    padding-top: 60px;
    margin-top: 80px; /* เว้นระยะจากเนื้อหาด้านบน */
    position: relative;
    font-size: 0.95rem;
}

/* เส้นตกแต่งด้านบน */
.site-footer::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color, #c5a059), #f8f9fa, var(--accent-color, #c5a059));
}

.site-footer .brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color, #c5a059);
    letter-spacing: 1px;
}

.site-footer .heading {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 10px;
}

.site-footer .heading::after {
    content: "";
    position: absolute;
    left: 0; bottom: 0;
    width: 40px;
    height: 3px;
    background: var(--accent-color, #c5a059);
}

/* ลิงก์ต่างๆ */
.footer-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links ul li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-links ul li:last-child {
    border-bottom: none;
}

.footer-links ul li a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    display: inline-block;
    transition: 0.3s;
}

/* Effect: Hover แล้วเลื่อนขวา */
.footer-links ul li a:hover {
    color: var(--accent-color, #c5a059);
    transform: translateX(5px);
}

.footer-links ul li a i {
    margin-right: 8px;
    font-size: 0.8rem;
    color: var(--accent-color, #c5a059);
}

/* Social Icons */
.social-links a {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    margin-right: 10px;
    text-decoration: none;
    transition: 0.3s;
}

.social-links a:hover {
    background: var(--accent-color, #c5a059);
    color: #fff;
    transform: translateY(-3px);
}

/* Footer Bottom (ส่วนลิขสิทธิ์) */
.footer-bottom {
    background: #111;
    padding: 20px 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

/* 📱 Mobile Responsive: จัดกลางทั้งหมด */
@media (max-width: 768px) {
    .site-footer {
        text-align: center;
    }
    .site-footer .heading::after {
        left: 50%;
        transform: translateX(-50%); /* เส้นขีดใต้ชื่อเมนูอยู่ตรงกลาง */
    }
    .social-links {
        display: flex;
        justify-content: center;
        margin-bottom: 20px;
    }
    .footer-bottom .text-md-end {
        text-align: center !important;
        margin-top: 10px;
    }
}

/* ⬆️ Back to Top Button */
.back-to-top {
    position: fixed;
    visibility: hidden;
    opacity: 0;
    right: 15px;
    bottom: 15px;
    z-index: 996;
    background: var(--accent-color, #c5a059);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: all 0.4s;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.back-to-top i {
    font-size: 20px;
    color: #fff;
    line-height: 0;
}

.back-to-top.active {
    visibility: visible;
    opacity: 1;
    bottom: 30px; /* เด้งขึ้นมา */
}

.back-to-top:hover {
    background: #fff;
    color: var(--accent-color, #c5a059);
}
.back-to-top:hover i {
    color: var(--accent-color, #c5a059);
}
/* ... (CSS เดิม) ... */

        /* ✅ ปรับแต่ง Pagination ให้ปุ่มเท่ากันเป๊ะ */
        .pagination {
            gap: 5px; /* ระยะห่างระหว่างปุ่ม */
        }
        
        .pagination .page-link {
            width: 45px;       /* ล็อคความกว้าง */
            height: 45px;      /* ล็อคความสูง */
            display: flex;     /* ใช้ Flexbox จัดกึ่งกลาง */
            align-items: center;
            justify-content: center;
            padding: 0;        /* ล้าง Padding เดิมของ Bootstrap */
            border-radius: 10px !important; /* ปรับความมนของขอบ */
            font-weight: 600;
            color: #666;
            border: 1px solid #eee;
            transition: all 0.2s;
        }

        /* ปุ่ม Hover */
        .pagination .page-link:hover {
            background-color: #f8f9fa;
            color: var(--accent-color, #c5a059);
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(0,0,0,0.05);
        }

        /* ปุ่ม Active (หน้าปัจจุบัน) */
        .pagination .page-item.active .page-link {
            background-color: var(--accent-color, #c5a059);
            border-color: var(--accent-color, #c5a059);
            color: #fff;
            box-shadow: 0 4px 10px rgba(197, 160, 89, 0.4);
        }

        /* ปุ่ม Disabled (กดไม่ได้) */
        .pagination .page-item.disabled .page-link {
            background-color: #f9f9f9;
            color: #ccc;
            border-color: #eee;
            cursor: not-allowed;
            transform: none;
        }
		
		/* ... (CSS ส่วนอื่นๆ คงเดิม) ... */

        /* ✅ ปรับปุ่มตัวกรองให้ใหญ่ขึ้น สวยขึ้น */
        .nav-pills .nav-link {
            border-radius: 50px;
            padding: 12px 35px; /* เพิ่มพื้นที่ขอบ (บนล่าง 12px, ซ้ายขวา 35px) */
            font-size: 1.1rem;  /* ขยายตัวหนังสือ */
            font-weight: 600;
            color: #555;
            background: #fff;
            border: 1px solid #eee;
            margin-right: 12px; /* เพิ่มระยะห่างระหว่างปุ่ม */
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0,0,0,0.02); /* เงาจางๆ ปกติ */
        }

        /* Effect ตอนเอาเมาส์ชี้ */
        .nav-pills .nav-link:hover {
            background: #fff;
            border-color: var(--accent-color, #c5a059);
            color: var(--accent-color, #c5a059);
            transform: translateY(-3px); /* ลอยขึ้นสูงกว่าเดิมนิดนึง */
            box-shadow: 0 6px 6px rgba(0,0,0,0.08);
        }

        /* ปุ่มที่ถูกเลือก (Active) */
        .nav-pills .nav-link.active {
            background-color: var(--accent-color, #c5a059);
            border-color: var(--accent-color, #c5a059);
            color: #fff;
            box-shadow: 0 8px 10px rgba(197, 160, 89, 0.4); /* เงาสีทองฟุ้งๆ */
            transform: translateY(-2px);
        }
		/* สีปุ่ม View (สีฟ้าคราม) */
.btn-action.view { color: #17a2b8; border-color: #17a2b8; }
.btn-action.view:hover { background: #17a2b8; color: #fff; }

/* สีปุ่ม Copy (สีเทาเข้ม) */
.btn-action.copy { color: #6c757d; border-color: #6c757d; }
.btn-action.copy:hover { background: #6c757d; color: #fff; }

/* เพื่อให้เอฟเฟกต์รูปปกทำงานสมบูรณ์ครับ */
.hover-opacity-100 { opacity: 0; transition: opacity 0.3s; }
.cover-wrapper:hover .hover-opacity-100 { opacity: 1; }



/* ✅ ปรับแต่ง Pagination ให้ปุ่มเท่ากัน */
.custom-pagination .pagination {
        margin-bottom: 0;
        gap: 5px; /* ระยะห่างระหว่างปุ่ม */
    }

.custom-pagination .page-item .page-link {
        width: 38px;  /* 👈 กำหนดความกว้างตายตัว */
        height: 38px; /* 👈 กำหนดความสูงตายตัว */
        
        display: flex;
        align-items: center;
        justify-content: center;
        
        padding: 0; /* ลบ padding เดิมออก เพื่อให้ตัวเลขอยู่กลางเป๊ะ */
        border-radius: 8px !important; /* มุมมนสวยๆ */
        border: 1px solid #e0e0e0;
        color: #666;
        font-weight: 500;
        transition: all 0.2s;
    }

/* Effect ตอนเอาเมาส์ชี้ */
.custom-pagination .page-item .page-link:hover {
        background-color: #f0f0f0;
        color: #333;
        border-color: #d0d0d0;
        transform: translateY(-1px);
    }

    /* ปุ่มหน้าที่เลือกอยู่ (Active) */
.custom-pagination .page-item.active .page-link {
        background-color: var(--bs-primary); /* สีหลัก (สีน้ำเงิน) */
        border-color: var(--bs-primary);
        color: #fff;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    /* ปุ่มที่กดไม่ได้ (Disabled) */
.custom-pagination .page-item.disabled .page-link {
        background-color: #f8f9fa;
        color: #ccc;
        border-color: #eee;
    }
