/* ==========================================================================
   Twibbon — dipakai bersama oleh panel admin (Bootstrap 4 + Stisla)
   dan halaman publik (tema frontend2).

   Semua selector diberi awalan `.tw-` supaya tidak bertabrakan dengan
   aturan global tema (fe2/css/style.css mengatur .btn, img, canvas, dll).
   Token warna diambil dari tema situs: aksen #ff4800, muted #738097,
   garis #ebebeb.
   ========================================================================== */

.tw-scope {
  --tw-accent: #ff4800;
  --tw-accent-dark: #d93c00;
  --tw-accent-soft: #fff1eb;
  --tw-ink: #2c3345;
  --tw-muted: #738097;
  --tw-line: #ebebeb;
  --tw-surface: #ffffff;
  --tw-bg: #f7f8fa;
  --tw-radius: 14px;
  --tw-radius-sm: 9px;
}

/* --------------------------------------------------------------------------
   1. Papan catur — latar untuk menampilkan transparansi PNG
   -------------------------------------------------------------------------- */

.tw-checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e4e8ee 25%, transparent 25%, transparent 75%, #e4e8ee 75%),
    linear-gradient(45deg, #e4e8ee 25%, transparent 25%, transparent 75%, #e4e8ee 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

/* --------------------------------------------------------------------------
   2. Thumbnail di tabel admin
   -------------------------------------------------------------------------- */

.tw-thumb {
  width: 84px;
  height: 84px;
  object-fit: contain;
  display: block;
  border: 1px solid var(--tw-line, #ebebeb);
  border-radius: 8px;
}

.tw-thumb-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b6bcc8;
  font-size: 20px;
  background: #f3f5f8;
}

/* --------------------------------------------------------------------------
   3. Halaman publik — kepala halaman & filter
   -------------------------------------------------------------------------- */

.tw-intro {
  margin-bottom: 26px;
}

.tw-intro h3 {
  color: #2c3345;
  font-weight: 700;
  margin-bottom: 8px;
}

.tw-intro p {
  color: #738097;
  margin-bottom: 0;
  max-width: 680px;
}

.tw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.tw-search {
  flex: 1 1 260px;
  display: flex;
  min-width: 0;
}

.tw-search input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid #e2e6ec;
  border-right: 0;
  border-radius: 999px 0 0 999px;
  background: #fff;
  color: #2c3345;
  font-size: 15px;
}

.tw-search input:focus {
  outline: none;
  border-color: #ff4800;
  box-shadow: 0 0 0 3px rgba(255, 72, 0, 0.12);
}

.tw-search button {
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 0 999px 999px 0;
  background: #ff4800;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.tw-search button:hover {
  background: #d93c00;
}

.tw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 26px;
}

.tw-chip {
  display: inline-block;
  padding: 7px 15px;
  border: 1px solid #e2e6ec;
  border-radius: 999px;
  background: #fff;
  color: #738097;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: all 0.15s ease;
}

.tw-chip:hover {
  border-color: #ff4800;
  color: #ff4800;
  text-decoration: none;
}

.tw-chip.is-active {
  background: #ff4800;
  border-color: #ff4800;
  color: #fff;
}

/* --------------------------------------------------------------------------
   4. Halaman publik — kartu template
   -------------------------------------------------------------------------- */

.tw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 22px;
}

.tw-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.tw-card:hover {
  transform: translateY(-3px);
  border-color: #ffd0bd;
  box-shadow: 0 12px 26px rgba(44, 51, 69, 0.10);
}

.tw-card-media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-bottom: 1px solid #ebebeb;
}

.tw-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tw-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(44, 51, 69, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tw-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 15px 16px 17px;
}

.tw-card-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: #2c3345;
}

.tw-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #738097;
}

.tw-card-cta {
  margin-top: auto;
  display: block;
  padding: 10px 16px;
  border-radius: 999px;
  background: #ff4800;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.tw-card-cta:hover {
  background: #d93c00;
  color: #fff;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   5. Keadaan kosong
   -------------------------------------------------------------------------- */

.tw-empty-state {
  padding: 64px 24px;
  text-align: center;
  background: #fff;
  border: 1px dashed #d9dee7;
  border-radius: 14px;
}

.tw-empty-state i {
  font-size: 34px;
  color: #c3cad6;
  margin-bottom: 14px;
}

.tw-empty-state p {
  margin: 0;
  color: #738097;
}

/* --------------------------------------------------------------------------
   6. Halaman editor
   -------------------------------------------------------------------------- */

.tw-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 26px;
  align-items: start;
}

@media (max-width: 991px) {
  .tw-editor {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tw-stage {
  position: relative;
  padding: 16px;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 14px;
}

/* width/height auto WAJIB: satu faktor konversi koordinat pointer hanya
   valid kalau aspect ratio kanvas dipertahankan oleh CSS. */
.tw-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}

.tw-canvas:active {
  cursor: grabbing;
}

.tw-stage-overlay {
  position: absolute;
  inset: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  color: #738097;
}

.tw-stage-overlay[hidden] {
  display: none;
}

.tw-stage-overlay i {
  font-size: 30px;
  color: #ff4800;
}

.tw-stage-overlay strong {
  color: #2c3345;
  display: block;
  margin-bottom: 2px;
}

.tw-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 14px;
}

