/* ============================================================
   Test a Book modal (admin index page only)

   index.html does not load raw_book/css/style.css, so the few
   generic helpers the books modal relies on (.btn, .hidden,
   .muted, form controls, overlay) are re-declared here and kept
   scoped so they cannot leak into .card-btn / .header-action-btn.
   ============================================================ */

.hidden {
  display: none !important;
}

.muted {
  font-size: 12.5px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.6);
}

/* Header: two action buttons side by side */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

/* Keep the modal out of sight while the auth check is pending */
body.auth-pending .modal,
body.auth-pending #testBookOverlay {
  visibility: hidden;
}

/* ===== Buttons (scoped to modal) ===== */
.modal .btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1;
  font-weight: 600;
  color: #fff;
  background: #007bff;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.12);
  transition:
    background 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
}

.modal .btn:hover:not(:disabled) {
  background: #0056b3;
  box-shadow: 0 12px 26px rgba(2, 6, 23, 0.16);
  transform: translateY(-1px);
}

.modal .btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.14);
}

.modal .btn:disabled {
  background: #c9ced8 !important;
  cursor: not-allowed !important;
  opacity: 0.7;
  box-shadow: none;
  transform: none;
}

.modal .btn.secondary-btn {
  background: #eef2ff;
  color: #2b2f66;
  border: 1px solid rgba(67, 56, 202, 0.25);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.06);
}

.modal .btn.secondary-btn:hover:not(:disabled) {
  background: #e0e7ff;
}

.modal .btn.cancel-btn {
  background: #ff0000;
  color: #fff;
}

.modal .btn.cancel-btn:hover:not(:disabled) {
  background: #d70000;
}

.modal .btn.primary-btn {
  background: #16a34a;
}

.modal .btn.primary-btn:hover:not(:disabled) {
  background: #15803d;
}

/* ===== Form controls (scoped to modal) ===== */
.modal input[type="text"],
.modal select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text, #0f172a);
  background: #fff;
}

.modal input[type="text"]:focus,
.modal select:focus {
  outline: none;
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

/* Manual book id row, right under the search row */
.modal-manual {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.modal-manual input[type="text"] {
  width: 100%;
  min-width: 0;
}

#testBookList {
  max-height: 46vh;
}

/* ===== Detail view ===== */
.tb-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.tb-detail {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.02);
}

.tb-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tb-detail-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  color: rgba(15, 23, 42, 0.92);
  min-width: 0;
}

.tb-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tb-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 5px 9px;
  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);
}

.tb-chip.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

.tb-chip.off {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.tb-id-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.55);
}

.tb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin-top: 14px;
}

.tb-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  min-width: 0;
}

.tb-k {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.5);
}

.tb-v {
  font-size: 13px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.88);
  word-break: break-word;
}

.tb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.tb-hint {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.55);
}

.tb-hint.warn {
  color: #b45309;
}

/* ===== Overlay ===== */
#testBookOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

#testBookOverlay.hidden {
  display: none !important;
}

#testBookOverlay .overlay-content {
  background: #fff;
  padding: 20px 26px;
  border-radius: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#testBookOverlay .overlay-content p {
  margin: 0;
}

@media (max-width: 720px) {
  .header-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .modal-manual {
    grid-template-columns: 1fr;
  }

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

  .tb-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}
