/* ============================================================
   Motithang School E-Library - Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Orbitron:wght@500;700&display=swap');

/* === CSS Variables === */
:root {
  --bg-primary: #121212;
  --bg-secondary: #1E1E1E;
  --bg-surface: #242424;
  --accent-red: #D32F2F;
  --accent-hover: #B71C1C;
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0B0;
  --text-muted: #777777;
  --success: #4CAF50;
  --warning: #FF9800;
  --border-color: #333333;
  --overlay: rgba(0, 0, 0, 0.85);
  --nav-height: 64px;
  --header-height: 56px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-nav: 0 -2px 10px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding-top: var(--header-height);
  padding-bottom: var(--nav-height);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

input {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
}

::-webkit-scrollbar {
  display: none;
}

/* === Header === */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background: rgba(18, 18, 18, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.header-logo-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-logo-img i {
  font-size: 20px;
  color: var(--accent-red);
}

.header-brand {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-brand span {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 20px;
  transition: background var(--transition-fast);
}

.header-actions button:active {
  background: var(--bg-surface);
}

/* === Bottom Navigation === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--bg-secondary);
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid var(--border-color);
  z-index: 100;
  box-shadow: var(--shadow-nav);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  text-decoration: none;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  position: relative;
  min-width: 56px;
}

.nav-item i {
  font-size: 22px;
  transition: transform var(--transition-fast);
}

.nav-item span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-item.active {
  color: var(--accent-red);
}

.nav-item.active i {
  transform: scale(1.1);
}

.nav-item:active {
  opacity: 0.7;
}

/* === Page Title === */
.page-title-section {
  padding: 20px 16px 8px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--warning);
  margin-top: 4px;
  font-weight: 400;
  line-height: 1.4;
}

/* === Section Headers === */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 24px 16px 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-red);
  transition: opacity var(--transition-fast);
}

.section-link:active {
  opacity: 0.7;
}

/* === Trending Carousel (Center-Enlarge) === */
.trending-carousel {
  position: relative;
  padding: 8px 0 16px;
}

.trending-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  padding: 16px 40px;
  -webkit-overflow-scrolling: touch;
  scroll-padding: 40px;
}

.trending-card {
  flex: 0 0 180px;
  width:180px;
  min-width:180px;
  max-width:180px;
  scroll-snap-align: center;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
  opacity: 0.6;
  transform: scale(0.9);
  cursor: pointer;
}

.trending-card.active {
  opacity: 1;
  transform: scale(1.05);
  z-index: 10;
}

.trending-card-inner {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.trending-cover {
  width: 100%;
  height: 225px;

  background: linear-gradient(145deg, #2a2a2a, #383838);

  display: flex;
  align-items: center;
  justify-content: center;

  position: relative;
  overflow: hidden;
}

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

.trending-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
  font-weight: 500;
}

.trending-info {
  padding: 10px 12px;
}

.trending-info .book-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trending-info .book-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trending-info .availability {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
}

.availability-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.availability-dot.available {
  background: var(--success);
}

.availability-dot.unavailable {
  background: var(--accent-red);
}

.availability-text.available {
  color: var(--success);
}

.availability-text.unavailable {
  color: var(--accent-red);
}

/* === Horizontal Scroll Section === */
.scroll-section {
  padding: 0 0 8px;
}

.scroll-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 16px 12px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.scroll-card{
  flex:0 0 150px;
  width:180px;
  min-width:180px;
  max-width:180px;
  scroll-snap-align:start;
  cursor:pointer;
  transition:transform var(--transition-fast);
}

.scroll-card:active {
  transform: scale(0.97);
}

.scroll-card-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}

.scroll-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scroll-card-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 8px;
  font-weight: 500;
}

.scroll-card-info{
  height:72px;
  padding:8px 2px 0;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
}

.scroll-card-info .book-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.scroll-card-info .book-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scroll-card-info .availability {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
}

/* === Browse Library Grid === */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 0 16px 16px;
}

