:root { 
    --accent: #ff84d8; 
    --accent-dark: #a500a2; 
    --pink-bg: #ffddf2; 
    --text-dark: #1b1b1b; 
    --text-light: #919191;
}

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

body { 
    font-family: 'Source Sans Pro', Arial, sans-serif; 
    margin: 0; background: #161616; color: var(--text-dark); line-height: 1.5; 
}

/* ============ FULL-WIDTH DARK HEADER ============ */
.site-header {
    background-color: #161616;
    padding: 0;
    width: 100%;
}

.header-container {
    max-width: 1160px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px;
}

.logo {
    font-family: 'Fjalla One', Arial, sans-serif !important;
    font-size: 30px;
    color: #ffddf2;
    text-decoration: none;
    cursor: pointer;
    letter-spacing: 0.5px;
    display: inline-block !important;
    line-height: 1.2 !important;
}
.logo:hover { color: #ff84d8; }

/* Nav tabs */
.nav-links {
    display: flex;
    gap: 0;
}
.nav-links,
.nav-links a {
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
}
.nav-links a {
    text-transform: uppercase;
    letter-spacing: 0.063em;
    color: #e2e2e2;
    text-decoration: none;
    padding: 16px 48px;
    font-size: 15px;
    transition: color 0.2s ease;
}
.nav-links a:hover { color: #ffddf2; }
.nav-links a.active { 
    color: #ffddf2; 
    border-bottom: 1px solid #e2e2e2;
}


/* ============ MAIN WRAPPER ============ */
.page-body {
    max-width: 1160px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    gap: 32px;
    background-color: #161616 !important;
}

/* ============ SIDEBAR FILTERS ============ */
.sidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background-color: #161616 !important;
}

.sidebar h3 {
    font-size: 14px;
    text-transform: uppercase;
    color: #ffddf2;
    margin-bottom: 12px;
    letter-spacing: 0.063em;
    margin-top: 24px;
}
.sidebar h3:first-child { margin-top: 0; }

/* Clear All button */
#clear-all {
    margin-bottom: 16px;
    margin-top: 24px;
}
#clear-all button,
.ais-ClearRefinements-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 56px !important;
    padding: 0 40px !important;
    border-radius: 48px !important;
    background-color: #ffddf2 !important;
    color: #231c21 !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    line-height: 1.25 !important;
    text-decoration: none !important;
    cursor: pointer !important;
    border: none !important;
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
}
#clear-all button:hover,
.ais-ClearRefinements-button:hover {
    background-color: #ffc9eb !important;
}

/* Sidebar filter items */
.filter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #e2e2e2;
    background-color: rgba(0,0,0,0.25);
    border-radius: 4px;
    border: none;
    margin-bottom: 8px;
}
.filter-item.selected {
    color: #ffddf2;
    font-weight: 700;
    background-color: rgba(255,221,242,0.1);
    border: 1px solid #ff84d8;
}
.filter-count {
    background: rgba(255,255,255,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    color: #a4a4a4;
    margin-left: 8px;
}

/* Sidebar text fonts */
.sidebar *,
#store-selector *,
#section-list *,
#new-filter *,
#bookmarked-filter *,
#local-author-filter *,
#best-sellers-filter *,
.filter-item,
.filter-count,
.filter-tag {
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
}

/* Sidebar dropdown selects (New Since) */
.sidebar-select-label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
}
.sidebar-select {
    width: 100%;
    padding: 6px 8px;
    background: rgba(0,0,0,0.3);
    color: #e2e2e2;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
    cursor: pointer;
    outline: none;
}
.sidebar-select:focus {
    border-color: #ff84d8;
}
.sidebar-select option {
    background: #2a2a2a;
    color: #e2e2e2;
}

/* ============ MAIN PANEL (dark) ============ */
.main-panel {
    flex: 1;
    min-width: 0;
    background-color: #161616;
    color: #e2e2e2;
}

/* SEARCH BOX */
#searchbox input {
    width: 100%;
    padding: 8px 16px;
    border: 1px solid rgba(76,76,76,0.5);
    background: transparent;
    color: #f7f7f7;
    font-family: 'Source Sans Pro', Arial, sans-serif;
    font-size: 16px;
    outline: none;
}
#searchbox input::placeholder { color: #ffddf2; }

/* Search box row: search input on left, last-updated text on right */
.searchbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.searchbox-container {
    flex: 1;
    min-width: 0;
}

