/*
 * Panel "Riwayat & komentar": laci dari kanan seperti buku catatan.
 * Gaya Ruang Penulis: hijau hutan, kuning kertas, kertas bergaris.
 */

/* Tombol kecil di samping tautan unduhan dokumen */
.rp-thread-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 0 8px;
  padding: 4px 11px;
  border: 1px solid var(--rpx-leaf-line, #d5e4cb);
  border-radius: 999px;
  background: var(--rpx-leaf, #eef4e5);
  color: var(--rpx-green, #174c39);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.5;
  vertical-align: middle;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.rp-thread-chip::before {
  content: '';
  width: 12px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23174c39' stroke-width='2.2'%3E%3Cpath d='M5 5h14a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-8l-4 3v-3H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.rp-thread-chip:hover {
  border-color: #ffce0c;
  background: #fff6cf;
}

/* Laci */
.rp-thread {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  justify-content: flex-end;
  font-family: inherit;
}

.rp-thread-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 52, 37, 0.45);
  animation: rp-thread-fade 0.2s ease-out;
}

.rp-thread-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  height: 100%;
  background: #fbfcf4;
  box-shadow: -18px 0 50px rgba(14, 52, 37, 0.28);
  animation: rp-thread-slide 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rp-thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background:
    radial-gradient(circle at 12px 12px, rgba(255, 206, 12, 0.22) 1.5px, transparent 2px) 0 0 / 24px 24px,
    linear-gradient(135deg, #0e3425, #174c39 60%, #1f5e47);
  color: #fff;
}

.rp-thread-head > div {
  flex: 1;
  min-width: 0;
}

.rp-thread-head small {
  display: block;
  color: #ffce0c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rp-thread-head h2 {
  margin: 3px 0 0;
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.rp-thread-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s;
}

.rp-thread-close:hover {
  transform: rotate(90deg);
}

/* Versi */
.rp-thread-versions {
  display: flex;
  gap: 8px;
  padding: 12px 18px 4px;
  overflow-x: auto;
}

.rp-thread-versions button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1.5px dashed #9fbe8d;
  border-radius: 999px;
  background: #eef4e5;
  color: #174c39;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.rp-thread-versions button.on {
  border: 1.5px solid #0e3425;
  background: #174c39;
  color: #fff;
  box-shadow: 0 3px 0 #0e3425;
}

.rp-thread-versions i {
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ffce0c;
  color: #174c39;
  font-size: 10px;
  font-style: normal;
}

/* Kartu file */
.rp-thread-file {
  padding: 12px 18px 8px;
}

.rp-thread-photo {
  display: block;
  margin-bottom: 10px;
  padding: 6px;
  border-radius: 10px;
  background: #fff;
  line-height: 0;
  box-shadow: 0 6px 14px rgba(23, 76, 57, 0.16);
  transform: rotate(-0.6deg);
}

.rp-thread-photo img {
  width: 100%;
  max-height: 190px;
  border-radius: 6px;
  object-fit: contain;
  background: #eef4e5;
}

.rp-thread-download {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #d5e4cb;
  border-radius: 14px;
  background: #fff;
  color: #174c39;
  text-decoration: none;
  box-shadow: 0 2px 0 rgba(23, 76, 57, 0.06);
}

.rp-thread-download:hover {
  border-color: #ffce0c;
}

.rp-thread-download .rp-file-badge {
  width: 38px;
  height: 46px;
  border-radius: 6px;
  font-size: 9px;
}

.rp-thread-download > span:not(.rp-file-arrow) {
  flex: 1;
  min-width: 0;
}

.rp-thread-download strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.rp-thread-download small {
  display: block;
  margin-top: 3px;
  color: #5f735a;
  font-size: 11px;
}

/* Komentar di atas kertas bergaris */
.rp-thread-comments {
  flex: 1;
  min-height: 120px;
  padding: 14px 18px;
  overflow-y: auto;
  background-color: #fbfcf4;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 27px, #e7eedb 27px, #e7eedb 28px);
  background-attachment: local;
}

.rp-thread-comment {
  max-width: 92%;
  margin: 0 auto 12px 0;
  padding: 10px 13px;
  border: 1px solid #d5e4cb;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(23, 76, 57, 0.07);
}

.rp-thread-comment.mine {
  margin: 0 0 12px auto;
  border-color: #f0d96b;
  border-radius: 16px 16px 5px 16px;
  background: #fff6cf;
}

.rp-thread-comment.staff:not(.mine) {
  border-left: 4px solid #174c39;
}

.rp-thread-comment header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.rp-thread-comment header strong {
  color: #174c39;
  font-size: 12.5px;
}

.rp-thread-comment header span {
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef4e5;
  color: #174c39;
  font-size: 10px;
  font-weight: 800;
}

.rp-thread-comment header time {
  margin-left: auto;
  color: #5f735a;
  font-size: 10.5px;
}

.rp-thread-comment p {
  margin: 6px 0 8px;
  color: #1d3b2c;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.rp-thread-comment button {
  padding: 3px 10px;
  border: 1px solid #d5e4cb;
  border-radius: 999px;
  background: #fff;
  color: #174c39;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.rp-thread-comment button:hover {
  border-color: #ffce0c;
  background: #fff6cf;
}

.rp-thread-comment.done {
  opacity: 0.72;
}

.rp-thread-comment.done button {
  border-color: #9fbe8d;
  background: #eef4e5;
}

.rp-thread-empty {
  padding: 28px 10px;
  color: #5f735a;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

/* Tulis komentar */
.rp-thread-compose {
  padding: 12px 18px 18px;
  border-top: 1px solid #e7efdf;
  background: #fff;
}

.rp-thread-compose label {
  display: block;
  margin-bottom: 6px;
  color: #5f735a;
  font-size: 11px;
}

.rp-thread-compose textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d5e4cb;
  border-radius: 14px;
  background: #fcfdfa;
  color: #1d3b2c;
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.rp-thread-compose textarea:focus {
  border-color: #174c39;
  box-shadow: 0 0 0 3px rgba(255, 206, 12, 0.45);
  outline: none;
}

.rp-thread-error {
  margin: 8px 0 0;
  color: #8e1f1f;
  font-size: 12px;
  font-weight: 700;
}

.rp-thread-send {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 1px solid #0e3425;
  border-radius: 13px;
  background: linear-gradient(180deg, #1f5e47, #174c39);
  color: #fff;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 3px 0 #0e3425;
  cursor: pointer;
  transition:
    transform 0.16s,
    box-shadow 0.16s;
}

.rp-thread-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #0e3425;
}

.rp-thread-send:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0e3425;
}

.rp-thread-send:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: default;
}

@keyframes rp-thread-slide {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes rp-thread-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rp-thread-panel,
  .rp-thread-backdrop,
  .rp-thread-close,
  .rp-thread-send {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 650px) {
  .rp-thread-panel {
    width: 100vw;
  }
}
