:root {
  --card-bg-light: #ffffff;
  --card-bg-dark: #222222;
  --text-color-light: #2c3e50;
  --text-color-dark: #ecf0f1;
  --primary-color: #0d6efd;
  --secondary-text-light: #6c757d;
  --secondary-text-dark: #adb5bd;
  --card-border-light: #f0f0f0;
  --card-border-dark: #333333;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 12px 30px rgba(0, 0, 0, 0.12);
}

body.dark-mode {
  --card-bg: var(--card-bg-dark);
  --text-color: var(--text-color-dark);
  --secondary-text: var(--secondary-text-dark);
  --card-border: var(--card-border-dark);
  --bg-body: #121212;
}

body.light-mode {
  --card-bg: var(--card-bg-light);
  --text-color: var(--text-color-light);
  --secondary-text: var(--secondary-text-light);
  --card-border: var(--card-border-light);
  --bg-body: #f8f9fa;
}

/* Redeem Page Specific Styles */
.redeem-section {
  padding: 50px 0;
  /* Ensure background contrast if page bg is white */
  background-color: transparent;
  min-height: 60vh;
}

/* Modern Card Styling */
.book-card {
  background-color: var(--card-bg, #fff);
  border: 1px solid var(--card-border, #eee);
  border-radius: 16px;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.book-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: transparent;
}

.dark-mode .book-cover-wrapper {
  position: relative;
  padding-top: 150%; /* Taller aspect ratio 2:3 standard for books */
  overflow: hidden;
  background-color: #f1f1f1;
}

.book-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.book-card:hover .book-cover {
  transform: scale(1.08);
}

/* Gradient overlay for better badge readability if needed, currently unused but good practice */
.book-cover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0) 40%
  );
  pointer-events: none;
}

.points-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #d35400;
  padding: 6px 14px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.8rem;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 5px;
}

.dark-mode .points-badge {
  background: rgba(30, 30, 30, 0.85);
  color: #ffbf00;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.book-card-body {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.book-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  transition: color 0.3s ease;
}

.book-card:hover .book-title {
  color: var(--primary-color);
}

.points-text {
  font-size: 0.95rem;
  color: var(--secondary-text);
  margin-bottom: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-view-details {
  width: 100%;
  border-radius: 10px;
  padding: 10px 0;
  font-weight: 600;
  font-size: 0.9rem;
  background-color: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  transition: all 0.3s ease;
}

.book-card:hover .btn-view-details {
  background-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Dark Mode nuances */
.dark-mode .book-card {
  background-color: #1e1e1e;
  border-color: #333;
}

.dark-mode .book-cover-wrapper {
  background-color: #2a2a2a;
}

/* Offcanvas Cart */
.offcanvas-body {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.cart-items-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 20px;
}

.cart-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--card-border, #eee);
  border-radius: 12px;
  transition: transform 0.2s;
}

.dark-mode .cart-item {
  background: #252525;
  border-color: #333;
}

.cart-item-info {
  flex-grow: 1;
  padding-left: 12px;
}

.cart-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-color);
  margin-bottom: 2px;
}

.btn-remove-cart {
  color: #ff6b6b;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-remove-cart:hover {
  background-color: rgba(255, 107, 107, 0.1);
}

.cart-footer {
  padding: 20px;
  background-color: var(--bg-body, #fff);
  border-top: 1px solid var(--card-border, #eee);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.dark-mode .cart-footer {
  background-color: #1e1e1e;
  border-color: #333;
}

/* Modal Styling */
.modal-content {
  border-radius: 16px;
  overflow: hidden;
  border: none;
}

.dark-mode .modal-content {
  background-color: #222;
  color: #eee;
}

.modal-book-img {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
  max-height: 400px;
  box-shadow: var(--shadow-md);
}

/* Responsive adjustments */
@media (max-width: 576px) {
  .redeem-section {
    padding: 30px 0;
  }
}

/* Cart Toggle Button */
.cart-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-right: 12px;
  transition: all 0.2s ease;
  /* Inherit default styles (Dark Mode) from .tt-header__right button */
  /* background: transparent; */
  /* border: 1px solid rgba(255, 255, 255, 0.2); */
  /* color: white; */
  /* border-radius: 99px; (Inherited) */
}

/* Hover effect for Dark Mode (inheriting gradient from dark.css might fail if not using specific selectors, so valid backup) */
.cart-toggle-btn:hover {
  color: var(--white, #fff); /* Ensure icon stays white on hover */
  /* Gradient background is handled by dark.css .tt-header__right button::before if applicable, 
       but if not, we might need to add it. Let's rely on global CSS first. */
}

/* Light Mode Overrides for Cart Button to match Theme Toggle */
body.light-mode .cart-toggle-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #6b7280;
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.06);
  border-radius: 10px; /* Square with rounded corners in Light Mode */
}

