/* Notes — Notepad-style editor layout */

/* Custom clear button; hide native WebKit cancel to avoid double × */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.chip-red { background: #fee2e2; color: #b91c1c; }
.chip-purple { background: #f3e8ff; color: #7e22ce; }
.chip-blue { background: #dbeafe; color: #1d4ed8; }
.chip-teal { background: #ccfbf1; color: #0f766e; }
.chip-indigo { background: #e0e7ff; color: #4338ca; }
.chip-amber { background: #fef3c7; color: #b45309; }
.chip-orange { background: #ffedd5; color: #c2410c; }
.chip-gray { background: #f1f5f9; color: #475569; }

.note-row {
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #e8ecef;
  text-align: left;
  cursor: pointer;
  background: transparent;
  transition: background-color 0.1s ease;
}
.note-row:hover {
  background: #eef6f5;
}
.note-row.is-selected {
  background: #ccfbf1;
  box-shadow: inset 3px 0 0 #0d9488;
}
.note-row.is-draft {
  border-left: 2px solid #0d9488;
}
.note-row.sortable-ghost {
  opacity: 0.4;
}
.note-row.sortable-chosen {
  background: #fff;
  box-shadow: 0 4px 16px rgb(26 34 41 / 0.1);
}

.drag-handle {
  cursor: grab;
  color: #c5ced6;
  touch-action: none;
  flex-shrink: 0;
  padding: 0.1rem;
  margin-top: 0.1rem;
  border-radius: 0.25rem;
}
.drag-handle:hover {
  color: #5a7186;
  background: #e8ecef;
}
.drag-handle:active {
  cursor: grabbing;
}

.tag-pill {
  font-size: 0.65rem;
  line-height: 1.2;
  padding: 0.12rem 0.4rem;
  border-radius: 9999px;
  background: #e8ecef;
  color: #455a6e;
  border: 1px solid transparent;
  cursor: pointer;
}
.tag-pill:hover,
.tag-pill.is-active {
  background: #ccfbf1;
  color: #0f766e;
  border-color: rgb(13 148 136 / 0.35);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.25rem 0.15rem 0.4rem;
  border-radius: 9999px;
  background: #ccfbf1;
  color: #0f766e;
}
.tag-chip button {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
}
.tag-chip button:hover {
  background: rgb(13 148 136 / 0.2);
}

.tag-suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.65rem;
}
.tag-suggestion-item:hover,
.tag-suggestion-item.is-active {
  background: #f4f6f8;
}
.tag-suggestion-item .hint {
  color: #7a8fa3;
  font-size: 0.65rem;
}

.category-select.chip-red,
.category-select.chip-purple,
.category-select.chip-blue,
.category-select.chip-teal,
.category-select.chip-indigo,
.category-select.chip-amber,
.category-select.chip-orange,
.category-select.chip-gray {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23455a6e'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  background-size: 0.85rem;
}

/* Current line highlight — mirror measures wrapped lines */
.content-editor-wrap {
  background: #fafbfc;
}
.line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0; /* set by JS — covers full logical line incl. soft wraps */
  background: rgb(13 148 136 / 0.09);
  border-left: 2px solid rgb(13 148 136 / 0.4);
  border-radius: 2px;
  pointer-events: none;
  z-index: 0;
}
.content-mirror {
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal;
  box-sizing: border-box;
  overflow: visible;
  height: auto;
  font-size: 0.95rem;
  line-height: 1.75rem;
}
#field-content {
  z-index: 1;
  caret-color: #0f766e;
  font-size: 0.95rem;
  line-height: 1.75rem;
  tab-size: 3;
  -moz-tab-size: 3;
}
#field-diagram {
  tab-size: 3;
  -moz-tab-size: 3;
}

.diagram-viewport {
  cursor: grab;
  min-height: 160px;
  max-height: 70vh;
  background: #f8fafb;
  background-image:
    linear-gradient(rgb(209 217 224 / 0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgb(209 217 224 / 0.35) 1px, transparent 1px);
  background-size: 16px 16px;
}
.diagram-viewport.is-panning {
  cursor: grabbing;
}
.diagram-canvas svg {
  max-width: none;
}
.diagram-resize-handle {
  height: 6px;
  cursor: ns-resize;
  background: linear-gradient(to bottom, transparent, #e8ecef 40%, #e8ecef 60%, transparent);
  border-bottom: 1px solid #e8ecef;
}
.diagram-resize-handle:hover,
.diagram-resize-handle.is-active {
  background: #ccfbf1;
}

/* Attachments side panel — shown only when note has files */
.attachments-panel {
  display: flex;
  flex-direction: column;
  width: 15.5rem;
  flex-shrink: 0;
  border-left: 1px solid #e8ecef;
  background: #fff;
  min-height: 0;
}
.attachments-panel.hidden {
  display: none;
}
.attachments-panel-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem 0.45rem;
  border-bottom: 1px solid #eef2f5;
}
.attachments-panel-title {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #455a6e;
}
.attachments-panel-count {
  font-size: 0.65rem;
  font-weight: 600;
  color: #0f766e;
  background: #ccfbf1;
  border-radius: 9999px;
  min-width: 1.15rem;
  padding: 0.05rem 0.35rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.attachments-panel-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.4rem 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.attachment-item {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.45rem 0.4rem 0.45rem 0.5rem;
  border-radius: 0.45rem;
  background: #f4f6f8;
  border: 1px solid #e8ecef;
}
.attachment-item:hover {
  background: #eef6f5;
  border-color: rgb(13 148 136 / 0.25);
}
.attachment-item-main {
  min-width: 0;
  flex: 1;
}
.attachment-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f766e;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-name:hover {
  text-decoration: underline;
}
.attachment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.65rem;
  color: #5a7186;
  font-variant-numeric: tabular-nums;
}
.attachment-delete {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.3rem;
  color: #7a8fa3;
  font-size: 0.95rem;
  line-height: 1;
}
.attachment-delete:hover {
  color: #dc2626;
  background: #fef2f2;
}

@media (max-width: 899px) {
  /* Stack under editor on narrower screens — still compact, not full-bleed rows */
  #editor-active > .flex-1.flex {
    flex-direction: column;
  }
  .attachments-panel {
    width: 100%;
    max-height: 9.5rem;
    border-left: 0;
    border-top: 1px solid #e8ecef;
  }
  .attachments-panel-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.5rem;
  }
  .attachment-item {
    width: 11.5rem;
    flex-shrink: 0;
  }
}

/* Collapsible filters sidebar (desktop) */
#sidebar.is-collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right-width: 0;
}
#sidebar.is-collapsed .sidebar-inner {
  opacity: 0;
  pointer-events: none;
}
body.sidebar-collapsed #icon-collapse {
  transform: scaleX(-1);
}

@media (max-width: 1023px) {
  #sidebar.is-open {
    transform: translateX(0);
  }
  #btn-collapse-sidebar {
    display: none !important;
  }
}

@media (max-width: 767px) {
  #editor-panel.is-open {
    display: flex;
  }
  #list-panel.is-hidden-mobile {
    display: none;
  }
}
