/* =========================================================
   deeBoard v3 — Floating Markdown Notes
   Ide & Eksekusi oleh gdeeogikk
========================================================= */

/* ---------- Header trigger ---------- */
.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}
.notes-trigger-btn {
  width: auto !important;
  padding: 0 12px !important;
  gap: 6px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-md);
}
.notes-trigger-btn .notes-trigger-label {
  font-size: 13px;
  font-weight: 600;
}
@media (max-width: 640px) {
  .notes-trigger-btn .notes-trigger-label { display: none; }
  .notes-trigger-btn { padding: 0 8px !important; }
}

/* ---------- Notes list panel (slide-in from right) ---------- */
.notes-list-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 900;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.notes-list-overlay.hidden { display: none; }

.notes-list-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 340px;
  max-width: 90vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 901;
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 50px var(--shadow-color);
  transform: translateX(0);
  animation: notesPanelIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.notes-list-panel.hidden { display: none; }

@keyframes notesPanelIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.notes-list-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
}
.notes-list-panel-header span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.notes-list-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notes-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--text-tertiary);
  text-align: center;
}
.notes-list-empty i { font-size: 32px; }
.notes-list-empty.hidden { display: none; }

.note-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.note-list-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-soft);
}
.note-list-item.open {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.note-list-item i.ph-file-text {
  font-size: 18px;
  color: var(--accent-strong);
  flex-shrink: 0;
}
.note-list-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  padding: 2px 0;
}
.note-list-item-title:focus {
  text-overflow: clip;
}
.note-list-item-del {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.note-list-item:hover .note-list-item-del { opacity: 1; }
.note-list-item-del:hover {
  color: var(--accent-rose);
  background: var(--accent-rose-soft);
}

.notes-list-panel-footer {
  padding: 12px;
  border-top: 1px solid var(--border-soft);
}
.btn-block { width: 100%; justify-content: center; }

/* ---------- Floating windows layer ---------- */
.floating-windows-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
}

.note-window {
  position: absolute;
  pointer-events: all;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px var(--shadow-color);
  min-width: 320px;
  min-height: 240px;
  overflow: hidden;
  resize: none;
  animation: noteWindowIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes noteWindowIn {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.note-window.dragging,
.note-window.resizing {
  transition: none;
  user-select: none;
}
.note-window.focused {
  border-color: var(--accent);
  box-shadow: 0 24px 60px var(--shadow-color), 0 0 0 1px var(--accent-soft);
}

.note-window-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-soft);
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}
.note-window-header:active { cursor: grabbing; }

.note-window-title {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  padding: 4px 6px;
  border-radius: 6px;
}
.note-window-title:focus { background: var(--surface-hover); }

.note-window-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.note-window-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-size: 15px;
}
.note-window-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.note-window-btn.close:hover {
  background: var(--accent-rose-soft);
  color: var(--accent-rose);
}

.note-window-save-indicator {
  font-size: 10.5px;
  color: var(--text-tertiary);
  padding: 0 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.note-window-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Simple rich-text editor (contenteditable) ---------- */
.note-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.note-editor-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
.note-editor-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.note-editor-btn.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.note-editor-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.note-window-editor {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  padding: 14px 16px;
  outline: none;
}
.note-window-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
  pointer-events: none;
}
.note-window-editor b,
.note-window-editor strong { font-weight: 700; color: var(--text); }
.note-window-editor i,
.note-window-editor em { font-style: italic; }
.note-window-editor u { text-decoration: underline; }
.note-window-editor s,
.note-window-editor strike { text-decoration: line-through; opacity: 0.75; }
.note-window-editor ul,
.note-window-editor ol {
  margin: 6px 0;
  padding-left: 22px;
}
.note-window-editor li { margin: 2px 0; }
.note-window-editor blockquote {
  margin: 6px 0;
  padding-left: 14px;
  border-left: 3px solid var(--accent-soft);
  color: var(--text-secondary);
}
.note-window-editor blockquote blockquote {
  border-left-color: var(--border);
}