.tw-panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #2c3345;
}

.tw-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tw-field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #738097;
}

.tw-field-label span:last-child {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #2c3345;
}

.tw-panel input[type="range"] {
  width: 100%;
  accent-color: #ff4800;
  margin: 0;
}

.tw-row {
  display: flex;
  gap: 8px;
}

.tw-row > * {
  flex: 1;
}

.tw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f2f4f7;
  color: #2c3345;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tw-btn:hover {
  background: #e7ebf1;
  text-decoration: none;
  color: #2c3345;
}

.tw-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tw-btn--primary {
  background: #ff4800;
  color: #fff;
}

.tw-btn--primary:hover {
  background: #d93c00;
  color: #fff;
}

.tw-btn--outline {
  background: #fff;
  border-color: #d9dee7;
  color: #2c3345;
}

.tw-btn--outline:hover {
  border-color: #ff4800;
  color: #ff4800;
  background: #fff;
}

.tw-btn--block {
  width: 100%;
}

.tw-btn--lg {
  padding: 14px 20px;
  font-size: 15px;
}

.tw-note {
  display: flex;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 10px;
  background: #f4f7fb;
  border: 1px solid #e4ecf6;
  color: #4a5568;
  font-size: 13px;
  line-height: 1.55;
}

.tw-note i {
  color: #2684fe;
  margin-top: 2px;
}

.tw-note strong {
  color: #2c3345;
}

.tw-message {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
}

.tw-message[hidden] {
  display: none;
}

.tw-message--error {
  background: #fdecea;
  border: 1px solid #f7c8c2;
  color: #a32316;
}

.tw-message--ok {
  background: #e8f6ee;
  border: 1px solid #c3e7d3;
  color: #1c6b3f;
}

.tw-steps {
  margin: 0;
  padding-left: 19px;
  color: #738097;
  font-size: 13px;
  line-height: 1.75;
}

.tw-steps li::marker {
  color: #ff4800;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   7. Editor "Area Foto" di panel admin
   -------------------------------------------------------------------------- */

.tw-crop-wrap {
  display: grid;
  /* Kolom pratinjau dibatasi lebarnya, bukan 1fr. Tanpa batas ini kanvas
     melebar mengikuti lebar kartu dan tingginya ikut membengkak — template
     persegi 1200x1200 jadi setinggi layar dan seluruh isi form terdorong jauh
     ke bawah. */
  grid-template-columns: minmax(0, 420px) minmax(200px, 260px);
  gap: 22px;
  align-items: start;
  justify-content: start;
}

@media (max-width: 767px) {
  .tw-crop-wrap {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tw-crop-intro {
  max-width: 78ch;
}

.tw-crop-stage {
  position: relative;
  overflow: hidden;
  max-width: 420px;
  border: 1px solid #e2e6ec;
  border-radius: 10px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Pratinjau digambar di kanvas (bukan <img> + span ber-absolute) supaya
   hasilnya benar-benar mencerminkan komposisi akhir: contoh foto di belakang,
   dilubangi mengikuti alpha PNG template, lalu template digambar di atasnya. */
.tw-crop-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.tw-crop-placeholder {
  padding: 54px 20px;
  text-align: center;
  color: #738097;
  font-size: 14px;
}

.tw-crop-placeholder[hidden] {
  display: none;
}

.tw-crop-placeholder i {
  display: block;
  font-size: 26px;
  color: #c3cad6;
  margin-bottom: 10px;
}

.tw-crop-rect {
  position: absolute;
  z-index: 2;
  border: 2px dashed #ff4800;
  background: rgba(255, 72, 0, 0.10);
  cursor: move;
}

.tw-crop-rect[hidden] {
  display: none;
}

.tw-crop-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ff4800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.tw-crop-handle[data-h="nw"] { left: 0;    top: 0;    cursor: nwse-resize; }
.tw-crop-handle[data-h="ne"] { left: 100%; top: 0;    cursor: nesw-resize; }
.tw-crop-handle[data-h="sw"] { left: 0;    top: 100%; cursor: nesw-resize; }
.tw-crop-handle[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }

.tw-crop-help {
  padding-left: 18px;
  margin: 0;
  color: #738097;
  font-size: 13px;
  line-height: 1.7;
}

.tw-crop-help li::marker {
  color: #ff4800;
}

.tw-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tw-preset {
  padding: 8px 14px;
  border: 1px solid #d9dee7;
  border-radius: 999px;
  background: #fff;
  color: #2c3345;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tw-preset:hover {
  border-color: #ff4800;
  color: #ff4800;
}

/* Nilai area aktif — ditampilkan supaya admin tahu angka yang akan tersimpan */
.tw-area-readout {
  margin-top: 12px;
  font-size: 12px;
  color: #738097;
  font-family: SFMono-Regular, Menlo, Consolas, monospace;
}
