/*
 * Portions of this stylesheet are inspired by or adapted from
 * "Pro Sidebar Template" by Mohamed Azouaoui (MIT License).
 * https://github.com/azouaoui-med/pro-sidebar-template
 * Copyright (c) 2017 Mohamed AZOUAOUI
 */
/* Theme Variables */
/* Color palette (provided by user):
   F7F1DE, DEDED1, FF9D00, FCF9EA, 80A1BA, E6D8C3, FAF8F1, 3C467B
*/
/* Design tokens: spacing, radii, typography */
:root {
  --space-1: 6px;
  --space-2: 12px;
  --space-3: 20px;
  --space-4: 28px;
  --space-5: 40px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-md: 16px;
  --text-lg: 20px;

  /* Light theme (default) */
  --bg-main: #FCF9EA;    /* very light warm */
  --bg-alt: #F7F1DE;     /* warm alt */
  --bg-hero: linear-gradient(135deg, #3C467B, #80A1BA);
  --text-main: #3C467B;  /* deep blue */
  --text-light: #FAF8F1; /* near-white */
  --text-muted: #6b6b6b;
  --accent: #FF9D00;     /* bright orange */
  --accent: #FF7A00;     /* bright orange (tweaked for better contrast) */
  --accent-hover: #E6A06A; /* soft tan hover */
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --card-shadow: rgba(60,70,123,0.06);
  --panel-bg: #ffffff; /* cards / panels */
  /* Link colors */
  --link: #3C467B;
  --link-hover: #FF7A00;
  /* Pro-sidebar inspired palette for public sidebar (light) */
  --ps-bg: #ffffff;
  --ps-text: #334155;
  --ps-muted: #94a3b8;
  --ps-active-start: #60a5fa;
  --ps-active-end: #22d3ee;
  --ps-hover: #f3f4f6;
}

/* If the user prefers dark, flip the palette via media query. This gives a sensible default even when JS hasn't run. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #111827;
    --bg-alt: #1f2937;
    --bg-hero: linear-gradient(135deg, #111827, #3C467B);
    --text-main: #FCF9EA;  /* light text */
    --text-light: #FAF8F1;
    --text-muted: #DEDED1;
    --accent: #FF9D00;
      --accent: #FF7A00;
      --accent-hover: #E6A06A;
      --danger: #dc2626;
      --danger-hover: #b91c1c;
    --card-shadow: rgba(0,0,0,0.25);
    /* Slightly lighter than page bg so cards/panels lift on dark */
    --panel-bg: #1f2937;
    /* Link colors on dark */
    --link: #fbbf24; /* amber-400 */
    --link-hover: #fde68a; /* amber-200 */
    /* Pro-sidebar inspired palette for public sidebar (dark) */
    --ps-bg: #0b1b2a;
    --ps-text: #c7d2da;
    --ps-muted: #8aa1b2;
    --ps-active-start: #3b82f6;
    --ps-active-end: #1d4ed8;
    --ps-hover: rgba(255,255,255,0.06);
  }
}

/* Explicit class hooks (used by site.js toggle). These intentionally repeat the token names
   so that toggling a class will deterministically set the variables even if :root
   was modified by the media query above. */
