/* === SYSTEM FONT STACK === */
@font-face {
  font-family: system-ui;
  font-style: normal;
  font-weight: 400;
  src: local(".SFNSText"), local(".HelveticaNeueDeskInterface"),
       local(".LucidaGrandeUI"), local("Ubuntu"), local("Segoe UI"),
       local("Roboto"), local("Helvetica Neue"), local("Arial");
}

/* ─────────────────── ROOT THEME ─────────────────── */
:root {
  --bg1: #10252e;
  --bg2: #243b55;
  --bg3: #141e30;
  --card-bg: rgba(255, 255, 255, 0.08);
  --fg: #f1f1f1;
  --accent: #ffca28;
  --accent2: #18ffff;
  --radius-card: 16px;
  --radius-btn: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

body.light-mode {
  --bg1: #fdfbfb;
  --bg2: #ebedee;
  --bg3: #e3e4e8;
  --card-bg: rgba(0, 0, 0, 0.06);
  --fg: #222;
}

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

html,
body {
  overflow-x: hidden;
  font-family: system-ui, 'Poppins', sans-serif;
}

/* Sticky-footer layout */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(125deg, var(--bg1), var(--bg2), var(--bg3));
  color: var(--fg);
  scroll-behavior: smooth;
}

/* ─────────── NESTED “CARD ON CARD” ─────────── */
.inner-card {
  margin-top: 1.3rem;
  padding: 1.8rem 1.4rem;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

/* tidy spacing when inner card contains a grid */
.inner-card .book-grid {
  margin-top: 0.8rem;
}

/* make nested forms full-width inside */
.inner-card form,
.inner-card ul,
.inner-card textarea {
  width: 100%;
}

/* responsive tweak */
@media (max-width: 520px) {
  .inner-card {
    padding: 1.4rem 1.1rem;
  }
}

#footer {
  margin-top: auto;
}

/* ─────────────────── GLOBAL ELEMENTS ─────────────────── */
h1,
h2,
h3 {
  text-align: center;
  letter-spacing: 0.4px;
  font-weight: 600;
  margin: 0 0 0.7em;
}

section {
  padding: 4rem 6vw;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

.primary-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  border: 0;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: 0.25s;
  color: #000;
}

.primary-btn:hover,
.icon-btn:hover {
  filter: brightness(1.1);
}

.icon-btn {
  background: transparent;
  color: var(--fg);
  font-size: 1.4rem;
  padding: 0.5rem;
}

.trustpilot-btn {
  border-radius: 24px !important;
  background: #00b67a;
  color: #fff;
  padding: 0.5rem 1.4rem;
  display: inline-block;
  margin-top: 0.6rem;
}

/* ─────────────────── CARDS ─────────────────── */
.card-section {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  margin: 2rem 4vw;
  animation: fadeCard 0.5s ease 40ms both;
}

@keyframes fadeCard {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─────────────────── FORM CONTROLS ─────────────────── */
.form-control,
#search input,
#search select,
#request textarea,
#upload input,
#upload textarea,
#loginForm input {
  width: 100%;
  padding: 0.65rem;
  border: none;
  border-radius: var(--radius-btn);
  background: var(--card-bg);
  color: var(--fg);
  margin: 0.5rem 0;
}

#request textarea {
  resize: vertical;
  height: 90px;
}

/* Consistent font inside all textareas */
textarea {
  font-family: inherit;
}

/* ─────────────────── HEADER & NAV ─────────────────── */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 6vw;
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
}

#header img {
  height: 38px;
  object-fit: contain;
}

/* ─────────────────── NAV & DROPDOWN ─────────────────── */
#nav {
  position: sticky; /* container for absolute dropdown */
  top: 0;
  z-index: 1000; /* base stacking */
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 6vw;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
}

#navToggle {
  position: relative;
  z-index: 1100; /* above navList */
}

#marqueeContainer {
  position: relative;
  z-index: 1100; /* above navList */
}

/* Dropdown nav list */
#navList {
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: center; /* center links horizontally */
  padding: 0.75rem 1.5rem; /* comfortable padding */
  margin: 0;
  background: rgba(20, 30, 40, .8);
  backdrop-filter: blur(15px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  position: absolute;
  top: 100%; /* right below nav */
  left: 0;
  width: 100%; /* fill nav width */
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform-origin: top center;
  transform: translateY(-15px);
  transition: max-height 0.5s ease, opacity 0.4s ease 0.1s, transform 0.5s ease;
  z-index: 1050; /* below toggle & marquee */
}

