:root {
  --primary-color: #131921; /* Amazon dark blue/black header */
  --secondary-color: #232f3e; /* Amazon lighter subnav */
  --accent-color: #FEBD69; /* Amazon search button orange */
  --accent-hover: #F3A847;
  --bg-color: #EAEDED; /* Amazon gray background */
  --card-bg: #FFFFFF;
  --text-dark: #0F1111;
  --text-light: #565959;
  --link-color: #007185;
  --link-hover: #C45500;
  --border-color: #D5D9D9;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* Header & Nav */
header {
  background: linear-gradient(135deg, #0F161E 0%, #1F2A38 100%);
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: white;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 3px;
}

.logo:hover {
  border-color: white;
}

.logo img {
  height: 36px;
}

.header-search {
  flex: 1;
  max-width: 850px;
  margin: 0 1rem;
  display: flex;
  border-radius: 6px;
  overflow: hidden;
  height: 44px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: box-shadow 0.2s;
  background: white;
}

.header-search:focus-within {
  box-shadow: 0 0 0 3px rgba(243, 168, 71, 0.5);
}

.header-search input {
  flex: 1;
  padding: 0 1.2rem;
  border: none;
  outline: none;
  font-size: 1.05rem;
  color: #333;
}

.header-search button {
  background-color: #FEBD69;
  border: none;
  padding: 0 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
  transition: background-color 0.2s;
}

.header-search button:hover {
  background-color: #F3A847;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-link {
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  border: 1px solid transparent;
  border-radius: 3px;
}

.header-link:hover {
  border-color: white;
}

.header-link span {
  font-size: 0.75rem;
  font-weight: 400;
  color: #ccc;
}

.subnav {
  background-color: #232F3E;
  padding: 0.6rem 1.5rem;
  display: flex;
  gap: 1.8rem;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  overflow-x: auto;
  white-space: nowrap;
}
.subnav a {
  color: white;
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 3px;
}

.subnav a:hover {
  border-color: white;
}

/* Main Content */
main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
}

.section-header {
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.section-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

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

/* Books Grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.book-card:hover {
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.book-cover-container {
  height: 260px;
  background-color: #F8F9FA;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
}

.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--link-color);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}

.book-card:hover .book-title {
  color: var(--link-hover);
  text-decoration: underline;
}

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

/* Mock Rating Stars */
.book-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  color: #FFA41C;
  font-size: 0.85rem;
}
.book-rating span {
  color: var(--link-color);
  font-size: 0.8rem;
  margin-left: 0.2rem;
}

.book-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid #eee;
}

