/* ==========================================
   BOOKS.CSS - Book Components & User Settings (OPTIMIZED)
   Pages: book_card.html, preferences.html
   Dependencies: core.css (must be loaded first)
   ========================================== */

/* ==========================================
   BOOK GRID LAYOUTS
   ========================================== */

.bk-books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-8);
  margin: var(--space-5) 0;
}

.bk-books-grid-dense {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-5);
}

.bk-books-grid-large {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-10);
}

/* ==========================================
   3D BOOK CARD (ENHANCED & OPTIMIZED)
   ========================================== */

.bk-book {
  position: relative;
  width: 100%;
  max-width: 240px;
  height: 380px;
  text-align: center;
  margin: 1rem auto;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

/* Book Badges */
.bk-book-badges {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  opacity: 0;
}

.bk-book:hover .bk-book-badges {
  opacity: 1;
}

.bk-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
  opacity: 1;
}

.bk-badge-featured {
  background: linear-gradient(135deg, var(--featured-color), #ff8a50);
  color: white;
}

.bk-badge-free {
  background: linear-gradient(135deg, var(--free-color), #20c997);
  color: white;
}

.bk-badge-recommended {
  background: linear-gradient(135deg, #e91e63, #ff6b9d);
  color: white;
}

.bk-badge-premium {
  background: linear-gradient(135deg, var(--premium-color), #ffed4a);
  color: #8b6914;
}

.bk-badge-new {
  background: linear-gradient(135deg, #e91e63, #ff6b9d);
  color: white;
}

.bk-badge-level {
  background: var(--info-color) ;
  color: white;
}

.bk-badge-language {
  background: var(--secondary-color);
  color: white;
}

/* Book Cover with 3D Effect */
.bk-book-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
  transform-origin: 0 50%;
  background: #111;
  border: 1px solid rgba(218, 218, 218, 0.8);
  border-radius: 3px;
  box-shadow:
    inset 4px 1px 3px rgba(255, 255, 255, 0.375),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5),
    4px 4px 15px rgba(0, 0, 0, 0.4);
  perspective: 1000px;
  transform: rotateY(-10deg);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.bk-book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.bk-book-cover-img.loading {
  opacity: 0.5;
  filter: blur(2px);
}

.bk-book-cover-img.loaded {
  opacity: 1;
  filter: none;
}

.bk-book-cover-img.error {
  opacity: 0.3;
}

/* Placeholder Cover */
.bk-placeholder-cover {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 3px;
  padding: var(--space-5);
  text-align: center;
}

.bk-placeholder-cover i {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-3);
  opacity: 0.8;
}

.bk-placeholder-cover span {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
}

/* 3D Book Effects */
.bk-book-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  margin-left: 10px;
  border-left: 3px solid rgba(0, 0, 0, 0.118);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
  transition: width 0.5s ease;
}

.bk-book-light {
  position: absolute;
  top: 0;
  right: 0;
  width: 90%;
  height: 100%;
  border-radius: 3px;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.2) 100%);
  opacity: 0.1;
  transition: all 0.5s ease;
}

/* Hover Effects */
.bk-book:hover .bk-book-cover {
  transform: perspective(2000px) rotateY(-75deg);
  box-shadow:
    inset 4px 1px 3px rgba(255, 255, 255, 0.375),
    inset 0 -1px 2px rgba(0, 0, 0, 0.5),
    10px 0px 10px -5px rgba(0, 0, 0, 0.188);
}

.bk-book:hover .bk-book-effect {
  width: 40px;
}

.bk-book:hover .bk-book-light {
  opacity: 1;
  width: 70%;
}

/* ==========================================
   ENHANCED 3D BOOK FOR DETAIL PAGE
   ========================================== */

/* Enhanced 3D Book for Detail Page */
.bk-book-detail {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  margin: 0;
}

.bk-book-detail .bk-book-cover {
  position: absolute;
  inset: 0;
  z-index: 1;
  transform-origin: 0 50%;
  background: #111;
  border: 1px solid rgba(218, 218, 218, 0.8);
  border-radius: 3px;
  perspective: 1000px;
  transform: rotateY(-10deg);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.bk-book-detail .bk-book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.bk-book-detail .bk-book-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  margin-left: 10px;
  border-left: 3px solid rgba(0, 0, 0, 0.118);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.1) 100%);
  transition: width 0.4s ease;
}

