/* ============================================
   File    : app/css/components.css
   Fungsi  : Komponen — tombol, chip, card, toast, sheet, cmdk
   Letak   : lumennote/app/css/components.css
   ============================================ */

/* ---------- ICON BUTTON ---------- */
.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--fg-2);
  transition: background var(--dur-fast), color var(--dur-fast);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-2);
  color: var(--fg);
}

.icon-btn:active {
  background: var(--bg-3);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- CHIP (filter) ---------- */
.filters {
  display: flex;
  gap: 4px;
  padding: 0 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  flex-shrink: 0;
}

.filters::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 6px 10px;
  background: transparent;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: -0.005em;
  scroll-snap-align: start;
  line-height: 1;
}

.chip:hover {
  background: var(--bg-2);
  color: var(--fg);
}

.chip:active {
  transform: scale(0.97);
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(201, 118, 74, 0.25);
}

[data-theme="dark"] .chip.active {
  box-shadow: 0 2px 8px rgba(224, 138, 92, 0.3);
}

/* Mobile sangat kecil */
@media (max-width: 340px) {
  .chip {
    padding: 5px 9px;
    font-size: 11px;
  }
  .filters {
    gap: 3px;
    padding: 0 8px 10px;
  }
}

/* Desktop: chip sedikit lebih lega */
@media (min-width: 720px) {
  .chip {
    padding: 6px 11px;
    font-size: 12px;
  }
  .filters {
    padding: 0 14px 14px;
    gap: 5px;
  }
}

/* ---------- NOTE CARD (sidebar) ---------- */
.note-card {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  cursor: pointer;
  transition: background var(--dur-fast);
  position: relative;
  border: 1px solid transparent;
}

.note-card:hover {
  background: var(--bg-2);
}

.note-card:active {
  background: var(--bg-3);
}

.note-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.note-card .row1 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}

.note-card .pin-ico {
  color: var(--accent);
  font-size: 10px;
  flex-shrink: 0;
  line-height: 1;
}

.note-card .title {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  letter-spacing: -0.01em;
}

.note-card .snippet {
  font-size: var(--fs-xs);
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  line-height: 1.4;
}

.note-card .row2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--fg-3);
  letter-spacing: 0.01em;
}

.note-card .tag-mini {
  color: var(--accent);
  font-weight: 500;
}

.note-card mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

.empty-list {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-3);
  font-size: var(--fs-sm);
}

.empty-list .big {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.35;
}

/* ---------- TOOL PILL ---------- */
.tool-pill {
  height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-2);
  box-shadow: var(--shadow-sm);
  transition: all var(--dur-fast);
  flex-shrink: 0;
}

.tool-pill:hover {
  background: var(--bg-2);
}

.tool-pill:active {
  background: var(--bg-3);
}

.tool-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tool-pill svg {
  width: 16px;
  height: 16px;
}

/* ---------- TOAST ---------- */
.toast-wrap {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 96px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 90;
  padding: 0 16px;
}

.toast {
  background: var(--fg);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  transform: translateY(20px);
  opacity: 0;
  animation: toastIn var(--dur) var(--ease) forwards;
  max-width: 90vw;
}

.toast button {
  color: var(--accent-2);
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: 2px 4px;
}

@keyframes toastIn {
  to { transform: translateY(0); opacity: 1; }
}

.toast.out {
  animation: toastOut var(--dur-fast) forwards;
}

@keyframes toastOut {
  to { transform: translateY(20px); opacity: 0; }
}

/* ---------- SHEET (bottom modal) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur);
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 8px calc(var(--safe-bottom) + 12px);
  z-index: 61;
  transform: translateY(102%);
  transition: transform var(--dur-slow) var(--ease);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
}

.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--fg-3);
  opacity: 0.4;
  margin: 6px auto 12px;
}

.sheet h3 {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 12px 16px 6px;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--fg);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.sheet-item:hover,
.sheet-item:active {
  background: var(--bg-2);
}

.sheet-item.danger {
  color: var(--danger);
}

.sheet-item svg {
  width: 20px;
  height: 20px;
  color: var(--fg-2);
  flex-shrink: 0;
}

.sheet-item.danger svg {
  color: var(--danger);
}

.sheet-item .sub {
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-left: auto;
}

/* Color picker row */
.color-row {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.color-row::-webkit-scrollbar {
  display: none;
}

.color-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--dur-fast), border-color var(--dur-fast);
  position: relative;
}

.color-dot:hover {
  transform: scale(1.08);
}

.color-dot.active {
  border-color: var(--fg);
}

.color-dot[data-color="default"] {
  background: var(--bg-2);
  border: 2px dashed var(--border);
}