/* Apply theme variables when the class is on body OR html to avoid side gutters using a different background */
body.light-mode, html.light-mode {
  --bg-main: #FCF9EA;
  --bg-alt: #F7F1DE;
  --bg-hero: linear-gradient(135deg, #3C467B, #80A1BA);
  --text-main: #3C467B;
  --text-light: #FAF8F1;
  --text-muted: #6b6b6b;
    --accent: #FF7A00;
    --accent-hover: #E6A06A;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
  --card-shadow: rgba(60,70,123,0.06);
  --panel-bg: #ffffff;
  --link: #3C467B;
  --link-hover: #FF7A00;
}

body.dark-mode, html.dark-mode {
  --bg-main: #111827;
  --bg-alt: #1f2937;
  --bg-hero: linear-gradient(135deg, #111827, #3C467B);
  --text-main: #FCF9EA;
  --text-light: #FAF8F1;
  --text-muted: #DEDED1;
    --accent: #FF7A00;
    --accent-hover: #E6A06A;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
  --card-shadow: rgba(0,0,0,0.3);
  --panel-bg: #1f2937;
  --link: #fbbf24;
  --link-hover: #fde68a;
}

/* General Reset */
html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: 'Open Sans', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  transition: background 0.4s ease, color 0.4s ease;
}

/* Full-width responsive layout */
@media (min-width: 1024px) {
  body { max-width: none; margin-left: 0; margin-right: 0; }
}
/* Allow responsive to smallest screens */
html, body { min-width: 0; }

/* Main content takes available space */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  color: var(--text-main);
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-main);
  color: var(--text-main);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.4s ease, color 0.4s ease;
}

/* Make navbar positioning predictable so header controls can be absolutely positioned inside it */
.navbar { position: relative; overflow: visible; }

.logo {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.logo img {
  height: 48px;
  margin-right: var(--space-2);
}

.navbar nav a {
  margin-left: var(--space-2);
  text-decoration: none;
  color: var(--text-main);
  transition: color 0.3s;
  font-size: var(--text-md);
}

/* Theme toggle button in navbar */
#theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--text-main);
}
#theme-toggle:hover, #theme-toggle:focus { background: rgba(0,0,0,0.04); outline: none; }
#theme-icon { font-size: 1.25rem; line-height: 1; }

.navbar nav a:hover,
.navbar nav a.active {
  color: var(--accent);
}

.search-bar input {
  padding: var(--space-1);
  width: 260px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-sm);
}

.search-bar button {
  padding: 8px 12px;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-main);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Layout */
.container {
  display: flex;
  padding: var(--space-3);
  gap: 24px;
}

/* Content wrapper: keeps readable line length while background stays full-bleed */
.content-wrap { max-width: 1440px; margin: 0 auto; width: 100%; }

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.catalog-header h2 {
  margin: 0 0 8px;
}

.catalog-sub {
  margin: 0 0 18px;
  color: var(--text-muted);
}

/* Book Grid */
.main-area .book-grid,
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  flex: 1;
  padding: 0 20px;
}

