/* ═══════════════════════════════════════════════════════════════════
   GROWTH STEPS — E-BOOK LIBRARY STYLESHEET
   Seamlessly integrates with site design system and dark/light themes
   ═══════════════════════════════════════════════════════════════════ */

/* ── SEARCH & FILTER CONTROLS ── */
.library-controls {
  margin-bottom: var(--space-8);
}

.library-search-form {
  display: flex;
  gap: var(--space-3);
  max-width: 680px;
  margin: 0 auto var(--space-6);
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.library-search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.library-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.search-btn {
  padding: 12px 24px;
  font-weight: 600;
  border-radius: var(--radius-lg);
}

/* Tag filter chips */
.tag-filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.tag-chip:hover {
  background: var(--bg-muted);
  color: var(--text);
  border-color: var(--border-strong);
}

.tag-chip.active {
  background: var(--primary);
  color: #1c1917;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ── BOOK CARD GRID ── */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  height: 100%;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

/* Cover Image / Placeholder */
.book-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: linear-gradient(135deg, #27272a, #18181b);
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-slow);
}

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

/* Fallback Cover */
.book-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  text-align: center;
  background: linear-gradient(135deg, #3f3f46 0%, #18181b 100%);
  color: #fafafa;
  position: relative;
}

[data-theme="dark"] .book-cover-fallback {
  background: linear-gradient(135deg, #27272a 0%, #09090b 100%);
}

.fallback-icon {
  font-size: 3rem;
  margin-bottom: var(--space-3);
  opacity: 0.9;
}

.fallback-title {
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.3;
  max-height: 3.9em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Format Badge Overlay */
.format-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.badge-pdf {
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
}

.badge-epub {
  background: rgba(124, 58, 237, 0.92);
  color: #fff;
}

.badge-txt {
  background: rgba(13, 148, 136, 0.92);
  color: #fff;
}

/* Card Body */
.book-card-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-card-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-1);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card-title a {
  text-decoration: none;
  color: inherit;
  transition: color var(--transition-fast);
}

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

.book-card-author {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.book-card-notes {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.book-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--space-4);
}

.book-card-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  background: var(--bg-muted);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Card Actions */
.book-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: auto;
}

.book-card-actions .btn {
  flex: 1;
  justify-content: center;
  font-size: var(--text-sm);
  padding: 8px 12px;
}

/* ── BOOK DETAIL PAGE ── */
.book-detail-container {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

.breadcrumb-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  margin-bottom: var(--space-6);
  transition: color var(--transition-fast);
}

.breadcrumb-back:hover {
  color: var(--primary-text);
}

.book-detail-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-8);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
}

@media (max-width: 768px) {
  .book-detail-layout {
    grid-template-columns: 1fr;
    padding: var(--space-5);
  }
}

.book-detail-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.book-detail-info h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--text);
  margin-bottom: var(--space-2);
  line-height: 1.25;
}

.book-detail-author {
  font-size: var(--text-lg);
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

.book-detail-meta-table {
  width: 100%;
  margin-bottom: var(--space-6);
  border-collapse: collapse;
}

.book-detail-meta-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.book-detail-meta-table td:first-child {
  color: var(--text-subtle);
  width: 120px;
  font-weight: 500;
}

.book-detail-meta-table td:last-child {
  color: var(--text);
  font-weight: 600;
}

.book-detail-notes {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background: var(--bg-muted);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.6;
}

/* ── ADMIN LIBRARY PANEL ── */
.admin-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.admin-books-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--text-sm);
}

.admin-books-table th {
  padding: 14px 16px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-books-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.admin-books-table tr:last-child td {
  border-bottom: none;
}

.admin-books-table tr:hover td {
  background: var(--bg-muted);
}

.book-table-cover {
  width: 44px;
  height: 58px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

.book-table-cover-fallback {
  width: 44px;
  height: 58px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.table-action-group {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ── EDIT MODAL ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-base);
}

.modal-backdrop.active .modal-box {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}

.modal-header h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text);
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
}