.color-dot[data-color="terracotta"] { background: #c9764a; }
.color-dot[data-color="amber"] { background: #d9a94a; }
.color-dot[data-color="olive"] { background: #8a9a5b; }
.color-dot[data-color="sage"] { background: #6ba86e; }
.color-dot[data-color="sky"] { background: #5b8bbf; }
.color-dot[data-color="lavender"] { background: #8b7bbf; }
.color-dot[data-color="rose"] { background: #c97a8b; }
.color-dot[data-color="slate"] { background: #6b7280; }

/* ---------- MODAL (dialog tengah) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--dur) var(--ease);
}

.modal-backdrop.open .modal {
  transform: scale(1);
}

.modal h2 {
  font-size: var(--fs-lg);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.modal p {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: background var(--dur-fast);
}

.modal-btn.ghost {
  color: var(--fg-2);
}

.modal-btn.ghost:hover {
  background: var(--bg-2);
}

.modal-btn.primary {
  background: var(--accent);
  color: #fff;
}

.modal-btn.primary:hover {
  background: var(--accent-2);
}

.modal-btn.danger {
  background: var(--danger);
  color: #fff;
}

/* ---------- COMMAND PALETTE ---------- */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.cmdk-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cmdk {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  right: 12px;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 101;
  transform: translateY(-12px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur) var(--ease), opacity var(--dur);
  overflow: hidden;
}

.cmdk.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.cmdk input {
  width: 100%;
  padding: 16px 18px;
  border: none;
  outline: none;
  font-size: var(--fs-md);
  background: transparent;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.cmdk-list {
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
}

.cmdk-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--fg);
  transition: background var(--dur-fast);
}

.cmdk-item .ico {
  color: var(--fg-3);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
}

.cmdk-item .lbl {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmdk-item .hint {
  font-size: 11px;
  color: var(--fg-3);
  font-family: var(--font-mono);
}

.cmdk-item.sel {
  background: var(--accent-soft);
  color: var(--accent);
}

.cmdk-item.sel .ico {
  color: var(--accent);
}

.cmdk-empty {
  padding: 20px;
  text-align: center;
  color: var(--fg-3);
  font-size: var(--fs-sm);
}

/* ---------- INSTALL BANNER ---------- */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 12px);
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  z-index: 80;
  transform: translateY(120%);
  transition: transform var(--dur-slow) var(--ease);
  max-width: 500px;
  margin: 0 auto;
}

.install-banner.show {
  transform: translateY(0);
}

.install-banner .txt {
  flex: 1;
  font-size: var(--fs-sm);
  line-height: 1.4;
}

.install-banner .txt b {
  display: block;
  font-size: var(--fs-base);
  margin-bottom: 1px;
}

.install-banner button {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--accent);
  color: #fff;
}

.install-banner .x {
  background: none;
  color: var(--bg);
  opacity: 0.6;
  padding: 6px;
}

.install-banner .x:hover {
  opacity: 1;
}

/* ---------- SETTINGS ---------- */
.settings-page {
  padding: 0 16px calc(var(--safe-bottom) + 40px);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.settings-section {
  margin-bottom: 28px;
}

.settings-section h3 {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 8px;
  padding: 0 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-2);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background var(--dur-fast);
}

.settings-row:hover {
  background: var(--bg-3);
}

.settings-row .lbl {
  flex: 1;
  font-size: var(--fs-sm);
}

.settings-row .lbl small {
  display: block;
  font-size: var(--fs-xs);
  color: var(--fg-3);
  margin-top: 2px;
}

.settings-row .val {
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

.settings-row svg {
  width: 20px;
  height: 20px;
  color: var(--fg-3);
}

/* ---------- EMPTY / HELP ---------- */
.help-page,
.credits-page {
  padding: 0 20px calc(var(--safe-bottom) + 40px);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  font-size: var(--fs-sm);
  color: var(--fg-2);
  line-height: 1.7;
}

.help-page h2,
.credits-page h2 {
  font-size: var(--fs-xl);
  color: var(--fg);
  margin: 24px 0 12px;
  letter-spacing: -0.02em;
}

.help-page h3,
.credits-page h3 {
  font-size: var(--fs-base);
  color: var(--fg);
  margin: 20px 0 8px;
}

.help-page p,
.credits-page p {
  margin-bottom: 12px;
}

.help-page ul,
.credits-page ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.help-page li,
.credits-page li {
  margin-bottom: 6px;
}

.help-page kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--fg);
}

/* ---------- DONATE PAGE ---------- */
.donate-page {
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.donate-page .heart {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto 24px;
}

.donate-page .heart svg {
  width: 32px;
  height: 32px;
}

.donate-page h2 {
  font-size: var(--fs-xl);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.donate-page p {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  margin-bottom: 16px;
  line-height: 1.7;
}

.donate-page a.btn-donate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--fs-base);
  text-decoration: none;
  margin: 8px 0;
  transition: transform var(--dur-fast), background var(--dur-fast);
}

.donate-page a.btn-donate:hover {
  background: var(--accent-2);
}

.donate-page a.btn-donate:active {
  transform: scale(0.97);
}

.donate-page .supporters {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}

.donate-page .supporters b {
  display: block;
  font-size: var(--fs-base);
  color: var(--fg);
  margin-bottom: 8px;
}

.donate-page .supporters .name {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-2);
  border-radius: var(--radius-full);
  margin: 3px 3px 0 0;
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

/* ---------- WARNA AKSEN CATATAN DI SIDEBAR ---------- */
.note-card[data-color="terracotta"] { border-left: 3px solid #c9764a; }
.note-card[data-color="amber"] { border-left: 3px solid #d9a94a; }
.note-card[data-color="olive"] { border-left: 3px solid #8a9a5b; }
.note-card[data-color="sage"] { border-left: 3px solid #6ba86e; }
.note-card[data-color="sky"] { border-left: 3px solid #5b8bbf; }
.note-card[data-color="lavender"] { border-left: 3px solid #8b7bbf; }
.note-card[data-color="rose"] { border-left: 3px solid #c97a8b; }
.note-card[data-color="slate"] { border-left: 3px solid #6b7280; }

.note-card.active[data-color] {
  border-left-width: 4px;
}