.bk-book-detail .bk-book-light {
  position: absolute;
  top: 0;
  right: 0;
  width: 90%;
  height: 100%;
  border-radius: 3px;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.2) 100%);
  opacity: 0.1;
  transition: all 0.4s ease;
}

/* Hover Effects for Detail Page */
.bk-book-detail:hover .bk-book-effect {
  width: 40px;
}

.bk-book-detail:hover .bk-book-light {
  opacity: 1;
  width: 70%;
}

/* Enhanced Book Inside for Detail Page */
.bk-book-detail .bk-book-inside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
  top: 2%;
  right: -7px;
  width: calc(100% - 2px);
  height: 96%;
  border: 1px solid #999;
  border-radius: 3px;
  background: white;
  padding: var(--space-4) var(--space-3);
}

/* Format Info Styles */
.bk-format-info {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  margin: var(--space-2) 0;
  flex-wrap: wrap;
}

.bk-format-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--background-light);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  border: 1px solid var(--border-color);
}

.bk-pages-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: auto;
  padding: var(--space-1) var(--space-2);
  background: rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-sm);
}

/* Enhanced Button Styles for Detail Page */
.bk-btn-download {
  position: relative;
  overflow: hidden;
}

.bk-btn-download::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.bk-btn-download:hover::before {
  left: 100%;
}

/* Enhanced Loading States */
.bk-btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.bk-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Button Groups for Detail Page */
.bk-download-actions .bk-btn,
.bk-purchase-actions .bk-btn,
.bk-cart-actions .bk-btn,
.bk-sample-actions .bk-btn {
  width: 100%;
  justify-content: center;
}

.bk-sample-actions .bk-btn {
  width: auto;
  min-width: 120px;
}

/* Enhanced Focus States */
.bk-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(39, 143, 255, 0.2);
}

/* Improved Button Spacing */
.bk-btn span {
  display: inline-block;
}

.bk-btn i + span {
  margin-left: var(--space-2);
}

/* Enhanced Badge Styles for Detail Page */
.bk-badge {
  position: relative;
  overflow: hidden;
}

.bk-badge::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 2s ease;
}

.bk-badge-featured::before {
  animation: shimmer 3s ease infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  50% { left: 100%; }
  100% { left: -100%; }
}

/* Book Inside Content */
.bk-book-inside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
  top: 2%;
  right: -7px;
  width: calc(100% - 2px);
  height: 96%;
  border: 1px solid #999;
  border-radius: 3px;
  background: white;
  padding: var(--space-4) var(--space-3);
  box-shadow:
    10px 40px 40px -10px rgba(0, 0, 0, 0.188),
    inset -2px 0 0 #999,
    inset -3px 0 0 #dbdbdb,
    inset -4px 0 0 white,
    inset -5px 0 0 #dbdbdb,
    inset -6px 0 0 white,
    inset -7px 0 0 #dbdbdb,
    inset -8px 0 0 white,
    inset -9px 0 0 #dbdbdb;
}

.bk-book-inside-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-color);
  text-align: center;
  line-height: 1.3;
  margin: 0 0 var(--space-3) 0;
  padding: 0 var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Book Price Display */
.bk-book-price {
  margin: var(--space-3) 0;
  text-align: center;
}

.bk-price-free {
  background: linear-gradient(135deg, var(--free-color), #20c997);
  color: white;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bk-price-amount {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--primary-color);
  background: linear-gradient(135deg, var(--primary-color), #0056b3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Book Actions */
.bk-book-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  align-items: center;
}

.bk-book-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition);
  min-width: 100px;
  min-height: 32px;
  text-align: center;
}