.book-card {
  background: var(--panel-bg);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 6px var(--card-shadow);
  text-align: center;
  position: relative;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.book-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.book-card h4 {
  margin: 10px 0 5px;
  font-size: 16px;
}

.book-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.book-card button {
  margin-top: var(--space-2);
  padding: 8px 12px;
  background: var(--accent);
  color: var(--text-main);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
}

.book-card button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Stock Labels */
.stock {
  display: block;
  margin-top: 8px;
  font-weight: bold;
}

.in-stock {
  color: green;
}

.out-of-stock, .out-stock {
  color: red;
}

/* Backwards-compatible class name and improved stock styling */
.out-of-stock { color: red; }
.stock { font-size: 13px; }

/* Search form inside .search-bar (we changed HTML to use a form) */
.search-bar form { display:flex; gap:8px; align-items:center; }
.search-bar form input { width: 220px; padding:8px; border-radius:4px; }

/* When sidebar is active, push main content to the right (desktop/tablet) */
.sidebar.active + .main-area { margin-left: 250px; transition: margin-left 0.3s ease; }

/* Accessible focus styles */
.book-card:focus {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
.book-card:focus-visible { outline-color: var(--accent); }

button:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Ensure carousel nav is keyboard accessible */
.carousel-nav:focus { outline: 2px solid var(--accent); }

/* Small screens: sidebar overlays content so don't add margin-left
   (keeps overlay behaviour intact) */
@media (max-width: 768px) {
  .sidebar.active + .main-area { margin-left: 0; }
}

.carousel-wrapper {
  position: relative;
  overflow: hidden;
  max-width: 100%;
  margin: auto;
}

.carousel-track {
  display: flex;
  transition: transform 0.5s ease;
}

/* Ensure carousel shows one card at a time: scope to carousel track */
.carousel-track .book-card {
  flex: 0 0 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 1rem;
  text-align: center;
}

/* Multi-card per view on wider screens */
@media (min-width: 640px) {
  .carousel-track .book-card { flex: 0 0 50%; max-width: 50%; }
}
@media (min-width: 900px) {
  .carousel-track .book-card { flex: 0 0 33.3333%; max-width: 33.3333%; }
}
@media (min-width: 1200px) {
  .carousel-track .book-card { flex: 0 0 25%; max-width: 25%; }
}

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: #333;
  color: white;
  border: none;
  padding: 1rem;
  cursor: pointer;
  z-index: 1;
}

.carousel-nav.prev { left: 0; }
.carousel-nav.next { right: 0; }

/* Visual state when navigation is disabled (at ends) */
.carousel-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


/* Hero Section */
.hero {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  background: var(--bg-hero);
  color: var(--text-light);
  transition: background 0.4s ease, color 0.4s ease;
}

.hero h1 {
  font-size: 2.5em;
  margin-bottom: 15px;
}

.hero p {
  font-size: 18px;
  margin-bottom: 20px;
}

.btn-primary {
  display: inline-block;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--text-main);
  text-decoration: none;
  font-weight: bold;
  border-radius: 4px;
  transition: background 0.3s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* Secondary button */
.btn-secondary {
  display:inline-block;
  padding:10px 20px;
  background: transparent;
  color: var(--text-main);
  text-decoration:none;
  font-weight:700;
  border-radius:6px;
  border:1px solid rgba(0,0,0,0.12);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.btn-secondary:hover{ background: rgba(0,0,0,0.06); }
html.dark-mode .btn-secondary, body.dark-mode .btn-secondary{ border-color: rgba(255,255,255,0.15); }
html.dark-mode .btn-secondary:hover, body.dark-mode .btn-secondary:hover{ background: rgba(255,255,255,0.06); }

/* View Book — hero layout inspired by streaming detail pages */
.book-hero{ background: linear-gradient(135deg, rgba(60,70,123,.18), rgba(128,161,186,.08)); padding: 28px 0; }
.book-hero__inner{ display:grid; grid-template-columns: 280px 1fr; gap: 40px; align-items: flex-start; }
@media (max-width: 920px){ .book-hero__inner{ grid-template-columns: 240px 1fr; gap:24px; } }
@media (max-width: 780px){ .book-hero__inner{ grid-template-columns: 1fr; } }
.book-hero__cover{ width:280px; height:420px; border-radius: 12px; overflow:hidden; box-shadow: 0 10px 28px rgba(0,0,0,.22); background:#0d1324; position:relative; }
.book-hero__cover img{ width:100%; height:100%; object-fit:cover; display:block; }
.book-hero__info{ padding-top:4px; }
.book-hero__title{ font-size: 2.15rem; line-height:1.25; margin:0 0 8px; }
.book-hero__meta{ display:flex; align-items:center; gap:14px; color: var(--text-muted); font-size: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.book-hero__tags{ display:flex; flex-wrap: wrap; gap:8px; margin: 8px 0 14px; }
.tag{ display:inline-flex; align-items:center; padding:4px 10px; font-size:12px; border-radius:999px; background: var(--panel-bg); border:1px solid rgba(0,0,0,0.08); color: var(--text-main); }
html.dark-mode .tag, body.dark-mode .tag{ border-color: rgba(255,255,255,0.12); }
.book-hero__actions{ display:flex; gap:12px; margin-top: 12px; flex-wrap: wrap; }
.book-hero__desc{ margin-top: 12px; color: var(--text-main); line-height:1.6; }

/* Simple rating row */
.rating{ display:flex; align-items:center; gap:8px; }
.rating .star{ color:#fbbf24; }

/* Featured / Hot Books (alias: .hot) */
.featured, .hot {
  padding: 40px 20px;
  text-align: center;
}

.featured h2, .hot h2 {
  margin-bottom: 20px;
}

.featured .book-grid, .hot .book-grid {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* Why Visit Section */
.why-visit {
  padding: 40px 20px;
  background: var(--bg-alt);
  text-align: center;
  transition: background 0.4s ease;
}

/* Recommended Section */
.recommended { padding: 32px 20px; }
.recommended h2 { margin-bottom: 16px; }
.recommended .book-grid { gap: 24px; }

.why-cards {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.why-card {
  background: var(--panel-bg);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 6px var(--card-shadow);
  width: 270px;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  background: var(--panel-bg);
  margin: 10% auto;
  padding: 20px;
  width: 400px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 6px var(--card-shadow);
}

.modal img {
  max-width: 150px;
  margin-bottom: 15px;
}

.close {
  float: right;
  font-size: 22px;
  cursor: pointer;
}

/* Footer */
.footer {
  background: var(--bg-alt);
  color: var(--text-main);
  margin-top: auto;
  padding: 20px 28px;
  transition: background 0.4s ease, color 0.4s ease;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* Fixed full-width footer */
.footer-fixed {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.06);
}

body.has-fixed-footer main { padding-bottom: 110px; } /* reserve space so content not hidden */

.footer-content {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.footer-left .brand { font-weight: 700; margin: 0 0 4px; }
.footer-left .meta { margin: 0; font-size: 13px; color: var(--text-muted); }

.footer-right .admin-link { margin: 0; font-size: 14px; }
.footer-right .admin-link a { color: var(--link); text-decoration: none; font-weight: 600; }
.footer-right .admin-link a:hover { text-decoration: underline; }

.footer p {
  margin: 6px 0;
  color: var(--text-main);
}

.footer a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover {
  text-decoration: underline;
}

.footer .contact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer .meta {
  font-size: 14px;
  color: var(--text-muted);
}

.footer .admin-link a {
  background: rgba(241,196,15,0.08);
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--accent);
}

.footer .social { margin-top: 8px }
.footer .social a { margin-right: 8px; color: var(--text-main); opacity: 0.95 }
.footer .social a:hover { opacity: 1 }

/* Footer small screens: stack */
@media (max-width: 800px) {
  .footer-content { justify-content: center; text-align: center; }
  .footer-fixed { padding: 16px 18px; }
  body.has-fixed-footer main { padding-bottom: 140px; }
}

/* About / Map / Contact styling */
.about-us {
  padding: 36px 20px;
  max-width: 1100px;
  margin: 0 auto 12px;
  text-align: left;
  color: var(--text-main);
}
.about-us p { line-height: 1.7; margin: 0 0 12px; }

.map-wrapper {
  max-width: 900px;
  margin: 12px auto 18px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 18px var(--card-shadow);
  border: 1px solid rgba(0,0,0,0.06);
  background: var(--panel-bg);
}
.map-wrapper p { margin: 10px; color: var(--text-muted); }
.map-wrapper iframe { display: block; width: 100%; height: 360px; border: 0; }

.contact-info {
  padding: 28px 20px;
  max-width: 1100px;
  margin: 0 auto 36px;
  background: transparent;
}
.contact-info h2 { margin-bottom: 12px; }
.contact-info ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.contact-info li {
  background: var(--panel-bg);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 4px var(--card-shadow);
}
.contact-info a { color: var(--link); text-decoration: none; font-weight: 600; }
.contact-info a:hover { color: var(--link-hover); text-decoration: underline; }

/* Allow flex children to shrink so long links (emails) wrap inside their card on small screens */
.contact-info li { min-width: 0; }
.contact-info li a { display: inline-block; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }

/* On very small screens stack label and link for readability */
@media (max-width:420px) {
  .contact-info li { flex-direction: column; align-items: flex-start; }
}

/* badge on featured / book cards */
.book-card { position: relative; }
.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent);
  color: var(--text-main);
  padding: 6px 8px;
  font-weight: 700;
  border-radius: 8px;
  font-size: 12px;
}

/* Micro-interactions and accessibility helpers */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden; clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

.social { display:flex; align-items:center; gap:10px; }
.social-label { margin-right:6px; color: var(--text-muted); font-size: var(--text-sm); }
.social-link { display:inline-flex; align-items:center; justify-content:center; color: var(--text-main); transition: transform 180ms ease, color 180ms ease, opacity 180ms ease; }
.social-link svg { display:block; width:18px; height:18px; }
.social-link:hover, .social-link:focus { transform: translateY(-3px); color: var(--accent); opacity: 1; }
.social-link:focus { outline: 3px solid var(--accent); outline-offset: 4px; }

/* Card lift on hover/focus */
.book-card { transition: transform 220ms cubic-bezier(.2,.9,.2,1), box-shadow 220ms cubic-bezier(.2,.9,.2,1); }
.book-card:hover, .book-card:focus-within { transform: translateY(-8px); box-shadow: 0 18px 40px rgba(60,70,123,0.12); }
.book-card h4 { transition: color 160ms ease; }
.book-card:hover h4 { color: var(--accent); }

/* Button micro-interactions */
.book-card button { transition: transform 160ms ease, filter 160ms ease; }
.book-card button:hover:not(:disabled), .book-card button:focus { transform: translateY(-2px); filter: brightness(1.03); }
.book-card button:active { transform: translateY(0); }

/* Badge subtle movement */
.badge { transition: transform 220ms ease, box-shadow 220ms ease; }
.book-card:hover .badge { transform: translateY(-6px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }

/* View Book (single detail page) */
.book-detail { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .book-detail { grid-template-columns: 1fr; } }
.book-detail .cover-col img { width: 100%; height: auto; box-shadow: 0 2px 6px var(--card-shadow); border-radius: 4px; }
.book-detail .info-col h1 { margin-top: 0; }
.book-detail .info-col .authors { font-size: 1.05rem; margin: 4px 0 8px; }
.book-detail .description { margin-top: 12px; line-height: 1.5; }
.page-narrow { padding: 18px 16px; max-width: 960px; margin: 0 auto; }
.related-section { margin-top: 28px; }
.related-section h2 { margin: 18px 0; font-size: 1.2rem; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.related-grid .book-card { padding: 12px; }
.category-chips { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0 4px; }
.chip { background: var(--panel-bg); border:1px solid rgba(0,0,0,0.08); padding:4px 10px; border-radius:16px; font-size:12px; line-height:1; text-decoration:none; color: var(--text-main); box-shadow:0 1px 4px var(--card-shadow); transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.chip:hover, .chip:focus { background: var(--accent); color: var(--text-main); box-shadow:0 2px 8px rgba(0,0,0,0.12); outline:none; }
.chip:focus { outline:2px solid var(--accent); outline-offset:2px; }
.alert { padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; }
.alert-error { background: #ffe5e5; color: #8a1c1c; border: 1px solid #f5b4b4; }
.btn-link { display: inline-block; margin-top: 8px; font-size: 13px; text-decoration: none; color: var(--accent); }
.btn-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .map-wrapper iframe { height: 220px; }
  .navbar nav a { font-size: 18px; }
}

/* (public fixed sidebar removed - filters now inline) */
html.dark-mode body.home-has-fixed-sidebar #sidebarFilters.collapsed {
  background: linear-gradient(180deg, #1f2937, #111827);
  box-shadow: inset -4px 0 14px rgba(0,0,0,0.35);
}
.filters-collapse {
  position: absolute;
  top: 20px;
  right: 8px;
  width: 25px;
  height: 32px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--text-main);
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  transition: background 160ms ease, transform 160ms ease;
}
.filters-collapse:hover, .filters-collapse:focus { background: var(--accent-hover); transform: translateY(-2px); }
.filters-collapse:focus { outline: 3px solid var(--accent); outline-offset: 4px; }
/* Tooltip styling for collapse button */
.filters-collapse[data-tooltip] {
  position: relative;
}
.filters-collapse[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translate(-50%, -100%);
  background: var(--text-main);
  color: var(--bg-main);
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.filters-collapse:hover::after, .filters-collapse:focus::after {
  opacity: 1;
  transform: translate(-50%, -110%);
}
/* Collapsed state changes tooltip text via JS; fallback if JS fails */
body.catalog-has-fixed-sidebar #sidebarFilters.collapsed .filters-collapse[data-tooltip]::after {
  content: 'Expand filters';
}
@media (max-width: 960px) {
  body.catalog-has-fixed-sidebar,
  body.home-has-fixed-sidebar { --public-sidebar-width: 220px; }
  body.catalog-has-fixed-sidebar #sidebarFilters.collapsed,
  body.home-has-fixed-sidebar #sidebarFilters.collapsed { width: 52px; }
  body.catalog-has-fixed-sidebar #sidebarFilters.collapsed ~ .main-area,
  body.home-has-fixed-sidebar #sidebarFilters.collapsed ~ main { margin-left: 52px; }
}
/* On very small screens, keep the sidebar fixed but allow full-width expansion if desired in the future.
   We intentionally avoid overlay/floating behavior per request. */
@media (max-width: 740px) {
  body.catalog-has-fixed-sidebar,
  body.home-has-fixed-sidebar { --public-sidebar-width: 200px; }
  body.catalog-has-fixed-sidebar .main-area,
  body.home-has-fixed-sidebar main { padding-left: 16px; padding-right: 16px; }
}

/* Extra-narrow screens: shrink sidebar to 180px below 500px */
@media (max-width: 500px) {
  body.catalog-has-fixed-sidebar,
  body.home-has-fixed-sidebar { --public-sidebar-width: 170px; }
}
#sidebarFilters .sidebar-resizer { position:absolute; top:0; right:-4px; width:8px; height:100%; cursor:col-resize; background:transparent; transition:width 160ms ease; z-index:5; }
#sidebarFilters .sidebar-resizer::after{ content:''; position:absolute; top:0; bottom:0; left:3px; width:2px; background:rgba(0,0,0,0.06); transition:background 160ms ease; }
#sidebarFilters .sidebar-resizer:hover{ width:12px; }
#sidebarFilters .sidebar-resizer:hover::after{ left:5px; }
html.dark-mode #sidebarFilters .sidebar-resizer::after, body.dark-mode #sidebarFilters .sidebar-resizer::after{ background:rgba(255,255,255,0.12); }
body.catalog-has-fixed-sidebar #sidebarFilters.collapsed .sidebar-resizer, body.home-has-fixed-sidebar #sidebarFilters.collapsed .sidebar-resizer{ display:none; }
#sidebarFilters .filters-actions { margin-top:auto; display:flex; gap:8px; padding-top:12px; }
#sidebarFilters .filters-actions .btn { flex:1; }
/* Collapsed rail icon strip */
.collapsed-rail { display:none; position:absolute; top:84px; left:0; width:60px; padding:8px 4px; display:flex; flex-direction:column; gap:10px; }
body.catalog-has-fixed-sidebar #sidebarFilters.collapsed .collapsed-rail,
body.home-has-fixed-sidebar #sidebarFilters.collapsed .collapsed-rail { display:flex; }
.rail-btn { background: var(--accent); border:none; color: var(--text-main); height:42px; border-radius:12px; cursor:pointer; font-weight:700; font-size:14px; display:flex; align-items:center; justify-content:center; box-shadow:0 4px 12px rgba(0,0,0,0.12); transition: background .2s ease, transform .2s ease; }
.rail-btn:hover,.rail-btn:focus { background: var(--accent-hover); transform:translateY(-2px); }
.rail-btn:focus { outline:3px solid var(--accent); outline-offset:3px; }
html.dark-mode .rail-btn, body.dark-mode .rail-btn { color: var(--text-light); }
/* Custom scrollbar styling */
#sidebarFilters::-webkit-scrollbar, .pro-sidebar::-webkit-scrollbar { width:8px; }
#sidebarFilters::-webkit-scrollbar-track, .pro-sidebar::-webkit-scrollbar-track { background:transparent; }
#sidebarFilters::-webkit-scrollbar-thumb, .pro-sidebar::-webkit-scrollbar-thumb { background:rgba(0,0,0,0.18); border-radius:4px; }
html.dark-mode #sidebarFilters::-webkit-scrollbar-thumb, html.dark-mode .pro-sidebar::-webkit-scrollbar-thumb, body.dark-mode #sidebarFilters::-webkit-scrollbar-thumb, body.dark-mode .pro-sidebar::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.25); }
#sidebarFilters::-webkit-scrollbar-thumb:hover, .pro-sidebar::-webkit-scrollbar-thumb:hover { background:rgba(0,0,0,0.28); }
html.dark-mode #sidebarFilters::-webkit-scrollbar-thumb:hover, html.dark-mode .pro-sidebar::-webkit-scrollbar-thumb:hover { background:rgba(255,255,255,0.42); }
/* Heading subtle fade when sidebar collapses */
body.catalog-has-fixed-sidebar #sidebarFilters.collapsed h3, body.home-has-fixed-sidebar #sidebarFilters.collapsed h3 { opacity:0; transition:opacity .15s ease; }
body.catalog-has-fixed-sidebar #sidebarFilters:not(.collapsed) h3, body.home-has-fixed-sidebar #sidebarFilters:not(.collapsed) h3 { opacity:1; transition:opacity .25s ease .05s; }

/* Public sidebar hidden state (no overlay) */
body.public-sidebar-hidden.catalog-has-fixed-sidebar #sidebarFilters,
body.public-sidebar-hidden.home-has-fixed-sidebar #sidebarFilters {
  width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}
body.public-sidebar-hidden.catalog-has-fixed-sidebar .main-area,
body.public-sidebar-hidden.home-has-fixed-sidebar main { margin-left: 0 !important; }
body.public-sidebar-hidden #sidebarFilters .sidebar-inner { display: none; }
body.public-sidebar-hidden #sidebarFilters .filters-collapse { display: none; }
/* Hidden mode deprecated: ensure layout remains stable if class lingers */
body.public-sidebar-hidden #sidebarFilters { width:300px !important; padding:84px 16px 20px !important; border-right:1px solid rgba(0,0,0,0.06) !important; }
body.public-sidebar-hidden.catalog-has-fixed-sidebar .main-area,
body.public-sidebar-hidden.home-has-fixed-sidebar main { margin-left:300px !important; }

/* Pro-sidebar-esque header styling for Filters block */
#sidebarFilters .filters-sticky-header {
  position: sticky;
  top: 0;
  background: var(--ps-bg);
  padding: 8px 0 10px;
  z-index: 2;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
html.dark-mode #sidebarFilters .filters-sticky-header, body.dark-mode #sidebarFilters .filters-sticky-header {
  border-bottom-color: #334155;
}
#sidebarFilters .filters-sticky-header h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ps-muted);
}

/* Base button styling for public pages (used by Filters Apply/Reset) */
.btn { display:inline-block; padding:8px 12px; border-radius:8px; border:1px solid transparent; background: var(--accent); color: var(--text-main); font-weight:700; cursor:pointer; text-decoration:none; transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease; }
.btn:hover, .btn:focus { background: var(--accent-hover); outline: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
/* Make Reset look like a ghost button without changing markup */
#resetFilters.btn { background: transparent; border-color: rgba(0,0,0,0.12); color: var(--text-main); }
#resetFilters.btn:hover, #resetFilters.btn:focus { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.18); }
html.dark-mode #resetFilters.btn, body.dark-mode #resetFilters.btn { border-color: #334155; color: var(--text-light); }
html.dark-mode #resetFilters.btn:hover, body.dark-mode #resetFilters.btn:hover { background: rgba(255,255,255,0.06); border-color: #475569; }



