/* LendShelf Design System */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #1a1a2e;
  --cream: #faf8f5;
  --warm: #e8ddd3;
  --accent: #c75c2e;
  --accent-hover: #b5512a;
  --accent-light: #f0ddd2;
  --sage: #4a6741;
  --sage-light: #dce5d8;
  --text: #3d3d50;
  --text-light: #6b6b80;
  --border: rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--cream);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--ink);
  line-height: 1.2;
}

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

/* ==================== NAV ==================== */
.app-nav {
  padding: 1rem 2rem;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-links a {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-links a:hover {
  background: var(--warm);
  color: var(--ink);
}

.nav-links a.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); color: white; }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--cream); border-color: rgba(0,0,0,0.15); }

.btn-sage {
  background: var(--sage);
  color: white;
}
.btn-sage:hover { background: #3d5736; color: white; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn-outline:hover { background: var(--accent); color: white; }

.btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input::placeholder { color: #aaa; }

/* ==================== CARDS ==================== */
.card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

/* ==================== BOOK CARDS ==================== */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

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

.book-cover {
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.book-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
}

.book-initial {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: rgba(255,255,255,0.25);
  z-index: 1;
}

.book-cover-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  z-index: 1;
  padding: 0 1rem;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.format-badges {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.35rem;
  z-index: 2;
}

.format-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.format-badge.digital {
  background: rgba(74, 103, 65, 0.9);
  color: white;
}

.format-badge.physical {
  background: rgba(199, 92, 46, 0.9);
  color: white;
}

.format-badge.unavailable {
  background: rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.7);
  text-decoration: line-through;
}

.book-info {
  padding: 1rem;
}

.book-info h3 {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.genre-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: var(--cream);
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-light);
}

/* ==================== PAGE LAYOUT ==================== */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-light);
  font-size: 1.05rem;
}

/* ==================== SEARCH & FILTERS ==================== */
.search-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-input-wrapper .form-input {
  padding-left: 2.5rem;
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1rem;
}

.genre-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.genre-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.genre-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.genre-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ==================== PRICING CARDS ==================== */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.pricing-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pricing-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.pricing-card.featured {
  border: 2px solid var(--accent);
  box-shadow: 0 4px 20px rgba(199, 92, 46, 0.15);
}

.pricing-card.featured::before {
  content: 'Most Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 0.25rem 1rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

.pricing-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.pricing-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.pricing-price span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-light);
}

.pricing-desc {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.pricing-features {
  list-style: none;
  text-align: left;
  margin-bottom: 2rem;
}

.pricing-features li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pricing-features li:last-child { border-bottom: none; }

.check { color: var(--sage); font-weight: 700; }
.cross { color: #ccc; }

/* ==================== BORROW CARDS (LIBRARY) ==================== */
.borrow-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.borrow-card:hover { box-shadow: var(--shadow-md); }

.borrow-cover {
  width: 100px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.borrow-cover span {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
}

.borrow-info {
  padding: 1rem 1rem 1rem 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.borrow-info h3 {
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.borrow-info .author {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.borrow-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.status-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  text-transform: uppercase;
}

.status-badge.active { background: var(--sage-light); color: var(--sage); }
.status-badge.shipped { background: #fef3cd; color: #856404; }
.status-badge.returned { background: #e2e3e5; color: #6c757d; }
.status-badge.digital { background: var(--sage-light); color: var(--sage); }
.status-badge.physical { background: var(--accent-light); color: var(--accent); }

.due-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ==================== TABS ==================== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

.tab:hover { color: var(--ink); }

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

/* ==================== AUTH TABS ==================== */
.auth-tabs {
  display: flex;
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  margin-bottom: 2rem;
}

.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: none;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.auth-tab.active {
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: white;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--sage);
  font-size: 0.9rem;
  max-width: 350px;
  animation: slideIn 0.2s ease-out;
}

.toast.error { border-left-color: #dc3545; }
.toast.success { border-left-color: var(--sage); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==================== LOADING ==================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-light);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== DETAIL PAGE ==================== */
.book-detail {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 3rem;
  align-items: start;
}

.detail-cover {
  width: 100%;
  height: 400px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.detail-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
}

.detail-cover .book-initial {
  font-size: 5rem;
}

.detail-info h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.detail-author {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.detail-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.meta-item {
  padding: 0.4rem 0.8rem;
  background: var(--cream);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-light);
}

.meta-item strong { color: var(--ink); }

.detail-description {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 2rem;
}

.borrow-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.availability-note {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

/* ==================== ALERT BOX ==================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.alert-info {
  background: #e8f4fd;
  border: 1px solid #b8daff;
  color: #004085;
}

.alert-warning {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
}

.alert-success {
  background: var(--sage-light);
  border: 1px solid #c3dab4;
  color: #2d4a22;
}

/* ==================== FOOTER ==================== */
.app-footer {
  max-width: 1200px;
  margin: 4rem auto 0;
  padding: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

/* ==================== BACK LINK ==================== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); }

/* ==================== SUCCESS BANNER ==================== */
.success-banner {
  background: var(--sage);
  color: white;
  text-align: center;
  padding: 1rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .app-nav { padding: 0.75rem 1rem; }

  .nav-links { gap: 0; }
  .nav-links a { padding: 0.4rem 0.6rem; font-size: 0.8rem; }

  .page-container { padding: 1.5rem 1rem; }

  .page-header h1 { font-size: 1.5rem; }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }

  .book-cover { height: 160px; }
  .book-initial { font-size: 2.5rem; }

  .book-detail {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .detail-cover { height: 280px; }

  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .search-bar { flex-direction: column; }
  .search-input-wrapper { min-width: 100%; }

  .borrow-card { flex-direction: column; }
  .borrow-cover { width: 100%; min-height: 80px; }
  .borrow-info { padding: 1rem; }
}

@media (max-width: 480px) {
  .nav-inner { flex-wrap: wrap; gap: 0.5rem; }
  .nav-links { width: 100%; justify-content: center; }

  .genre-filters { gap: 0.35rem; }
  .genre-btn { font-size: 0.75rem; padding: 0.3rem 0.7rem; }
}
