/* ===== Books Modal ===== */
.modal.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
}

.modal-card {
  position: relative;
  width: min(860px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(720px, calc(100vh - 24px));
  margin: 12px auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.modal-card * {
  box-sizing: border-box;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-title {
  font-weight: 900;
  font-size: 16px;
  color: rgba(15, 23, 42, 0.92);
}

.modal-sub {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.6);
}

.modal-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.modal-tools input[type="text"] {
  width: 100%;
  min-width: 0;
}

.modal-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr)) minmax(150px, 1fr) minmax(110px, 0.7fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.modal-filters select,
.modal-filters input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 40px;
}

.books-list {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
}

.book-row {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.book-row:last-child {
  border-bottom: 0;
}

.book-row:hover {
  background: rgba(15, 23, 42, 0.04);
}

.book-main {
  min-width: 0;
  flex: 1;
}

.book-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.book-title {
  text-align: left;
  font-weight: 700;
  font-size: 18px;
  color: rgba(15, 23, 42, 0.92);
  line-height: 1.15;
  margin-bottom: 4px;
}

.book-lang-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 12px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  color: rgba(15, 23, 42, 0.78);
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.book-id-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.55);
  user-select: text;
}

.book-id-copy {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.82);
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 6px;
  padding: 2px 6px;
  user-select: text;
  cursor: text;
}

.book-copy-btn {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.04);
  color: rgba(15, 23, 42, 0.7);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0px;
}

.book-copy-btn:hover {
  background: rgba(15, 23, 42, 0.08);
  color: rgba(15, 23, 42, 0.95);
}

.book-meta {
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.58);
  margin-top: 5px;
  line-height: 1.35;
}

.book-right {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 34px;
}

.badge-small {
  font-size: 11px;
  font-weight: 900;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(15, 23, 42, 0.03);
}

.badge-small.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.badge-small.off {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.books-toast {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.books-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.card-head-row {
  display: flex;
  align-items: start;
  justify-content: left;
  gap: 20px;
  margin-bottom: 4px;
}

.card-head-row h2 {
  margin: 10px 0 0;
}

.card-head-row button {
  margin-top: 0;
}

@media (max-width: 900px) {
  .modal-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .modal-card {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    margin: 8px auto;
    padding: 12px;
  }

  .modal-tools {
    grid-template-columns: 1fr;
  }

  .modal-filters {
    grid-template-columns: 1fr;
  }

  .book-row {
    align-items: flex-start;
  }

  .book-right {
    padding-top: 2px;
  }

  .book-title {
    font-size: 20px;
  }
}
