/* ============================================================
   OVERLAY
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.hidden {
  display: none !important;
}

/* ============================================================
   MODAL - CARD PADRÃO
   ============================================================ */
.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: min(720px, 95%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

/* ============================================================
   HEADER
   ============================================================ */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text);
  cursor: pointer;
}

/* ============================================================
   DESCRIÇÃO
   ============================================================ */
.modal-desc {
  margin-top: 8px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
}

/* ============================================================
   GRID DE CAMPOS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full {
  grid-column: span 3;
}

.form-group label {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--muted);
}

/* Inputs e selects */
.form-group input,
.form-group select,
.form-group textarea {
  background: #1b1230;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}

.thumb-status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.thumb-btn {
  margin-top: 8px;
  background: #6f55b6;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  color: white;
  cursor: pointer;
  width: fit-content;
}

.thumb-preview {
  margin-top: 12px;
  background: #140f22;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  position: relative;
}

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

.thumb-loading {
  opacity: 0.75;
}

.thumb-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: rgba(255,255,255,0.8);
  border-radius: 50%;
  animation: thumb-spin 0.8s linear infinite;
  position: absolute;
  z-index: 2;
}

@keyframes thumb-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Textarea grande */
#pub_content {
  min-height: 200px;
  max-height: 350px;
  resize: vertical;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.45;
}

/* ============================================
   AUTOR — COMBOBOX ESTILO RETOOL
   ============================================ */

.combo-wrapper {
  position: relative;
  width: 100%;
}

#pub_author_search {
  width: 100%;
  background: #1b1230;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}

.combo-list {
  position: absolute;
  top: 42px;
  left: 0;
  width: 100%;
  background: #1b1230;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 3000;
  box-shadow: 0 12px 24px rgba(0,0,0,0.4);
}

.combo-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text);
}

.combo-item:hover {
  background: rgba(255,255,255,0.08);
}

.combo-list.hidden {
  display: none;
}


/* ============================================================
   FOOTER
   ============================================================ */
.modal-footer {
  margin-top: 30px;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}

.btn-cancel {
  background: #6c6380;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  color: white;
  cursor: pointer;
}

.btn-send {
  background: #36c66a;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  color: white;
  cursor: pointer;
}

.btn-cancel:hover,
.btn-send:hover {
  opacity: 1;
}

.btn-cancel:hover {
  background: #5213b9;
}

/* ============================================================
   MODAL IA — LISTA E PREVIEW
   ============================================================ */
.txt-item {
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.txt-item:hover {
  background: #2a1f42;
}

.txt-item.selected {
  background: var(--accent);
  color: white;
}

#txtPreview {
  background: #1b1230;
  padding: 16px;
  border-radius: 8px;
  max-height: 350px;
  overflow-y: auto;
  overflow-x: hidden;        /* 🔥 evita scroll horizontal */
  white-space: pre-wrap;     /* 🔥 mantém quebras */
  word-break: break-word;    /* 🔥 linhas longas quebram */
  line-height: 1.45;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.06);
}
