:root {
    --primary: #1a1a1a;
    --accent: #d4af37;
    --bg-page: #FAF8F5;
    --bg-card: #ffffff;
    --border: #f0ebe1;
    --text-muted: #8b8b8b;
    --text-dark: #2c2c2c;
    --btn-dark: #1a1a1a;
}

body {
    background-color: var(--bg-page);
    font-family: 'Outfit', sans-serif;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
}

/* ── LAYOUT ── */
.ebook-container {
    width: 90%;
    max-width: 1600px;
    margin: 40px auto 80px;
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 30px;
}
@media (max-width: 1024px) {
    .ebook-container {
        grid-template-columns: 1fr;
        margin: 60px auto 80px !important;
    }
}

/* ── SEARCH & PILLS ── */
.top-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 16px;
    flex-wrap: wrap;
}
.pill-categories {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 0 8px;
    -webkit-overflow-scrolling: touch;
}
.pill-categories::-webkit-scrollbar { display: none; width: 0; height: 0; }
.pill {
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid rgba(26, 26, 26, 0.1);
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s ease;
}
.pill:hover { 
    border-color: var(--primary);
    background: #fafafa;
}
.pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.12);
}
.search-wrap {
    position: relative;
    flex-grow: 1;
    max-width: 320px;
}
.search-wrap input {
    width: 100%;
    padding: 10px 16px 10px 38px;
    border-radius: 30px;
    border: 1px solid #e2ddcf;
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    outline: none;
    background: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.01);
}
.search-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.05);
}
.search-wrap i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s ease;
}
.search-wrap input:focus + i {
    color: var(--primary);
}

/* ── REKOMENDASI HORIZONTAL ── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.section-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dark);
}
.section-title i { color: var(--accent); }
.view-all {
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
}

.recommendation-wrapper {
    background: #fdfaf4;
    border: 1px solid #f0e9dc;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 40px;
    position: relative;
}
.recommendation-scroll {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}
.recommendation-scroll::-webkit-scrollbar { height: 6px; }
.recommendation-scroll::-webkit-scrollbar-track { background: transparent; }
.recommendation-scroll::-webkit-scrollbar-thumb { 
    background: rgba(26, 26, 26, 0.05); 
    border-radius: 3px;
}
.recommendation-scroll:hover::-webkit-scrollbar-thumb {
    background: rgba(26, 26, 26, 0.12);
}

.recom-card {
    display: flex;
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    min-width: 380px;
    gap: 18px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.02), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(26, 26, 26, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.recom-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    border-color: rgba(26, 26, 26, 0.12);
}
.recom-cover {
    width: 100px;
    height: 145px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}
.recom-card:hover .recom-cover {
    transform: scale(1.03);
}
.recom-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.recom-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text-dark);
}
.recom-author {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px;
}
.recom-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.recom-badge-premium {
    font-size: 10.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    width: max-content;
    display: inline-flex;
    align-items: center;
    background: rgba(16, 185, 129, 0.08); /* emerald soft bg */
    color: #065f46;
    letter-spacing: 0.2px;
    margin-bottom: auto;
}
.recom-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.btn-baca {
    background: var(--btn-dark);
    color: #fff;
    border: 1px solid var(--btn-dark);
    padding: 6px 14px; /* Reduced vertical padding from 8px to 6px */
    border-radius: 8px;
    font-size: 12px; /* Reduced font-size slightly */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    justify-content: center;
}
.btn-baca:hover {
    background: #000;
    border-color: #000;
    transform: translateY(-1px);
}
.btn-sample {
    background: #fff;
    color: var(--text-dark);
    border: 1px solid rgba(26,26,26,0.15);
    padding: 6px 14px; /* Reduced vertical padding from 8px to 6px */
    border-radius: 8px;
    font-size: 12px; /* Reduced font-size slightly */
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    justify-content: center;
}
.btn-sample:hover {
    background: #f9f9f9;
    border-color: var(--text-dark);
    transform: translateY(-1px);
}

/* ── GRID KOLEKSI TERBARU ── */
.tabs-header {
    display: flex;
    gap: 24px;
    border-bottom: 2px solid #e2ddcf;
    margin-bottom: 24px;
    align-items: center;
}
.tab-btn {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    padding-bottom: 10px;
    cursor: pointer;
    position: relative;
}
.tab-btn.active {
    color: var(--text-dark);
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0; right: 0;
    height: 2px;
    background: var(--text-dark);
}