.grid-card {
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.grid-card:active {
  transform: scale(0.97);
}

.grid-card-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}

.grid-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid-card-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 12px;
  font-weight: 500;
}

.grid-card-info{
  height:80px;
  padding:8px 0 0;
  display:flex;
  flex-direction:column;
}

.grid-card-info .book-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.grid-card-info .book-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.grid-card-info .availability {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* === Category Grid (3 columns) === */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 16px 16px;
}

.category-grid .grid-card-cover {
  border-radius: var(--radius-md);
}

.category-grid .grid-card-info .book-title {
  font-size: 12px;
}

/* === Reference List === */
.reference-list {
  padding: 0 16px;
}

.reference-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.reference-item:active {
  opacity: 0.7;
}

.reference-item-cover {
  width: 80px;
  height: 110px;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reference-item-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-item-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
  padding: 6px;
}

.reference-item-info .book-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.reference-item-info .book-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 12px;
}

.filter-label {
  font-size: 13px;
  color: var(--accent-red);
  font-weight: 600;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.filter-btn:active {
  background: var(--bg-surface);
}

.filter-btn i {
  font-size: 16px;
}

/* === Filter Modal === */
.filter-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 250;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.filter-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.filter-modal {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 60vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 16px;
  z-index: 260;
  transform: translateY(100%);
  transition: transform var(--transition-normal);
  overflow-y: auto;
  pointer-events: none;
  visibility: hidden;
}

.filter-modal.active {
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.filter-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.filter-modal-title {
  font-size: 18px;
  font-weight: 700;
}

.filter-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 20px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  padding: 8px 16px;
  border-radius: var(--radius-pill, 9999px);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.filter-chip.active {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: var(--text-primary);
}

.filter-chip:active {
  opacity: 0.8;
}

/* === View All Button === */
.view-all-container {
  padding: 8px 16px 24px;
  display: flex;
  justify-content: center;
}

.btn-view-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-view-all:active {
  background: var(--bg-secondary);
  transform: scale(0.97);
}

/* === Book Detail Page === */
.detail-hero {
  width: 100%;
  height: 300px;
  background: linear-gradient(145deg, #1a1a1a, #2a2a2a);
  position: relative;
  overflow: hidden;
}

.detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.5;
}

.detail-hero-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, var(--bg-primary), transparent);
}

.detail-back-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 20px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.detail-info-card {
  display: flex;
  gap: 16px;
  padding: 0 16px;
  margin-top: -60px;
  position: relative;
  z-index: 5;
}

.detail-cover {
  width: 100px;
  height: 140px;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.detail-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
  padding: 6px;
}

.detail-text {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 4px;
}

.detail-text .book-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.detail-text .availability {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}

/* === Action Buttons === */
.detail-actions {
  display: flex;
  gap: 12px;
  padding: 20px 16px;
}

.btn-reserve {
  flex: 1;
  padding: 14px 20px;
  background: var(--accent-red);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-reserve:active {
  background: var(--accent-hover);
  transform: scale(0.97);
}

.btn-reserve.disabled {
  background: var(--bg-surface);
  color: var(--text-muted);
  pointer-events: none;
}

.btn-download {
  flex: 1;
  padding: 14px 20px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition-fast);
}

.btn-download:active {
  background: var(--bg-surface);
}

/* === Detail Sections === */
.detail-section {
  padding: 16px 16px 0;
}

.detail-section-label {
  font-size: 14px;
  font-weight: 700;
  color: #4a90d9;
  margin-bottom: 6px;
  position: relative;
  display: inline-block;
}

.detail-section-label::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #4a90d9;
  border-radius: 1px;
}

.detail-section-value {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 8px;
}

.detail-section-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.detail-section-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.detail-copies-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-red);
}

.detail-copies-value {
  color: var(--accent-red);
  font-weight: 700;
}

/* === Search Overlay === */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  visibility: hidden;
}