body.light-mode .cart-toggle-btn:hover {
  color: #0d6efd;
  border-color: transparent;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(120deg, #0d6efd, #fe52fb) border-box;
  box-shadow: 0 6px 14px rgba(17, 24, 39, 0.08);
}
/* ==========================
   Redeem Book Page Light Theme
   ========================== */
body.light-mode {
  --card-bg: #ffffff;
  --text-color: #2c3e50;
  --secondary-text: #6c757d;
  --card-border: #e2e8f0;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 12px 30px rgba(0, 0, 0, 0.15);
  --bg-body: #f8f9fa;
  --primary-color: #0d6efd;
}

body.light-mode .book-card {
  background-color: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
  padding: 0px !important;
}

body.light-mode .book-title {
  color: #1f2937 !important;
}

body.light-mode .points-text {
  color: #4b5563 !important;
}

body.light-mode .cart-item {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

body.light-mode .cart-footer {
  background: #ffffff !important;
  border-top: 1px solid #e5e7eb !important;
}

body.light-mode .modal-content {
  background: #ffffff !important;
  color: #1f2937 !important;
}

body.light-mode .points-badge {
  background: rgba(255, 255, 255, 0.95) !important;
  color: #d97706 !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

body.light-mode .book-cover-wrapper {
  position: relative;
  overflow: hidden;
  background-color: #f1f1f1;
}

body.light-mode .card-title {
  font-size: 1.1rem !important;
  font-weight: 800 !important;
  color: #333333 !important;
  padding: 0.3rem 0 !important;
}

/* ==========================
   Offcanvas Dark Mode Styles
   ========================== */
.dark-mode .offcanvas {
  background-color: #1e1e1e;
  color: #f0f0f0;
  border-left: 1px solid #333;
}

.dark-mode .offcanvas-header {
  background-color: #252525 !important;
  border-bottom: 1px solid #333;
}

.dark-mode .offcanvas-title {
  color: #ffffff;
}

.dark-mode .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

.dark-mode .cart-item {
  background-color: #252525;
  border: 1px solid #333;
}

.dark-mode .cart-item-title {
  color: #f0f0f0;
}

.dark-mode .cart-item .text-muted {
  color: #adb5bd !important;
}

.dark-mode .cart-footer {
  background-color: #252525;
  border-top: 1px solid #333;
}

.dark-mode .cart-footer .text-dark {
  color: #f0f0f0 !important;
}

.dark-mode #cart-empty-state i {
  color: #444 !important;
}

.dark-mode #cart-empty-state p {
  color: #888 !important;
}

/* ==========================
   Responsive Header Adjustments
   ========================== */
@media (max-width: 576px) {
  .redeem-section {
    padding: 30px 0;
  }

  /* Redeem Header: Stack and reduce sizes on mobile */
  .redeem-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  .redeem-header h4 {
    font-size: 1.25rem !important; /* Smaller title */
    width: 100%;
  }

  .redeem-points-badge {
    font-size: 0.85rem !important; /* Smaller font */
    padding: 8px 12px !important;
    width: 100%;
    display: flex;
    justify-content: space-between; /* "Available Points: XXX" spread out */
  }
}

/* ==========================
   Fix Badge Visibility in Dark Mode
   ========================== */
/* Specify higher specificity to override dark.css limits */
.tt-header__right .cart-toggle-btn {
  overflow: visible !important; /* Allow badge to spill out */
  z-index: 10; /* Ensure it floats above */
}

/* Ensure the badge itself is visible */
.cart-toggle-btn .badge {
  z-index: 11;
  border: 1px solid var(--card-bg, #222); /* Optional: small border to separate from icon */
}

/* Fix for Dark Mode Hover Overflow 
   Since we used overflow: visible, the background hover effect (::before) 
   needs its own border-radius to match the button shape. 
*/
.cart-toggle-btn::before {
  border-radius: inherit;
}

/* Fix Bootstrap modal-open breaking position: sticky on sidebar */
body.modal-open {
  overflow: clip !important;
}

body[style*="overflow: hidden"] {
  overflow: clip !important;
}