/* Sort dropdown row - positioned below Last Updated line */
.sort-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-top: 4px;
    margin-bottom: 0;
}
.last-updated-text {
    font-size: 12px;
    color: #666;
    font-family: 'Source Sans Pro', Arial, sans-serif;
}

/* Sort widget dropdown (top right of main panel) */
.sort-label {
    font-size: 12px;
    color: #666;
    margin-right: 4px;
    font-family: 'Source Sans Pro', Arial, sans-serif;
}
.sort-select {
    padding: 3px 8px;
    background: rgba(0,0,0,0.25);
    color: #999;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Source Sans Pro', Arial, sans-serif;
    cursor: pointer;
    outline: none;
}
.sort-select:focus {
    border-color: #ff84d8;
}
.sort-select option {
    background: #2a2a2a;
    color: #e2e2e2;
}

/* HIDE redundant InstantSearch reset button */
.ais-SearchBox-reset { display: none !important; }

/* Active filters */
.active-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    padding-top: 8px;
}
.filter-tag {
    display: inline-flex;
    align-items: center;
    background: #475569;
    color: #f8fafc;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}
.filter-tag button {
    background: none;
    border: none;
    color: #cbd5e1;
    margin-left: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
}

/* Stats */
.stats-text {
    font-size: 14px;
    color: var(--text-light);
    padding-top: 4px;
}

/* ============ BOOK CARDS ============ */
.book-card {
    display: flex;
    background: #323232;
    padding: 24px;
    margin-bottom: 24px;
    border-radius: 7px;
    box-shadow: 0 2px 6px 0px rgba(0,0,0,0.3);
    gap: 24px;
    cursor: pointer;
    position: relative;
}
.book-card:hover { box-shadow: 0 4px 12px 0px rgba(0,0,0,0.4); }

/* Heart bookmark button */
.bookmark-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 2;
}
.bookmark-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}
.bookmark-btn svg {
    width: 24px;
    height: 24px;
    display: block;
}
.bookmark-btn.outline svg path { fill: none; stroke: #e2e2e2; stroke-width: 2; }
.bookmark-btn.filled svg path { fill: #cc0033; stroke: none; }
.bookmark-btn.pop { animation: heartPop 0.3s ease; }
@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Bookmark share icon (sidebar) - proper sizing */
.bookmark-share-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: 6px;
    opacity: 0.7;
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
}
.bookmark-share-btn:hover { opacity: 1; transform: scale(1.1); }
.bookmark-share-btn svg { width: 24px; height: 24px; display: block; fill: #ffddf2; }

/* Bookmark CSV download icon (sidebar) - stroke-based SVG needs explicit sizing */
.bookmark-csv-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
}
.bookmark-csv-btn:hover { opacity: 1; transform: scale(1.1); }
.bookmark-csv-btn svg { width: 24px; height: 24px; display: block; stroke: #ffddf2; fill: none; }

.copy-tooltip {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(34,34,34,0.92);
    color: #ffddf2;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    z-index: 2000;
    pointer-events: none;
}
.copy-tooltip.show { display: block; }

/* Bookmarked filter in sidebar */
#bookmarked-filter .filter-item {
    background-color: #161616 !important;
    color: #e2e2e2;
}
#bookmarked-filter .filter-item.selected {
    background-color: rgba(255,221,242,0.1) !important;
    border: 1px solid #ff84d8;
    color: #ffddf2;
    font-weight: 700;
}

/* "Bookmarked" tag badge on individual book cards */
.tag-bookmarked {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    background: #c02;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    z-index: 2;
}