.search-overlay.active {
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.search-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 20px;
  flex-shrink: 0;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 0 12px;
  height: 42px;
}

.search-input-wrap i {
  color: var(--text-muted);
  font-size: 18px;
}

.search-input {
  flex: 1;
  height: 100%;
  color: var(--text-primary);
  font-size: 15px;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.search-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.search-empty i {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-result-item:active {
  background: var(--bg-surface);
}

.search-result-cover {
  width: 50px;
  height: 70px;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-result-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-result-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 8px;
  text-align: center;
  padding: 2px;
}

.search-result-info .book-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-info .book-title .highlight {
  background: rgba(211, 47, 47, 0.3);
  color: var(--accent-red);
  border-radius: 2px;
  padding: 0 1px;
}

.search-result-info .book-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.search-result-info .availability {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* === Reservation Modal === */
.reservation-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 250;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.reservation-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.reservation-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 400px;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all var(--transition-normal);
}

.reservation-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.reservation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.reservation-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reservation-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.reservation-brand-logo i {
  font-size: 14px;
  color: var(--accent-red);
}

.reservation-brand-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.reservation-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 700;
}

.reservation-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

.reservation-book-info {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.reservation-book-cover {
  width: 80px;
  height: 110px;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.reservation-book-cover .placeholder-text {
  color: var(--text-muted);
  font-size: 9px;
  text-align: center;
  padding: 4px;
}

.reservation-book-text .book-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.reservation-book-text .book-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.reservation-book-text .availability {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
}

.reservation-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 42px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition-fast);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  border-color: var(--accent-red);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.reservation-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
}

.btn-submit-reservation {
  width: 100%;
  padding: 14px;
  background: var(--accent-red);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius-md);
  margin-top: 8px;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-submit-reservation:active {
  background: var(--accent-hover);
  transform: scale(0.98);
}

/* === Support Page === */
.support-content {
  padding: 24px 16px;
}

.support-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

.support-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.support-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* === Animations === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeInUp 0.4s ease forwards;
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }

/* === Toast / Notification === */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 400;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--accent-red);
}

/* === Media Queries === */
/* === Uniform Grid & Card Aspect-Ratios === */

/* Standardize card layout styling inside grids */
.grid-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform var(--transition-fast);
}

/* Force image container to render as a perfect 2:3 physical shape */
.grid-card-cover, .category-grid .grid-card-cover {
  width: 100%;
  aspect-ratio: 2 / 3 !important;
  position: relative;
  background: linear-gradient(145deg, #2a2a2a, #383838);
  overflow: hidden;
}

.grid-card-cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Crops the book covers elegantly instead of stretching them */
}

/* Make sure text boxes are identical heights across all cards */
.grid-card-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Clamp titles to exactly 2 lines so long titles never break your layout rows */
.grid-card-info .book-title,
.category-grid .grid-card-info .book-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 34px; /* Reserves identical height space */
}

.grid-card-info .book-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive Grid Adapters for Fiction/Non-Fiction pages */
.browse-grid, .category-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
  gap: 16px !important;
  padding: 16px;
  width: 100%;
}

@media (min-width: 600px) {
  .browse-grid, .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  }
}

@media (min-width: 900px) {
  .browse-grid, .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)) !important;
    gap: 24px !important;
  }
}

/* === Responsive Layout Framework === */
@media (min-width: 1024px) {
  /* Let the body span the full screen, with a centered wrapper constraint */
  body {
    max-width: 100%;
    margin: 0;
    border: none;
  }

  /* Constraint structural elements to a clean, readable desktop width */
  .site-header, 
  #app-content, 
  .bottom-nav, 
  .search-overlay, 
  .reservation-backdrop {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
  }
  
  /* Make sure floating navigation bars don't stretch weirdly on wide monitors */
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .site-header {
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
}

/* === Loading Skeleton === */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, #2e2e2e 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   MHSS E-Library - Global Loading & Error Framework Layouts
   ============================================================ */

/* Full-Screen Initialization Layout */
#library-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.library-loader-content {
  text-align: center;
}