/* Show dropdown when nav is open */
#nav.open #navList {
  max-height: 500px; /* enough height for links */
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Nav links styling */
#navList a {
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  color: var(--fg);
  text-align: center;
  width: 100%;
  display: block;
  font-weight: 600;
}

body.light-mode #navList a {
  color: #000;
}

#navList a:hover {
  border-color: var(--accent);
}

/* Remove pipe separators completely */
#navList li::after {
  content: none !important;
  position: static !important;
}

/* Hide nav list when hidden */
#navList.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

/* Ensure no horizontal overflow */
body,
html {
  overflow-x: visible !important;
}

/* ─────────────────── TOGGLE ─────────────────── */
#modeToggle {
  position: fixed;
  top: 82px;
  right: 1.2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  font-size: 1.35rem;
  box-shadow: var(--shadow);
  z-index: 1100;
  transition: 0.3s;
}

body.light-mode #modeToggle {
  background: rgba(0, 0, 0, 0.12);
  color: #333;
}

/* ===== BOOK GRID & CARDS ===== */
.book-grid, #bookGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0 0.5rem;
}

.book-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  transition: transform 0.25s ease;
  cursor: default;
  text-align: center;
  user-select: none;
}

.book-card:hover {
  transform: translateY(-6px);
}

.book-card img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  user-select: none;
}

.book-card .no-img-placeholder {
  width: 100%;
  height: 200px;
  background-color: #ddd;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  user-select: none;
}

.book-card .info h4 {
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}

.book-card .info span {
  color: #999;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
  user-select: none;
}

.book-card .btn-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: auto;
}

.book-card .primary-btn,
.book-card button.primary-btn {
  background: var(--accent);
  color: #000;
  border-radius: var(--radius-btn);
  padding: 0.4rem 1rem;
  font-weight: 600;
  transition: filter 0.25s ease;
}

.book-card .primary-btn:hover,
.book-card button.primary-btn:hover {
  filter: brightness(1.1);
}

/* ===== CART MODAL TABLE ===== */
#cartTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 1rem;
  color: var(--fg);
  user-select: none;
}

#cartTable tr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255 255 255 / 0.15);
}

#cartTable td {
  padding: 0.3rem 0.6rem;
  display: flex;
  align-items: center;
}

/* Left align Buy & Trash buttons: 1st and 2nd cells */
#cartTable td:nth-child(1), /* Title */
#cartTable td:nth-child(2), /* Buy */
#cartTable td:nth-child(3)  /* Trash */ {
  flex: 1;
}

#cartTable td:nth-child(1) {
  justify-content: flex-end;
  font-weight: 600;
  white-space: nowrap;
  color: var(--fg);
  padding-right: 1rem;
}

#cartTable td:nth-child(2),
#cartTable td:nth-child(3) {
  justify-content: flex-start;
}

/* Buttons styling */
#cartTable a.primary-btn,
#cartTable button.icon-btn {
  border-radius: var(--radius-btn);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-weight: 600;
  transition: filter 0.2s ease;
}

#cartTable a.primary-btn {
  background-color: var(--accent);
  color: #000;
  text-decoration: none;
}

#cartTable a.primary-btn:hover {
  filter: brightness(1.1);
}

#cartTable button.icon-btn {
  background: transparent;
  color: var(--accent);
  font-size: 1.3rem;
  border: none;
}

#cartTable button.icon-btn:hover {
  filter: brightness(0.8);
}

/* Card styling for any books-section tables */
#books table {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#books th,
#books td {
  padding: 0.75rem;
  text-align: left;
}

#books tbody tr:not(:last-child) td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* ─────────────────── FLOATING CART ─────────────────── */
.floating-cart {
  position: fixed;
  bottom: 1.3rem;
  right: 1.3rem;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  box-shadow: var(--shadow);
  transition: 0.25s;
  z-index: 1150;
}

.floating-cart span {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #e53935;
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  padding: 2px 6px;
}

.floating-cart.hidden {
  display: none;
}