/* Share button on book cards (positioned left of the heart) */
.share-btn {
    position: absolute;
    top: 10px;
    right: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 2;
}
.book-card:hover .share-btn { opacity: 0.8; }
.share-btn:hover { opacity: 1 !important; transform: scale(1.1); }
.share-btn svg { width: 20px; height: 20px; fill: #e2e2e2; stroke: none; }
.share-btn .share-copied { opacity: 1 !important; }
.share-btn.share-copied::after {
    content: 'Copied!';
    position: absolute;
    bottom: -24px;
    right: 0;
    background: rgba(34,34,34,0.9);
    color: #ffddf2;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Book cover images */
.book-cover {
    width: 100px;
    height: 150px;
    min-width: 100px;
    object-fit: cover;
    border-radius: 6px;
    background: #f1f5f9;
    border: 1px solid #ccc;
}
.book-cover.no-cover {
    object-fit: contain;
    background: #e2e2e2;
}

.card-body { flex: 1; }

.card-title {
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.3;
    color: #e2e2e2 !important;
}

.author-link {
    color: #ff84d8;
    text-decoration: none;
    font-weight: 500;
}
.author-link:hover { color: #a500a2; text-decoration: underline; }

.card-meta {
    font-size: 14px;
    color: #64748b;
    margin-top: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.loc-pill {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    color: #475569;
}

.stars-row { margin-top: 6px; display: flex; align-items: center; gap: 2px; }
.star-filled { color: #ff84d8; }
.star-empty { color: #d6d0c0; }
.review-count { color: #a4a4a4; font-size: 0.85rem; margin-left: 2px; }

.price-text {
    color: #a500a2;
    font-weight: 700;
    font-size: 32px;
    margin-top: 8px;
}

/* Price row: flex container with price left, quarantine badge right */
.price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.badge-new {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 8px;
    background: #fef3c7;
    color: #92400e;
    vertical-align: middle;
}

.badge-audio {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 8px;
    background: #e0f2fe;
    color: #075985;
    vertical-align: middle;
}

/* Standalone house icon with tooltip - same visual height as badges */
.local-author-icon {
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
    cursor: default;
}
.local-author-icon svg {
    width: 14px;
    height: 14px;
}

/* Quarantine badge on cards: icon + text, sits in price row */
.quarantine-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
}
.quarantine-badge svg {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
}

/* Quarantine notice in detail modal */
.quarantine-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    font-weight: 600;
}
.quarantine-icon-inline svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.badge-format {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    background: #334155;
    color: #94a3b8;
    vertical-align: middle;
}

/* Author dropdown in main panel */
#author-menu { margin-top: 16px; }
.author-drop-link {
    display: block;
    padding: 8px 16px;
    color: #e2e2e2;
    cursor: pointer;
    background: rgba(0,0,0,0.25);
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 14px;
    text-decoration: none;
}
.author-drop-link:hover { color: #ffddf2; background: rgba(0,0,0,0.4); }

/* ============ MODAL ============ */
#detail-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255, 201, 235, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-inner {
    background: white;
    width: 90%;
    max-width: 800px;
    padding: 40px;
    border-radius: 7px;
    position: relative;
    max-height: 500px;
    overflow-y: auto;
    display: flex;
    gap: 32px;
}
.modal-close {
    position: absolute;
    top: 15px; right: 15px;
    border: none; background: none;
    font-size: 30px; cursor: pointer;
    color: #64748b;
}
.modal-close:hover { color: var(--accent-dark); }

/* ============ FOOTER ============ */
.site-footer {
    margin-top: 40px;
    border-top: 1px solid #d6d0c0;
    padding-top: 24px;
    padding-bottom: 32px;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}
.footer-inner { max-width: 1160px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }

/* ============ GLOBAL BULLET / LIST RESET ============ */
*, *::before, *::after { list-style: none !important; }
ul, ol { list-style-type: none !important; padding-left: 0 !important; margin: 0 !important; }
li { list-style-type: none !important; margin-left: 0 !important; padding-left: 0 !important; }

/* NUCLEAR RESET for InstantSearch backgrounds */
.ais-RefinementList-list,
.ais-Hits-list,
.ais-InfiniteHits-list,
.ais-CurrentRefinements-list,
.ais-Menu-menu,
.ais-SearchBox,
.ais-Stats,
.ais-ClearRefinements,
.ais-CurrentRefinements,
.ais-Hits,
#searchbox,
#active-filters,
#stats,
#author-menu,
#hits {
    background: #161616 !important;
    background-color: #161616 !important;
}

.ais-RefinementList-item,
.ais-Hits-item,
.ais-InfiniteHits-item,
.ais-Menu-search,
.ais-Menu-select,
select.ais-Menu-select,
.ais-SearchBox-input,
.ais-SearchBox-form,
.ais-SearchBox-submit,
.ais-SearchButton,
#store-selector .ais-RefinementList-list,
#section-list .ais-RefinementList-list,
#new-filter .ais-RefinementList-list {
    background: #161616 !important;
    background-color: #161616 !important;
}

/* Bookmarked filter item - must come after nuclear reset to override */
#bookmarked-filter > .filter-item,
#sidebar-bookmarked-tag {
    background-color: rgba(0,0,0,0.25) !important;
}
#bookmarked-filter > .filter-item.selected,
#sidebar-bookmarked-tag.selected {
    background-color: rgba(255,221,242,0.15) !important;
    border: 1px solid #ff84d8 !important;
}

/* Best Sellers filter item in sidebar */
#best-sellers-filter > .filter-item {
    background-color: rgba(0,0,0,0.25) !important;
}
#best-sellers-filter > .filter-item.selected {
    background-color: rgba(255,221,242,0.15) !important;
    border: 1px solid #ff84d8 !important;
}

