/* ===== KARSA — komponen: tombol, modal, toast, menu konteks ===== */

/* --- Tombol --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124, 92, 255, .35);
}
.btn-primary:hover { box-shadow: 0 6px 22px rgba(124, 92, 255, .5); }

.btn-ghost {
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: var(--radius); }

.btn-run {
  background: var(--grad-success);
  color: #fff;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 12px rgba(16, 185, 129, .3);
}
.btn-run:hover { filter: brightness(1.08); }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 16px;
  transition: background var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); }

.icon-btn-sm {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}
.icon-btn-sm:hover { background: var(--bg-hover); color: var(--text); }

.badge {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 99px;
}

/* --- Switch --- */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.switch-label input { display: none; }
.switch {
  width: 34px; height: 19px;
  border-radius: 99px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background var(--transition);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--transition), background var(--transition);
}
.switch-label input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.switch-label input:checked + .switch::after { transform: translateX(15px); background: #fff; }
.switch-text { font-size: 12px; color: var(--muted); font-weight: 600; }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, .6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  animation: popIn .18s ease;
}
.modal-wide { width: min(760px, calc(100vw - 32px)); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 20px;
}
.modal-desc { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.field input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.field input[type="text"]:focus { border-color: var(--accent); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; min-height: 16px; }
.modal-hint { font-size: 12px; margin-top: 10px; line-height: 1.45; }
.modal-hint.muted { color: var(--muted); }
.modal-hint a { color: var(--accent); }

.publish-slug-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-3);
}
.publish-slug-prefix {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 10px 10px 12px;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  font-family: var(--font-code);
}
.publish-slug-row input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.publish-slug-status { font-size: 12px; margin-top: 6px; min-height: 16px; }
.publish-slug-status.ok { color: #22c55e; }
.publish-slug-status.warn { color: var(--warn, #f59e0b); }
.publish-url-preview {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-code);
  margin-top: 6px;
  word-break: break-all;
}
.playstore-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.playstore-score { font-size: 18px; font-weight: 800; color: var(--accent); }
.playstore-progress {
  height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.playstore-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #14b8a6);
  border-radius: 999px;
  transition: width .35s ease;
}
.playstore-checklist {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.playstore-check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid var(--border);
}
.playstore-check-item.ok { border-color: rgba(34, 197, 94, .35); }
.playstore-check-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-2);
  flex-shrink: 0;
}
.playstore-check-item.ok .playstore-check-mark { background: rgba(34, 197, 94, .2); color: #22c55e; }
.playstore-check-text strong { display: block; font-size: 13px; margin-bottom: 2px; }
.playstore-check-hint { font-size: 11px; color: var(--muted); display: block; }
.playstore-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.publish-slug-suffix {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 12px 10px 0;
  font-family: var(--font-code);
  white-space: nowrap;
}
.publish-url-block { margin-bottom: 10px; }
.publish-url-label { font-size: 11px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 4px; }
.publish-live-url {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-code);
  font-size: 13px;
  margin-top: 0;
}
.publish-dns-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 12px;
}
.publish-dns-box strong { display: block; margin-bottom: 6px; }
.publish-dns-box code { font-family: var(--font-code); font-size: 11px; }
.modal-hint.warn { color: #f59e0b; }

/* --- Toast --- */
.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  max-width: 340px;
  animation: slideUp .2s ease;
}
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
.toast.toast-out { opacity: 0; transform: translateY(8px); transition: all .25s ease; }

/* --- Context menu --- */
.context-menu {
  position: fixed;
  z-index: 150;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  min-width: 180px;
  animation: popIn .12s ease;
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  text-align: left;
  transition: background var(--transition);
}
.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-sep { height: 1px; background: var(--border); margin: 5px 8px; }

/* --- Item riwayat versi --- */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.history-item-info strong { font-size: 13.5px; }
.history-item-meta { font-size: 12px; color: var(--muted); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; white-space: nowrap; }

/* --- Confetti --- */
.confetti-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}
.confetti-piece {
  position: absolute;
  bottom: 38%;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFly 1.25s cubic-bezier(.16, .8, .32, 1) forwards;
}
@keyframes confettiFly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
