/* ropds — modern clean theme */

:root {
  --ropds-accent: #4a90d9;
  --ropds-accent-hover: #3a7bc8;
}

[data-bs-theme="dark"] {
  --ropds-accent: #6ba3e0;
  --ropds-accent-hover: #8ab8ea;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* Navbar */
.navbar > .container {
  flex-wrap: wrap;
}

.navbar-brand img {
  height: 32px;
  width: 32px;
  margin-right: 0.5rem;
}

.navbar-nav .nav-link {
  white-space: nowrap;
}

@media (max-width: 1199.98px) {
  #navMain.collapse.show {
    max-height: calc(100vh - 7rem);
    max-height: calc(100dvh - 7rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (min-width: 1200px) {
  #navMain {
    order: 2;
  }

  .navbar-search-row {
    order: 3;
    flex: 0 0 100%;
  }
}

.navbar-user-btn {
  max-width: 14rem;
  display: inline-flex;
  align-items: center;
}

.navbar-username {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 10rem;
  display: inline-block;
  vertical-align: middle;
}

#search-form {
  min-width: 0;
  flex: 1 1 0;
}

.search-type-group {
  flex-shrink: 0;
  min-width: 0;
}

.search-type-group[hidden] {
  display: none;
}

.search-type-group .btn,
.book-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-type-group .btn {
  min-height: 44px;
}

@media (max-width: 1199.98px) {
  .navbar-search-row {
    flex-wrap: wrap;
  }

  .search-type-group {
    order: 3;
    flex: 0 0 100%;
    margin-top: 0.5rem !important;
  }

  .search-type-group .btn {
    flex: 1 1 auto;
  }
}

/* Utility: allow text-truncate inside flex items */
.min-width-0 {
  min-width: 0;
}

/* Book cards */
.book-card {
  transition: box-shadow 0.15s ease;
}
.book-card:hover {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
}

.book-cover {
  width: 100px;
  min-width: 100px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.375rem;
  display: block;
}

.book-card .card-title,
.book-card .small {
  overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
  .book-card .card-body {
    padding: 0.75rem;
  }

  .book-card .card-title {
    font-size: 1.05rem;
    line-height: 1.35;
  }

  .book-cover {
    width: 80px;
    min-width: 80px;
  }
}

.book-cover-sm {
  width: 60px;
  min-width: 60px;
  height: auto;
  object-fit: cover;
  align-self: flex-start;
  display: block;
}

.book-cover-compact {
  width: 70px;
  min-width: 70px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.375rem;
  display: block;
}

.random-book .small {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Reading progress chip + bar on cards */
.read-progress {
  max-width: 170px;
}

.read-progress--compact {
  max-width: 130px;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.book-actions .bookshelf-action-form {
  display: inline-flex;
  margin: 0;
}

.btn-icon {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.book-actions .btn {
  min-height: 44px;
}

.navbar-nav .nav-link,
.navbar .dropdown-item {
  min-height: 44px;
  display: flex;
  align-items: center;
}

@media (prefers-reduced-motion: reduce) {
  .book-card {
    transition: none;
  }
}

/* Alphabet browse grid */
.prefix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
}

.prefix-item {
  text-align: center;
  padding: 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color);
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.prefix-item:hover {
  background-color: var(--bs-tertiary-bg);
}

/* Genre list */
.genre-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}
.genre-item:last-child {
  border-bottom: none;
}

/* Genre badges on book cards.
   Bootstrap's .badge sets white-space: nowrap, so a long genre name renders
   as one unbreakable box that overflows the card and forces horizontal page
   scrolling on narrow screens. Let the text wrap inside the badge instead. */
.book-genres-badges .badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: start;
  vertical-align: middle;
  margin-bottom: 0.25rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--bs-border-color);
}

/* Language selector */
.lang-selector .btn {
  font-size: 0.85rem;
}

/* Catalog icons */
.catalog-icon {
  width: 24px;
  height: 24px;
  opacity: 0.6;
}

/* Cover preview */
.cover-preview {
  cursor: pointer;
  display: block;
}

.cover-preview:focus-visible {
  outline: 2px solid var(--bs-focus-ring-color);
  outline-offset: 3px;
}

.cover-dialog {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  max-height: 90dvh;
  padding: 3rem 1rem 1rem;
  border: 0;
  background: transparent;
  overflow: visible;
}

.cover-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.cover-dialog img {
  display: block;
  max-width: calc(90vw - 2rem);
  max-height: calc(90vh - 4rem);
  max-height: calc(90dvh - 4rem);
  object-fit: contain;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.4);
}

.cover-dialog-close {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--bs-body-bg);
  border-radius: 50%;
}

.cover-dialog-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

.ui-status-alert {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  z-index: 1080;
  width: max-content;
  max-width: calc(100vw - 2rem);
  margin: 0;
  transform: translateX(-50%);
}

/* Search dropdown */
.search-type-group .btn-check:checked + .btn {
  background-color: var(--ropds-accent);
  border-color: var(--ropds-accent);
  color: #fff;
}

/* OAuth buttons on login page */
.oauth-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.oauth-login-content {
  width: 100%;
  display: grid;
  grid-template-columns: 20px 1fr 20px;
  align-items: center;
  gap: 0.5rem;
}

.oauth-login-icon-wrap {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.oauth-login-icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.oauth-login-fallback-icon {
  font-size: 18px;
  line-height: 1;
}

.oauth-login-label {
  line-height: 1.2;
  text-align: center;
}

.oauth-login-spacer {
  width: 20px;
  height: 20px;
  display: inline-block;
}