/* Pagination - dark theme */
#pagination,
#pagination-top {
    display: flex;
    justify-content: center;
}
#pagination { margin-top: 32px; }
#pagination-top { margin-bottom: 20px; margin-top: 8px; }
.ais-Pagination-list {
    display: flex;
    gap: 4px;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 auto !important;
}
.ais-Pagination-link,
.ais-Pagination-item a,
.ais-Pagination-item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 6px;
    background: rgba(0,0,0,0.3) !important;
    color: #e2e2e2 !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
}
.ais-Pagination-item a:hover {
    background: rgba(255,221,242,0.15) !important;
    color: #ffddf2 !important;
}
.ais-Pagination-item--selected a {
    background-color: #ffddf2 !important;
    color: #231c21 !important;
    font-weight: 700 !important;
}
.ais-Pagination-item--disabled a,
.ais-Pagination-item--disabled span {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* Sidebar share wishlist button */
.bookmark-share-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--pink-bg);
    color: #231c21;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Source Sans Pro', Arial, sans-serif;
}
.bookmark-share-item:hover { background: #ffc9eb; }

/* Wishlist Overlay */
.wishlist-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
}
.wishlist-overlay.open { display: flex; }
.wishlist-overlay-inner {
    background: #323232;
    color: #e2e2e2;
    width: 90%;
    max-width: 460px;
    padding: 32px;
    border-radius: 10px;
    position: relative;
}
.wishlist-overlay-close {
    position: absolute;
    top: 8px; right: 12px;
    background: none;
    border: none;
    font-size: 28px;
    color: #e2e2e2;
    cursor: pointer;
}
.wishlist-overlay-close:hover { color: var(--accent); }
#wl-share-btn, .wl-share-btn {
    margin-top: 16px;
    padding: 10px 24px;
    background: var(--pink-bg);
    color: #231c21;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
}
#wl-share-btn:hover, .wl-share-btn:hover { background: #ffc9eb; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .page-body { flex-direction: column; padding: 16px; gap: 16px; }
    .sidebar { width: auto; min-width: auto; margin-bottom: 16px; }
    .book-card { padding: 16px; gap: 16px; }
    .modal-inner { flex-direction: column; padding: 24px; max-height: none; }
    .footer-inner { flex-direction: column; gap: 16px; }
    .nav-links a { padding: 16px 20px; font-size: 13px; }
}
/* ============ DATE BUTTON STACK (New Since) ============ */
#new-since-filter {
    position: relative;
    width: 100%;
}
#new-since-filter > .filter-item {
    width: 100%;
}

.ds-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
    border: none;
    border-radius: 4px;
    text-align: left;
    background: rgba(0,0,0,0.25);
    color: #e2e2e2;
}

.ds-btn:hover {
    background: rgba(0,0,0,0.4);
}

.ds-btn-active {
    border: 1px solid #ff84d8;
    color: #ffddf2;
    font-weight: 700;
    background: rgba(255,221,242,0.1);
}

.ds-label {
    flex: 1;
    text-align: left;
}

.ds-count {
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: #a4a4a4;
}

.ds-chevron {
    font-size: 10px;
    color: #999;
    margin-left: 4px;
}

/* Dropdown panel */
#ds-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 500;
    background: #323232;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    padding: 6px;
    margin-top: 2px;
}

.ds-option {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Source Sans Pro', Arial, sans-serif !important;
    border: none;
    border-radius: 4px;
    text-align: left;
    background: transparent;
    color: #e2e2e2;
}

.ds-option:hover {
    background: rgba(0,0,0,0.4);
}

.ds-option-active {
    color: #ffddf2;
    font-weight: 700;
    background: rgba(255,221,242,0.1);
}
