/* Wiley-style Insert Reference / Citation / How to cite modal */

.ref-insert-overlay {
  position: fixed;
  inset: 0;
  z-index: 10100;
  background: rgba(0, 40, 60, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ref-insert-panel {
  width: 100%;
  max-width: 720px;
  max-height: min(90vh, 640px);
  background: #fff;
  border: 1px solid #b8c5ce;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  font-family: "Open Sans", system-ui, sans-serif;
}

.ref-insert-tabs {
  display: flex;
  align-items: stretch;
  background: #e8ecef;
  border-bottom: 1px solid #b8c5ce;
  flex-shrink: 0;
}

.ref-insert-tab {
  flex: 1;
  border: none;
  background: #d0d8de;
  color: #1c1d1e;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  border-right: 1px solid #b8c5ce;
}

.ref-insert-tab:hover {
  background: #c5d0d8;
}

.ref-insert-tab.active {
  background: #005274;
  color: #fff;
}

.ref-insert-close {
  flex: 0 0 44px;
  border: none;
  background: #d0d8de;
  font-size: 20px;
  cursor: pointer;
  color: #333;
}

.ref-insert-close:hover {
  background: #c5d0d8;
}

.ref-insert-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 280px;
}

.ref-insert-panel-inner {
  display: none;
}

.ref-insert-panel-inner.active {
  display: block;
}

/* —— Insert Reference tab —— */
.ref-doi-row {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
}

.ref-doi-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #adb5bd;
  border-right: none;
  font-size: 14px;
}

.ref-doi-search {
  width: 44px;
  border: 1px solid #005274;
  background: #005274;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
}

.ref-doi-search:hover {
  background: #003d56;
}

.ref-manual-text {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid #adb5bd;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.ref-year-input {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #adb5bd;
  font-size: 14px;
  box-sizing: border-box;
}

.ref-doi-preview {
  margin-top: 10px;
  font-size: 12px;
  color: #495057;
  line-height: 1.45;
  max-height: 80px;
  overflow-y: auto;
}

.ref-doi-preview.error {
  color: #c62828;
}

/* —— Bibliography preview (Insert Reference tab) —— */
.ref-bibliography-section {
  margin-bottom: 16px;
}

.ref-bibliography-heading {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #005274;
}

.ref-bibliography-list {
  border: 1px solid #dee2e6;
  max-height: 160px;
  overflow-y: auto;
  background: #fafbfc;
}

.ref-bibliography-item {
  padding: 8px 12px;
  border-bottom: 1px solid #e9ecef;
  font-size: 12px;
  line-height: 1.4;
}

.ref-bibliography-item:last-child {
  border-bottom: none;
}

.ref-bibliography-cite {
  display: block;
  font-weight: 600;
  color: #005274;
  margin-bottom: 2px;
}

.ref-bibliography-text {
  color: #495057;
}

.ref-bibliography-empty {
  padding: 12px;
  font-size: 12px;
  color: #6c757d;
  text-align: center;
}

/* —— Insert Citation tab —— */
.ref-cite-types {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 14px;
  font-size: 13px;
}

.ref-cite-types label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 500;
}

.ref-cite-search-row {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.ref-cite-search {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #adb5bd;
  border-right: none;
  font-size: 14px;
}

.ref-cite-search-btn {
  width: 44px;
  border: 1px solid #005274;
  background: #005274;
  color: #fff;
  cursor: pointer;
}

.ref-cite-list {
  border: 1px solid #dee2e6;
  max-height: 220px;
  overflow-y: auto;
  background: #fafbfc;
}

.ref-cite-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e9ecef;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
}

.ref-cite-item:hover {
  background: #e8f4f8;
}

.ref-cite-item:last-child {
  border-bottom: none;
}

.ref-cite-item input {
  margin-top: 3px;
  flex-shrink: 0;
}

.ref-cite-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ref-cite-apa {
  color: #005274;
  font-size: 13px;
}

.ref-cite-meta {
  font-size: 12px;
  color: #6c757d;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ref-cite-empty {
  padding: 24px;
  text-align: center;
  color: #6c757d;
  font-size: 13px;
}

/* —— How to cite —— */
.ref-how-cite-text {
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
}

.ref-how-cite-copy {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  border: 1px solid #adb5bd;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.ref-insert-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #dee2e6;
  background: #f5f8fa;
  flex-shrink: 0;
}

.ref-insert-btn {
  min-width: 88px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  background: #005274;
  color: #fff;
}

.ref-insert-btn:hover {
  background: #003d56;
}

.ref-insert-btn--ghost {
  background: #005274;
}
