/* Tahap 3: command palette (Ctrl+K) dan panel detail samping. Perilaku ada di js/palette.js & js/sheet.js. */

/* ---- Tombol pemicu di topbar ---- */
.cmdk-trigger {
  gap: 8px;
  padding: 0 8px 0 12px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.cmdk-trigger:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--lime) 60%, var(--line));
}

.cmdk-trigger .icon {
  width: 16px;
  height: 16px;
}

kbd {
  font: 600 10px/1 var(--font);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--muted);
}

/* Kolom "Cari di halaman ini" diringkas agar topbar tidak penuh; tetap bisa dipakai. */
@media (min-width: 761px) {
  .topbar .search {
    width: 190px;
  }
}

@media (max-width: 1150px) {
  .cmdk-trigger span,
  .cmdk-trigger kbd {
    display: none;
  }

  .cmdk-trigger {
    width: 42px;
    padding: 0;
    justify-content: center;
  }
}

/* ---- Palette ---- */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 12vh 16px 16px;
}

.cmdk[hidden] {
  display: none;
}

.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: #0d1f1659;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: wsx-fade 200ms ease-out;
}

.cmdk-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: min(560px, 76vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: var(--shadow);
  animation: wsx-pop 300ms var(--ease-out);
}

.cmdk.is-closing .cmdk-panel {
  animation: wsx-cmdk-out 160ms ease-in forwards;
}

.cmdk.is-closing .cmdk-backdrop {
  animation: wsx-cmdk-fade-out 160ms ease-in forwards;
}

@keyframes wsx-cmdk-out {
  to {
    opacity: 0;
    transform: scale(0.97);
  }
}

@keyframes wsx-cmdk-fade-out {
  to {
    opacity: 0;
  }
}

.cmdk-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.cmdk-input input {
  flex: 1;
  border: 0;
  padding: 4px 0;
  background: transparent;
  font-size: 16px;
  box-shadow: none !important;
}

.cmdk-list {
  overflow-y: auto;
  padding: 8px;
  scroll-padding: 8px;
}

.cmdk-group {
  padding: 12px 10px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.cmdk-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

/* Daftar masuk berurutan hanya saat palette dibuka, tidak setiap mengetik. */
.cmdk.is-opening .cmdk-item {
  animation: wsx-rise 260ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 12ms);
}

.cmdk-item .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.cmdk-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.cmdk-hint {
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
}

.cmdk-item.is-active {
  background: color-mix(in srgb, var(--lime) 24%, transparent);
}

.cmdk-item.is-active .icon {
  color: var(--ink);
}

.cmdk-item:active:not(:disabled) {
  transform: none;
}

.cmdk-empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.cmdk-foot {
  display: flex;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.cmdk-foot kbd {
  margin-right: 3px;
}

@media (max-width: 760px) {
  .cmdk {
    padding-top: 10px;
  }

  .cmdk-foot {
    display: none;
  }
}

/* ---- Panel detail samping ---- */
/* Latar hanya diredupkan tipis agar daftar di belakang panel tetap terbaca. */
dialog.as-sheet::backdrop {
  background: #0d1f1640;
  backdrop-filter: blur(1px);
}

@media (min-width: 761px) {
  dialog.as-sheet {
    width: min(600px, 92vw);
    height: calc(100vh - 24px);
    max-height: none;
    margin: 12px 12px 12px auto;
    border-radius: 22px;
    overflow-y: auto;
  }

  dialog.as-sheet[open] {
    animation: wsx-sheet 460ms var(--ease-out);
  }
}

@media (max-width: 760px) {
  dialog.as-sheet {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    overflow-y: auto;
  }

  dialog.as-sheet[open] {
    animation: wsx-sheet-up 460ms var(--ease-out);
  }
}

@keyframes wsx-sheet {
  from {
    opacity: 0;
    transform: translateX(56px);
  }
}

@keyframes wsx-sheet-up {
  from {
    opacity: 0;
    transform: translateY(60px);
  }
}

/* Isi panel muncul berurutan. */
dialog.as-sheet[open] #modal-content > * > * {
  animation: wsx-rise 420ms var(--ease-out) both;
  animation-delay: 120ms;
}