/* Spinner Core Definition Elements */
.library-loader-content .spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #d9383a; /* Match Motithang Crimson Accent Color */
  border-radius: 50%;
  margin: 0 auto 20px auto;
  animation: librarySpin 1s linear infinite;
}

.library-loader-content p {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
  margin: 0 0 4px 0;
}

.library-loader-content small {
  font-size: 13px;
  color: #7f8c8d;
}

/* Fallback/Timeout Error Containers */
.critical-error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 40px 20px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.critical-error-container h2 {
  font-size: 22px;
  font-weight: 700;
  color: #2c3e50;
  margin: 16px 0 8px 0;
}

.critical-error-container p {
  font-size: 15px;
  color: #667788;
  max-width: 400px;
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background-color: #d9383a;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-retry:hover {
  background-color: #b82e30;
}

@keyframes librarySpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Status Overlay Screens */
.status-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.status-modal-backdrop.active {
  opacity: 1;
}
.status-modal-box {
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 32px 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transform: scale(0.9);
  transition: transform 0.25s ease;
}
.status-modal-box.active {
  transform: scale(1);
}

/* Processing Reservation Spinner Overlay */
#processing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 18, 18, 0.85); /* Dark opaque backdrop */
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000; /* Stays above the reservation modal and header */
}

.processing-loader-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.processing-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid #d9383a; /* Your target red brand color */
  border-radius: 50%;
  animation: processingSpin 0.9s linear infinite;
}

@keyframes processingSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Page Transition Loading Overlay */
#page-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(18, 18, 18, 0.85); /* Matches processing backdrop */
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000; /* Extremely high index to cover all content during rendering */
}

/* ==========================================
   E-LIBRARY LOADING OVERLAY & CSS BOOK STACK
   ========================================== */
#library-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff; /* Smooth, clean fallback */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#library-loading-overlay.fade-out-overlay {
  opacity: 0;
  visibility: hidden;
}

.library-loader-content {
  text-align: center;
}

/* 1:1 Vector Book Stack Container */
.book-stack-animation {
  width: 140px;
  height: 140px;
  margin: 0 auto 24px auto;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.animated-book {
  width: 110px;
  height: auto;
  margin: -6px 0; /* Keeps them stacked tightly together */
  transform-origin: center center;
}

/* Recreating the Video Keyframe Offsets */
.top-book {
  animation: topBookLoop 2s ease-in-out infinite;
}

.middle-book {
  animation: middleBookLoop 2s ease-in-out infinite;
}

.bottom-book {
  animation: bottomBookLoop 2s ease-in-out infinite;
}

@keyframes topBookLoop {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  33% {
    transform: translate(-4px, 1px) rotate(-1.5deg) scale(0.98);
  }
  66% {
    transform: translate(3px, -1px) rotate(1deg) scale(1.02);
  }
}

@keyframes middleBookLoop {
  0%, 100% {
    transform: translate(0, 0) rotate(2deg) scale(1);
  }
  33% {
    transform: translate(5px, -1px) rotate(-3.5deg) scale(0.99);
  }
  66% {
    transform: translate(-3px, 1px) rotate(5deg) scale(1.01);
  }
}

@keyframes bottomBookLoop {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  33% {
    transform: translate(-1px, -2px) rotate(1deg) scale(1.01);
  }
  66% {
    transform: translate(2px, 0) rotate(-1deg) scale(0.99);
  }
}

/* Text and Transition Styling */
#library-loading-overlay p {
  font-family: 'Inter', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #121212;
  margin: 0 0 6px 0;
  transition: opacity 0.25s ease-in-out, transform 0.25s ease-in-out;
}

#library-loading-overlay p.phrase-fade-out {
  opacity: 0;
  transform: translateY(-5px);
}

#library-loading-overlay small {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #888888;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}