.book-stats div {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Footer */
footer {
  background-color: var(--primary-color);
  color: white;
  padding: 2rem 1.5rem;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6rem;
}

.footer-section h4 {
  font-size: 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section ul li a {
  color: #DDD;
  text-decoration: none;
  font-size: 0.9rem;
}

.footer-section ul li a:hover {
  text-decoration: underline;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  margin-top: 2rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  color: #CCC;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 8px;
  width: 100%;
  max-width: 1000px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  max-height: 95vh;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #F8F9FA;
  border-radius: 8px 8px 0 0;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.close-modal {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #555;
}

.close-modal:hover {
  color: #000;
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
}

.book-detail-grid {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 2rem;
}

@media (max-width: 992px) {
  .book-detail-grid {
    grid-template-columns: 200px 1fr;
  }
  .buy-box {
    grid-column: 1 / -1;
    margin-top: 1rem;
  }
}

@media (max-width: 768px) {
  .book-detail-grid {
    grid-template-columns: 1fr;
  }
  header .header-search {
    display: none;
  }
  .header-right {
    display: none;
  }
  .modal-body {
    padding: 1.2rem;
  }
  .book-detail-cover {
    width: 100%;
    max-width: 240px;
    height: auto;
    aspect-ratio: 2 / 3;
    margin: 0 auto 1.5rem auto;
    display: block;
  }
  .book-detail-title {
    font-size: 1.4rem;
    text-align: center;
  }
  .book-detail-author {
    text-align: center;
  }
  .book-rating {
    justify-content: center;
  }
  .book-detail-stats {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }
  .footer-content {
    flex-direction: column;
    gap: 1.5rem;
  }
}

/* Reader & Grid Mobile Adjustments */
@media (max-width: 600px) {
  .books-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .book-card {
    flex-direction: row;
    height: auto;
    min-height: 150px;
  }
  .book-cover-container {
    width: 105px;
    height: 100%;
    aspect-ratio: auto;
    border-bottom: none;
    border-right: 1px solid var(--border-color);
  }
  .book-info {
    padding: 0.8rem;
    justify-content: flex-start;
    overflow: hidden;
  }
  .book-title {
    font-size: 1rem;
    -webkit-line-clamp: 2;
  }
  .reader-toolbar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 0.5rem;
    gap: 0.5rem;
  }
  .reader-toolbar-center {
    order: 3;
    width: 100%;
    margin-top: 0.5rem;
  }
  .reader-title {
    max-width: 150px;
  }
  .reader-btn span.btn-text {
    display: none;
  }
  .reader-controls-floating {
    bottom: 1rem;
    padding: 0.3rem 0.8rem;
  }
}

.book-detail-cover {
  width: 100%;
  height: 380px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border: 1px solid var(--border-color);
  background: #fff;
}

.book-detail-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.book-detail-author {
  color: var(--link-color);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.book-detail-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-light);
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.book-detail-stats div {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.book-detail-desc {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Buy Box (Actions) */
.buy-box {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.2rem;
  background-color: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  align-self: start;
}

.buy-box h4 {
  font-size: 1.1rem;
  color: #B12704; /* Amazon price red */
  margin-bottom: 0.2rem;
}

.buy-box p.stock {
  color: #007600;
  font-size: 1rem;
  font-weight: 600;
}

.btn {
  padding: 0.6rem 1rem;
  border-radius: 20px; /* Pill shape like modern Amazon */
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.1s;
  width: 100%;
}

.btn-primary {
  background: #FFD814;
  color: #0F1111;
  border-color: #FCD200;
}

.btn-primary:hover {
  background: #F7CA00;
}

.btn-secondary {
  background: #FFA41C;
  color: #0F1111;
  border-color: #FF8F00;
}

.btn-secondary:hover {
  background: #FA8900;
}

.btn-outline {
  background: #FFFFFF;
  border-color: #D5D9D9;
  color: #0F1111;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(213,217,217,0.5);
}

.btn-outline:hover {
  background: #F7FAFA;
}

.btn.liked i, .btn.liked svg {
  fill: #B12704;
  color: #B12704;
  stroke: #B12704;
}

.share-link-container {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.share-link-container input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text-light);
  background: #F8F9FA;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 0.6rem;
  border-radius: 4px;
  border: 1px solid #888;
  font-size: 0.95rem;
}

.form-group input:focus {
  border-color: #007185;
  box-shadow: 0 0 0 3px rgba(0, 113, 133, 0.2);
  outline: none;
}

#emptyState {
  text-align: center;
  padding: 4rem;
  color: var(--text-light);
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* Mobile search */
.mobile-search {
  display: none;
  padding: 0.8rem 1.5rem;
  background: linear-gradient(135deg, #0F161E 0%, #1F2A38 100%);
}

.mobile-search .header-search {
  margin: 0;
  max-width: 100%;
}

@media (max-width: 768px) {
  .mobile-search {
    display: block;
  }
  .mobile-search .header-search {
    display: flex;
  }
}

/* Reader Modal Specific Styles */
.reader-container {
  width: 100vw;
  height: 100%;
  background-color: #525659;
  display: flex;
  flex-direction: column;
}

.reader-toolbar {
  height: auto;
  min-height: 48px;
  background-color: #323639;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(0.5rem, env(safe-area-inset-top)) 1rem 0.5rem 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 10;
}

.reader-toolbar-left, .reader-toolbar-center, .reader-toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.reader-toolbar-center {
  flex: 1;
  justify-content: center;
}

.reader-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

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

.icon-btn {
  padding: 0.4rem;
}

.reader-title {
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-page-info {
  font-size: 0.9rem;
  font-family: monospace;
}

.reader-canvas-container {
  flex: 1;
  overflow: auto;
  padding: 2rem;
  position: relative;
  text-align: center;
}

#pdfCanvas {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  background: white;
  max-width: none;
  height: auto !important;
  margin: 0 auto;
  display: inline-block;
}

.reader-controls-floating {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  display: flex;
  gap: 1.5rem;
  z-index: 20;
}

.reader-nav-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.reader-nav-btn:hover {
  background: rgba(255,255,255,0.2);
}