.bk-btn-get {
  background: linear-gradient(135deg, var(--premium-color), #ffed4a);
  color: #8b6914;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.bk-btn-get:hover {
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.bk-btn-download {
  background: linear-gradient(135deg, var(--success-color), #20c997);
  color: white;
}

.bk-btn-download:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bk-btn-cart {
  background: linear-gradient(135deg, var(--primary-color), #0056b3);
  color: white;
}

.bk-btn-cart:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bk-btn-owned {
  background: linear-gradient(135deg, var(--secondary-color), #5a6268);
  color: white;
  cursor: default;
}

.bk-btn-login {
  background: linear-gradient(135deg, var(--warning-color), #e0a800);
  color: #856404;
}

.bk-btn-login:hover {
  transform: translateY(-2px);
}

/* Audio Indicator */
.bk-audio-indicator {
  color: var(--info-color);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Book Stats */
.bk-book-stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
  width: 100%;
}

.bk-book-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Book Title Hover */
.bk-book-title {
  position: absolute;
  opacity: 0;
  top: -75px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  font-size: var(--text-sm);
  width: max-content;
  max-width: 280px;
  color: var(--text-color);
  text-align: center;
  background: white;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  z-index: 20;
  border: 1px solid var(--border-color);
}

.bk-book-title p {
  margin: 0;
  line-height: 1.3;
  font-weight: 600;
}

.bk-book-authors {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: var(--space-1);
  display: block;
}

.bk-book:hover .bk-book-title {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* View Details Button */
.bk-btn-details {
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(39, 143, 255, 0.95), rgba(0, 86, 179, 0.95));
  color: white;
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  letter-spacing: 0.5px;
  border-radius: var(--radius);
  text-decoration: none;
  opacity: 0;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.bk-book:hover .bk-btn-details {
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
  box-shadow: var(--shadow-md);
}

.bk-btn-details:hover {
  background: linear-gradient(135deg, var(--primary-color), #0056b3);
  transform: translateX(-50%) translateY(-8px) !important;
}

/* Quick Actions */
.bk-book-quick-actions {
  position: absolute;
  top: var(--space-3);
  right: -40px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  opacity: 0;
  transform: translateX(10px);
  transition: var(--transition);
  z-index: 15;
}

.bk-book:hover .bk-book-quick-actions {
  opacity: 1;
  transform: translateX(0);
}

.bk-quick-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: white;
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.bk-quick-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: scale(1.1);
}

/* Intersection Observer Animation */
.bk-book:not(.bk-visible) {
  opacity: 0.8;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.bk-book:not(.bk-visible) .bk-book-badges {
  opacity: 1 !important; /* Keep badges fully visible even when book is not visible */
}

.bk-book.bk-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================
   PREFERENCES PAGE STYLES
   ========================================== */

.bk-preferences-container {
  max-width: 1000px;
  margin: var(--space-5) auto;
  padding: var(--space-5);
}

.bk-preferences-header {
  text-align: center;
  margin-bottom: var(--space-10);
  padding: var(--space-8);
  background: linear-gradient(135deg, var(--background-white) 0%, #f0f4f8 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.bk-preferences-title {
  font-size: var(--text-4xl);
  color: var(--text-color);
  margin: var(--space-4) 0 var(--space-3) 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.bk-preferences-subtitle {
  color: var(--text-muted);
  font-size: var(--text-lg);
  margin: 0;
}

.bk-preferences-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.bk-preference-section {
  background: white;
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.bk-preference-section h2 {
  margin: 0 0 var(--space-6) 0;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--border-color);
  font-size: var(--text-2xl);
}

.bk-preference-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

.bk-preference-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.bk-preference-label {
  font-weight: 600;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
}

.bk-preference-help {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
  margin-top: var(--space-1);
}

/* Genre and Level Selection */
.bk-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.bk-checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.bk-checkbox-item:hover {
  background: var(--background-light);
  border-color: var(--primary-color);
}

.bk-checkbox-item input {
  display: none;
}

.bk-checkbox-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.bk-checkbox-item input:checked + .bk-checkbox-custom {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.bk-checkbox-item input:checked + .bk-checkbox-custom::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: var(--text-sm);
  font-weight: bold;
}

.bk-checkbox-text {
  font-size: var(--text-sm);
  color: var(--text-color);
}

/* Radio Groups */
.bk-radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bk-radio-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.bk-radio-item:hover {
  background: var(--background-light);
  border-color: var(--primary-color);
}

.bk-radio-item input {
  display: none;
}

.bk-radio-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.bk-radio-item input:checked + .bk-radio-custom {
  border-color: var(--primary-color);
}

.bk-radio-item input:checked + .bk-radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: var(--radius-full);
}

.bk-radio-text {
  font-size: var(--text-base);
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Toggle Options */
.bk-toggle-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.bk-toggle-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.bk-toggle-item:hover {
  background: var(--background-light);
}

.bk-toggle-item input {
  display: none;
}

.bk-toggle-switch {
  width: 44px;
  height: 24px;
  background: #ccc;
  border-radius: 12px;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.bk-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.bk-toggle-item input:checked + .bk-toggle-switch {
  background: var(--primary-color);
}

.bk-toggle-item input:checked + .bk-toggle-switch::after {
  transform: translateX(20px);
}

.bk-toggle-text {
  font-size: var(--text-base);
  color: var(--text-color);
}

/* Action Buttons */
.bk-preference-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-8);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
}

/* File Upload */
.bk-file-upload {
  text-align: center;
  margin-bottom: var(--space-5);
}

.bk-file-input {
  display: none;
}

.bk-file-label {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}

.bk-file-label:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.bk-file-label i {
  font-size: var(--text-4xl);
}

/* Saving Indicator */
.bk-saving-indicator {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  background: var(--primary-color);
  color: white;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: var(--z-fixed);
  display: none;
  font-size: var(--text-sm);
}



/* ==========================================
   ADDITIONAL FIXES & UTILITIES
   Add this to your existing CSS or include separately
   ========================================== */

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ensure proper book card spacing in grid */
.bk-books-grid .bk-book {
  justify-self: center;
  align-self: start;
}

/* Fix for book title positioning on different screen sizes */
.bk-book-title {
  pointer-events: none;
  user-select: none;
}

.bk-book-title::before {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid white;
}

/* Enhanced button states */
.bk-book-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.bk-book-action-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Loading state for buttons */
.bk-book-action-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.bk-book-action-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Enhanced hover effects for better UX */
.bk-book {
  transform-origin: center bottom;
}

.bk-book:hover {
  z-index: 10;
}



/* High contrast mode improvements */
@media (prefers-contrast: high) {
  .bk-book-cover {
    border: 2px solid #000;
  }
  
  .bk-book-badges .bk-badge {
    border: 1px solid #000;
  }
  
  .bk-book-action-btn {
    border: 2px solid currentColor;
  }
}

/* Print styles */
@media print {
  .bk-book-quick-actions,
  .bk-btn-details,
  .bk-book-action-btn {
    display: none !important;
  }
  
  .bk-book {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Fix for Safari flexbox issues */
@supports (-webkit-touch-callout: none) {
  .bk-book-inside {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    -webkit-align-items: center;
    align-items: center;
  }
  
  .bk-book-actions {
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: center;
    align-items: center;
  }
}

/* Smooth animations for premium features */
@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
  }
}

.bk-btn-get:hover {
  animation: pulse-glow 1.5s infinite;
}

/* Ensure proper spacing for the last row */
.bk-books-grid::after {
  content: '';
  flex: auto;
}


.bk-book-title {
  z-index: 21;
}

.bk-book-quick-actions {
  z-index: 16;
}

/* Enhanced focus management for keyboard users */
.bk-book:focus-within .bk-book-quick-actions {
  opacity: 1;
  transform: translateX(0);
}

.bk-book:focus-within .bk-btn-details {
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
}

/* Ensure consistent button heights */
.bk-book-action-btn {
  box-sizing: border-box;
}

/* Loading spinner animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Better image aspect ratio handling */
.bk-book-cover-img {
  object-position: center top;
}

/* Subtle entrance animation for books */
@keyframes bookFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bk-book.bk-visible {
  animation: bookFadeIn 0.6s ease-out;
}

/* Prevent text selection on interactive elements */
.bk-book-cover,
.bk-book-badges,
.bk-book-quick-actions,
.bk-btn-details {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* ==========================================
   MODERN MODAL STYLES (OpenAI-inspired)
   ========================================== */

.bk-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal, 1040);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.bk-image-modal-content {
  max-width: min(90vw, 800px);
  max-height: 90vh;
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.bk-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: #fafafa;
}

.bk-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bk-modal-title i {
  color: #10a37f;
}

.bk-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.bk-modal-close:hover {
  background: #f3f4f6;
  color: #374151;
}

.bk-modal-body {
  padding: 15px 20px;
  background: #fafafa;
}

.bk-modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.bk-image-modal-body {
  text-align: center;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.bk-modal-image {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}

.bk-in-cart-section {
  padding: 24px;
  background: white;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.bk-in-cart-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: #10a37f;
  font-weight: 600;
  padding: 12px 16px;
  background: rgba(16, 163, 127, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(16, 163, 127, 0.2);
  margin-bottom: var(--space-4);
}

.bk-cart-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.bk-cart-actions .bk-btn {
  min-width: 120px;
  height: 40px;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.bk-cart-actions .bk-btn:hover {
  transform: translateY(-1px);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .bk-modal {
    padding: 16px;
  }
  
  .bk-image-modal-content {
    max-width: 100%;
    border-radius: 12px;
  }
  
  .bk-modal-header {
    padding: 20px;
  }
  
  .bk-modal-title {
    font-size: 16px;
  }
  
  .bk-modal-close {
    width: 32px;
    height: 32px;
  }
  
  .bk-cart-actions {
    flex-direction: column;
  }
  
  .bk-cart-actions .bk-btn {
    width: 100%;
  }
}

/* Loading States Enhancement */
.bk-btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.bk-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Skip to Content Link */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 10px;
  background: var(--primary-color);
  color: white;
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  border-radius: var(--radius);
  z-index: 1000;
  font-weight: 600;
  transition: var(--transition);
}

.skip-to-content:focus {
  top: 10px;
}

/* Announcement Region */
#announcements {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Enhanced Button Focus States */
.bk-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(39, 143, 255, 0.2);
}

/* Quota Bar Enhancements */
.bk-quota-fill {
  transition: width 1s ease-in-out, background-color 0.3s ease;
}

.bk-quota-fill.low {
  background: linear-gradient(90deg, var(--danger-color), #e74c3c);
}

.bk-quota-fill.medium {
  background: linear-gradient(90deg, var(--warning-color), #f39c12);
}

.bk-quota-fill.high {
  background: linear-gradient(90deg, var(--success-color), #27ae60);
}

/* ==========================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================== */

/* Focus indicators for keyboard navigation */
.bk-book-detail:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .bk-modal {
    background: rgba(0, 0, 0, 0.9);
  }
  
  .bk-modal-close {
    border: 2px solid currentColor;
  }
  
  .bk-in-cart-indicator {
    border: 1px solid currentColor;
  }
}

/* Reduced motion support for modal */
@media (prefers-reduced-motion: reduce) {
  .bk-modal {
    backdrop-filter: none;
  }
  
  .bk-quota-fill {
    transition: none;
  }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1200px) {
  .bk-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 900px) {
  .bk-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (max-width: 768px) {
  .bk-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-6);
  }
  
  .bk-book {
    height: 350px;
    max-width: 200px;
  }
  
  .bk-book-title {
    max-width: 220px;
    font-size: var(--text-xs);
  }
  
  .bk-preferences-container {
    padding: var(--space-4);
  }
  
  .bk-preference-section {
    padding: var(--space-6);
  }
  
  .bk-preference-grid {
    gap: var(--space-6);
  }
  
  .bk-selection-grid {
    grid-template-columns: 1fr;
  }
  
  .bk-radio-group {
    gap: var(--space-2);
  }
  
  .bk-preference-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .bk-preference-actions .bk-btn {
    width: 100%;
    max-width: 300px;
  }
}

@media (max-width: 600px) {
  .bk-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
  }
  
  .bk-book {
    max-width: 180px;
    height: 300px;
  }
  
  .bk-book-title {
    max-width: 200px;
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
  }
  
  .bk-btn-details {
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-3);
  }
}

@media (max-width: 480px) {
  .bk-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-5);
  }
  
  .bk-book {
    height: 320px;
    max-width: 180px;
  }
  
  .bk-book-title {
    max-width: 200px;
    top: -40px;
  }
  
  .bk-preferences-header {
    padding: var(--space-6);
  }
  
  .bk-preferences-title {
    font-size: var(--text-3xl);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .bk-book:hover .bk-book-cover {
    transform: none;
  }
  
  .bk-book:hover .bk-book-effect,
  .bk-book:hover .bk-book-light {
    width: initial;
    opacity: initial;
  }
  
  .bk-book-cover,
  .bk-book-effect,
  .bk-book-light,
  .bk-book-title,
  .bk-btn-details,
  .bk-book-quick-actions {
    transition: none;
  }
  
  /* Enhanced 3D Book Detail Page - Reduced Motion */
  .bk-book-detail,
  .bk-book-detail .bk-book-cover,
  .bk-book-detail .bk-book-effect,
  .bk-book-detail .bk-book-light,
  .bk-btn::before,
  .bk-badge::before {
    transition: none;
    animation: none;
  }
  
  .bk-book-detail:hover {
    transform: none;
  }
  
  .bk-book-detail:hover .bk-book-cover {
    transform: rotateY(-10deg);
  }
}

/* Detail Page Responsive Adjustments */
@media (max-width: 768px) {
  .bk-book-detail {
    width: 220px;
    height: 320px;
  }
  
  .bk-book-detail .bk-book-inside {
    padding: var(--space-3) var(--space-2);
  }
  
  .bk-book-inside-title {
    font-size: var(--text-xs);
  }
  
  .bk-format-badge,
  .bk-pages-info {
    font-size: 10px;
    padding: var(--space-1);
  }
}

@media (max-width: 480px) {
  .bk-book-detail {
    width: 200px;
    height: 290px;
  }
  
  .bk-format-info {
    flex-direction: column;
    gap: var(--space-1);
  }
  
  .bk-sample-actions {
    flex-direction: column;
    gap: var(--space-2);
  }
  
  .bk-sample-actions .bk-btn {
    width: 100%;
  }
}

/* ==========================================
   UI COMPONENT STYLES (Clean JS Integration)
   ========================================== */

/* Toast Container */
.bk-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  pointer-events: none;
  max-width: 400px;
}

/* Toast Notifications */
.bk-toast {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-3);
  padding: var(--space-4);
  pointer-events: auto;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
  min-width: 300px;
  max-width: 400px;
}

.bk-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.bk-toast.hide {
  transform: translateX(100%);
  opacity: 0;
}

.bk-toast-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bk-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  margin-left: auto;
  color: var(--text-muted);
  transition: var(--transition);
}

.bk-toast-close:hover {
  background: var(--background-light);
  color: var(--text-color);
}

/* Toast Types */
.bk-toast-success {
  border-left: 4px solid var(--success-color);
}

.bk-toast-success .bk-toast-content i {
  color: var(--success-color);
}

.bk-toast-error {
  border-left: 4px solid var(--danger-color);
}

.bk-toast-error .bk-toast-content i {
  color: var(--danger-color);
}

.bk-toast-warning {
  border-left: 4px solid var(--warning-color);
}

.bk-toast-warning .bk-toast-content i {
  color: var(--warning-color);
}

.bk-toast-info {
  border-left: 4px solid var(--info-color);
}

.bk-toast-info .bk-toast-content i {
  color: var(--info-color);
}

.bk-toast-loading {
  border-left: 4px solid var(--primary-color);
}

.bk-toast-loading .bk-toast-content i {
  color: var(--primary-color);
}

/* Loading Overlay */
.bk-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
  text-align: center;
}

.bk-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.bk-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Confirm Dialog */
.bk-confirm-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.bk-confirm-content {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.bk-confirm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-5);
}

/* Body States */
.modal-open {
  overflow: hidden;
}

.loading-active {
  overflow: hidden;
}

/* ==========================================
   UTILITY ANIMATION CLASSES
   ========================================== */

/* Animation Classes */
.bk-fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.bk-fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.bk-animate-width {
  width: 0%;
  transition: width 1s ease-in-out;
}

/* Progress Bar Animation */
.bk-progress-bar {
  transition: width 1s ease-in-out;
}

/* Tooltip Positioning (dynamic classes) */
.bk-tooltip-positioned {
  position: absolute;
  z-index: 1000;
}

/* Accordion Animation */
.bk-accordion-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.bk-accordion-content.expanded {
  max-height: none;
}

.bk-accordion-content.collapsed {
  max-height: 0;
}