.ebook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 24px;
}
.grid-card {
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(26,26,26,0.04);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.grid-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    border-color: rgba(26,26,26,0.1);
}
.grid-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
    transition: transform 0.3s ease;
}
.grid-card:hover .grid-cover {
    transform: scale(1.02);
}
.grid-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px;
    line-height: 1.4;
    color: var(--text-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.grid-author {
    font-size: 11.5px;
    color: var(--text-muted);
    margin: 0 0 8px;
}
.grid-rating {
    font-size: 11px;
    color: var(--text-dark);
    margin: 4px 0 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.grid-rating i {
    color: #f1c40f;
}
.grid-badge-premium {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    width: max-content;
    display: inline-flex;
    align-items: center;
    background: rgba(59, 130, 246, 0.08); /* blue soft bg */
    color: #1e40af;
    letter-spacing: 0.2px;
    margin-bottom: 10px;
}

/* New Grid Action buttons matching recommendation styles exactly */
.btn-grid-baca {
    background: var(--btn-dark);
    color: #fff;
    border: 1px solid var(--btn-dark);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}
.btn-grid-baca:hover {
    background: #000;
    border-color: #000;
    transform: translateY(-1px);
}
.btn-grid-unduh {
    background: #fff;
    color: var(--text-dark);
    border: 1px solid rgba(26,26,26,0.15);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}
.btn-grid-unduh:hover {
    background: #f9f9f9;
    border-color: var(--text-dark);
    transform: translateY(-1px);
}

/* ── SIDEBAR ── */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.sidebar-card {
    background: #ffffff;
    border: 1px solid rgba(26,26,26,0.06);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}
.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
}
.sidebar-title i { color: var(--accent); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}
.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border-radius: 12px;
    transition: background 0.2s ease;
}
.stat-item:hover {
    background: rgba(26,26,26,0.02);
}
.stat-item i {
    font-size: 18px;
    color: var(--accent);
    background: rgba(212, 175, 87, 0.08); /* soft gold background */
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(212, 175, 87, 0.05);
}
.stat-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}
.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.3;
}

.cat-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.cat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13.5px;
}
.cat-left {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
    font-weight: 500;
}
.cat-left i {
    color: var(--text-muted);
    width: 14px;
    text-align: center;
}
.cat-count {
    background: rgba(26,26,26,0.05);
    color: var(--text-dark);
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}
.cat-view-all {
    display: block;
    margin-top: 16px;
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.panduan-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}
.btn-panduan {
    background: #fff;
    border: 1px solid #e2ddcf;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-dark);
    transition: all 0.2s ease;
}
.btn-panduan:hover { 
    background: #fafafa;
    border-color: var(--text-dark);
}

/* ── RESPONSIVE MEDIA QUERIES (MOBILE STYLES) ── */
@media (max-width: 768px) {
    .ebook-container {
        width: 100% !important;
        padding: 0 16px !important;
        margin: 20px auto !important;
        box-sizing: border-box !important;
    }
    .top-filter-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px !important;
        margin-bottom: 20px;
    }
    .search-wrap {
        max-width: 100% !important;
        width: 100% !important;
    }
    .pill-categories {
        width: 100%;
    }
    .recommendation-wrapper {
        padding: 16px !important;
        margin-bottom: 30px;
        border-radius: 16px;
    }
    .recom-card {
        min-width: 290px !important;
        padding: 14px !important;
        gap: 14px !important;
        border-radius: 12px;
    }
    .recom-cover {
        width: 85px !important;
        height: 120px !important;
        border-radius: 8px;
    }
    .recom-title {
        font-size: 14px !important;
    }
    .recom-desc {
        display: none !important; /* hide description on small mobile screen to avoid clutter */
    }
    .recom-actions {
        margin-top: auto !important;
    }
    .btn-baca, .btn-sample {
        padding: 5px 10px !important; /* Reduced vertical padding for mobile recommendation buttons */
        font-size: 11px !important;
        border-radius: 6px !important;
    }

    /* CRITICAL RESPONSIVENESS FIX: Grid template columns forced to 2 columns on mobile */
    .ebook-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }
    .grid-card {
        padding: 10px !important;
        border-radius: 12px !important;
    }
    .grid-cover {
        border-radius: 8px !important;
        margin-bottom: 8px !important;
    }
    .grid-title {
        font-size: 12px !important;
        margin-bottom: 2px !important;
    }
    .grid-author {
        font-size: 10px !important;
        margin-bottom: 6px !important;
    }
    .grid-rating {
        font-size: 10px !important;
        margin: 2px 0 6px !important;
    }
    .grid-badge-premium {
        font-size: 9px !important;
        padding: 2px 6px !important;
        margin-bottom: 8px !important;
    }
    .grid-card div[style*="display:flex;gap:6px;"] {
        flex-direction: row !important; /* Keep buttons next to each other */
    }
    .btn-grid-baca, .btn-grid-unduh {
        padding: 5px 8px !important;
        font-size: 10px !important;
        gap: 4px !important;
        border-radius: 6px !important;
    }
}