/* quartz/static/book-styles.css */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.1rem;
  margin: 2rem 0;
}

.book-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.6rem 0.8rem; 
  margin: 0.5rem; /* ↓ 原来 gap 已经够了，这里缩小 */
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  height: auto; /* 自动适应内容 */
  min-height: 280px; /* 防止太扁 */
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.book-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: 0.1rem;
}

.book-cover-wrapper {
  margin-bottom: 0.3rem;
  width: 100%;
  display: flex;
  justify-content: center;
}

.book-cover {
  width: 100px;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.book-cover-placeholder {
  width: 120px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  font-size: 3rem;
}

.book-title-section {
  width: 100%;
}

.book-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0.2rem 0;
  color: #1f2937;
  line-height: 1.3;
  word-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.book-title a {
  text-decoration: none;
  color: inherit;
}

.book-title a:hover {
  color: #2563eb;
}

.book-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  margin-bottom: 0.1rem;
}

.stars {
  color: #f59e0b;
  font-size: 0.85rem;
}

.score {
  font-weight: 600;
  color: #f59e0b;
  font-size: 0.9rem;
}

.my-rating {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.book-info {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: #6b7280;
  width: 100%;
  text-align: left;
  flex: 1; /* 占据剩余空间，把底部元素推下去 */
}

.info-row {
  display: flex;
  margin: 0.25rem 0;
  line-height: 1.5;
  flex-wrap: wrap;
}

.info-row .label {
  font-weight: 500;
  min-width: 50px;
  color: #4b5563;
  flex-shrink: 0;
}

.info-row span:last-child {
  flex: 1;
  word-break: break-word;
}

.book-progress {
  margin-top: 0.8rem;
  width: 100%;
  height: 5px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;

  margin-top: auto; /* 自动推到底部 */
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 0.3rem;
  font-weight: 500;
}

.book-status {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 0.8rem;
  letter-spacing: 0.3px;

  align-self: flex-start;
  /* 不需要 margin-top: auto，因为进度条已经推到底部了 */
}

.status-正在阅读 {
  background: #dbeafe;
  color: #1e40af;
}

.status-已读完 {
  background: #d1fae5;
  color: #065f46;
}

.status-未读完 {
  background: #fef3c7;
  color: #92400e;
}

.status-未开始 {
  background: #f3f4f6;
  color: #4b5563;
}

.status-概览 {
  background: #e0e7ff;
  color: #4338ca;
}

.status-Unknown {
  background: #f3f4f6;
  color: #6b7280;
}

.book-query-loading {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-size: 1.2rem;
}

.book-query-error {
  text-align: center;
  padding: 2rem;
  color: #dc2626;
  background: #fee2e2;
  border-radius: 8px;
  margin: 1rem 0;
}

/* 响应式设计 */
@media (min-width: 1600px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 1200px) and (max-width: 1599px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  
  .book-cover,
  .book-cover-placeholder {
    width: 100px;
    height: 140px;
  }
}

@media (max-width: 767px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }
  
  .book-card {
    padding: 1rem;
  }
  
  .book-cover,
  .book-cover-placeholder {
    width: 90px;
    height: 130px;
  }
  
  .book-title {
    font-size: 0.9rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .book-card {
    background: #1f2937;
    border-color: #374151;
  }
  
  .book-title {
    color: #f9fafb;
  }
  
  .book-info {
    color: #d1d5db;
  }
  
  .info-row .label {
    color: #9ca3af;
  }
  
  .book-query-loading {
    color: #d1d5db;
  }
}