/* ─────────────────── MODALS ─────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  padding: 2rem;
  border-radius: var(--radius-card);
  width: min(92vw, 460px);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  animation: pop 0.35s ease;
}

.modal-content .close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 1.5rem
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ───── EDIT-REVIEW MODAL ───── */
#editModal .modal-content {
  width: min(92vw, 460px);
  max-height: 80vh;
  padding: 2rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

#editModal h3 {
  margin: 0;
  font-size: 1.35rem;
  text-align: center;
}

#editModal .stars {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  font-size: 1.5rem;
  flex-direction: row-reverse;
  direction: rtl; /* required for reverse logic */
}

#editModal .stars input {
  display: none;
}

#editModal .stars span {
  cursor: pointer;
  transition: 0.25s;
  color: var(--accent);
}

#editModal .stars label {
  cursor: pointer;
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.25);
  transition: color 0.2s;
}

body.light-mode #editModal .stars label {
  color: rgba(0, 0, 0, 0.25);
}

/* Show selected stars */
#editModal .stars input:checked ~ label {
  color: var(--accent);
}

/* Hover preview */
#editModal .stars label:hover,
#editModal .stars label:hover ~ label {
  color: var(--accent);
}

#editModal textarea {
  width: 100%;
  height: 90px;
  padding: 0.75rem;
  resize: vertical;
  border-radius: var(--radius-btn);
  background: var(--card-bg);
  color: var(--fg);
  border: none;
  font-family: inherit;
}

#editModal .btn-row {
  display: flex;
  justify-content: center;
}

#editModal .btn-row .primary-btn {
  padding: 0.65rem 2.2rem;
}

/* --- Marquee styling --- */
#marqueeContainer {
  overflow: hidden;
  white-space: nowrap;
  max-width: 250px;
  margin-left: 1rem;
  align-self: center; /* vertical center with toggle */
  user-select: none;
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent);
  position: relative;
  height: 1.4rem;
}

#marqueeText {
  display: inline-block;
  padding-left: 100%; /* start off-screen right */
  animation: marqueeAnim 10s linear infinite;
}

@keyframes marqueeAnim {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Ensure no horizontal overflow */
body,
html {
  overflow-x: visible !important;
}

/* Responsive tweaks */
@media (max-width: 520px) {
  #header img {
    height: 32px;
  }
  #modeToggle {
    top: 76px;
  }
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* ─────────── FOOTER ─────────── */
#footer {
  margin-top: auto;
  padding: 3rem 6vw 2rem;
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  box-shadow: var(--shadow);
}

#footer p {
  margin-bottom: 10px;
}

#footer a {
  color: var(--fg);
  text-decoration: none;
  transition: .25s;
}

body.light-mode #footer a {
  color: #000;
}

#footer a:hover {
  color: var(--accent2);
}

#footer ul {
  list-style: none;
  display: flex;
  gap: 1.2rem;
}

#footer ul a {
  font-size: 1.6rem;
}

#footer .follow {
  font-weight: 600;
  letter-spacing: .4px;
}

.no-img-placeholder {
  width: 150px;      /* or your intended width */
  height: 200px;     /* or your intended height */
  background-color: #ddd;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
  text-align: center;
  padding: 10px;
  border-radius: 4px;
  user-select: none;
  /* optional */
  border: 1px solid #aaa;
}

#reviewCarousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory; /* optional, for snapping */
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
  gap: 1rem; /* space between cards */
  padding: 1rem 0;
  scrollbar-width: thin; /* for Firefox */
}

.review-card {
  flex: 0 0 250px; /* fixed width so they don't shrink */
  scroll-snap-align: center;
  background: #aaa;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
  padding: 1rem;
  box-sizing: border-box;
  user-select: none;
}

.review-card.center {
  transform: scale(1.05);
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Progress bar fixed at top of page */
#uploadProgress {
  height: 6px;
  width: 0;                /* Start with zero width */
  background: #4caf50;
  box-shadow: 0 0 10px var(--accent);
  transition: width 0.3s ease, opacity 0.3s ease;
  margin: 10px 0;
  opacity: 0;
  border-radius: 4px;   
  animation: glow 1.5s ease-in-out infinite;/* Hidden by default */
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 10px var(--accent);
  }
  50% {
    box-shadow: 0 0 20px var(--accent);
  }
}