/* ---------- Resize handle — thumb-sized, same on mobile & desktop ----------
   Single mechanism (JS-driven, see setupResizeHandleTouch in notes.js):
   native CSS `resize` is off, this is the only way to resize a window,
   width or height, always clamped to the viewport. */
.note-window-resize-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 44px;
  height: 44px;
  touch-action: none;
  cursor: nwse-resize;
  z-index: 5;
}
.note-window-resize-handle::after {
  content: "";
  width: 16px;
  height: 16px;
  background:
    linear-gradient(135deg, transparent 0 50%, var(--accent) 50% 58%, transparent 58% 100%),
    linear-gradient(135deg, transparent 0 68%, var(--accent) 68% 76%, transparent 76% 100%);
  opacity: 0.85;
}

@media (max-width: 640px) {
  .note-window {
    min-width: 260px;
    min-height: 220px;
    touch-action: none;
  }
  .note-window-body {
    touch-action: none;
  }
  .note-window-header {
    touch-action: none;
  }
}

/* Drag handle tambahan agar grab area lebih jelas dan besar */
.note-window-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  margin-right: 4px;
  color: var(--text-tertiary);
  cursor: grab;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.note-window-drag-handle:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.note-window-drag-handle:active {
  cursor: grabbing;
}

/* Modifikasi tombol hapus menjadi container aksi ganda (Edit & Delete) */
.note-list-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.note-list-item:hover .note-list-actions { opacity: 1; }

.note-list-item-action {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; border: none; background: transparent;
  color: var(--text-tertiary); cursor: pointer;
  transition: all 0.15s ease;
}
.note-list-item-action:hover { background: var(--surface-hover); color: var(--text); }
.note-list-item-action.delete:hover { background: var(--accent-rose-soft); color: var(--accent-rose); }
.note-list-item-title[readonly] { cursor: pointer; }
/* ---------- Task <-> Notes/Flowchart linking (links.js) ---------- */
.link-section { margin-top: 16px; }
.link-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.link-chip-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 4px; }
.link-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 10px;
  background: var(--surface-hover);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.link-chip span:hover { color: var(--accent-strong); }
.link-chip-remove {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: none; background: transparent;
  color: var(--text-tertiary); cursor: pointer; font-size: 10px;
}
.link-chip-remove:hover { background: var(--accent-rose-soft); color: var(--accent-rose); }

.link-picker-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.link-picker-overlay.hidden { display: none; }
.link-picker-panel {
  width: 360px; max-width: 90vw; max-height: 70vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px var(--shadow-color);
  display: flex; flex-direction: column; overflow: hidden;
}
.link-picker-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft);
  font-weight: 600; font-family: "Space Grotesk", sans-serif; color: var(--text);
}
.link-picker-body { flex: 1; overflow-y: auto; padding: 8px; }
.link-picker-empty { padding: 24px 12px; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.link-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-md);
  cursor: pointer; color: var(--text); font-size: 13.5px;
  border: 1px solid transparent;
}
.link-picker-item:hover { background: var(--surface-hover); }
.link-picker-item.selected { background: var(--accent-soft); border-color: var(--accent); }
.link-picker-item i { color: var(--text-tertiary); flex-shrink: 0; }
.link-picker-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-picker-item-open {
  flex-shrink: 0;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; border: none; background: transparent;
  color: var(--text-tertiary); cursor: pointer;
  opacity: 0; transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.link-picker-item:hover .link-picker-item-open { opacity: 1; }
.link-picker-item-open:hover { color: var(--accent-strong); background: var(--surface-hover); }

/* ---------- Panel 1: node-links-popover (terpisah dari link-picker) ---------- */
.node-links-popover {
  position: fixed;
  z-index: 1050;
  width: 280px;
  max-width: 90vw;
  max-height: 60vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: noteWindowIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.node-links-popover.hidden { display: none; }
.node-links-popover-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  font-size: 13.5px;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  flex-shrink: 0;
}
.node-links-popover #node-links-popover-list {
  padding: 10px;
  overflow-y: auto;
  min-height: 8px;
}
.node-links-popover-add {
  margin: 0 10px 10px;
  width: auto;
}