/* notes.css — Archie Notes page */

.notes-body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

/* ── Topbar ──────────────────────────────────────────────────── */

#notes-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-surface);
}

#notes-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-sec);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color var(--duration);
}
#notes-back:hover { color: var(--accent); }

#notes-topbar h1 {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

#notes-topbar-actions { display: flex; gap: 8px; }

/* ── Layout ──────────────────────────────────────────────────── */

#notes-layout {
  display: grid;
  grid-template-columns: 200px 280px 1fr;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */

#notes-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface);
}

#notes-sidebar-search {
  padding: 10px 12px 8px;
}

#notes-page-search {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
}
#notes-page-search:focus { border-color: var(--accent-dim); }

#notes-notebooks-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 12px 4px;
}

#notes-notebooks-nav {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  padding: 2px 8px;
}

.nb-btn {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-sec);
  font-size: 13px;
  padding: 6px 8px;
  cursor: pointer;
  transition: background var(--duration), color var(--duration);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nb-btn:hover { background: var(--bg-hover); color: var(--text); }
.nb-btn.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }

#notes-sidebar-count {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

/* ── Note list ───────────────────────────────────────────────── */

#notes-list-panel {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#notes-list-inner { display: flex; flex-direction: column; padding: 4px 0; }

.notes-loading, .notes-error, .notes-empty {
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
.notes-error { color: var(--red); }

.note-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
  cursor: pointer;
  transition: background var(--duration);
}
.note-item:hover { background: var(--bg-hover); }
.note-item.selected { background: var(--accent-dim); }

.note-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.note-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.pin-star { color: var(--amber, #d4a017); font-size: 12px; flex-shrink: 0; }

.note-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.nb-chip {
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg-hover);
  border-radius: 4px;
  color: var(--text-sec);
}

.tag-chip {
  font-size: 10px;
  padding: 1px 5px;
  background: rgba(99,102,241,0.15);
  border-radius: 4px;
  color: var(--accent);
}

.note-date {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

.note-excerpt {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Editor ──────────────────────────────────────────────────── */

#notes-editor-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#notes-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

#notes-editor-toolbar-right { display: flex; gap: 8px; align-items: center; }

#notes-editor-status {
  font-size: 12px;
  padding: 3px 16px;
  min-height: 20px;
  flex-shrink: 0;
}
.editor-status-ok  { color: var(--green); }
.editor-status-err { color: var(--red); }

#notes-editor-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 0 16px 16px;
  gap: 8px;
}

#note-page-title {
  font-size: 22px;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 12px 0 8px;
  outline: none;
  width: 100%;
}
#note-page-title::placeholder { color: var(--text-muted); }

#notes-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#note-page-notebook,
#note-page-tags {
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 8px;
  outline: none;
}
#note-page-notebook { width: 130px; }
#note-page-tags     { flex: 1; min-width: 160px; }
#note-page-notebook:focus,
#note-page-tags:focus { border-color: var(--accent-dim); }

.pin-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-sec);
  cursor: pointer;
  user-select: none;
}

#note-page-split {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 16px;
}

#note-page-body,
#note-page-preview {
  flex: 1;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.65;
}

#note-page-body {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px;
  resize: none;
  outline: none;
  font-family: var(--font-mono);
}
#note-page-body:focus { border-color: var(--accent-dim); }

#note-page-preview {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
}
#note-page-preview h1,
#note-page-preview h2,
#note-page-preview h3 { color: var(--text); margin-top: 1em; }
#note-page-preview code {
  background: var(--bg-code, #1e1e2e);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
}
#note-page-preview pre {
  background: var(--bg-code, #1e1e2e);
  padding: 10px 14px;
  border-radius: 6px;
  overflow-x: auto;
}
#note-page-preview a { color: var(--accent); }

/* ── Shared button styles ─────────────────────────────────────── */

.btn-primary-sm {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: opacity var(--duration);
}
.btn-primary-sm:hover { opacity: 0.85; }
.btn-primary-sm:disabled { opacity: 0.4; cursor: default; }

.btn-danger-sm {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  cursor: pointer;
  font-weight: 500;
  transition: background var(--duration);
}
.btn-danger-sm:hover { background: rgba(199,91,91,0.1); }

.btn-ghost {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-sec);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--duration), border-color var(--duration), background var(--duration);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); }
.btn-ghost.active { color: var(--accent); border-color: var(--accent-dim); background: rgba(99,102,241,0.08); }
.btn-sm { font-size: 11px; padding: 3px 8px; }

/* ── Toast ───────────────────────────────────────────────────── */

#notes-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  z-index: 9999;
  pointer-events: none;
}
.notes-toast-ok  { background: var(--green); color: #000; }
.notes-toast-err { background: var(--red);   color: #fff; }

/* ── Mobile ──────────────────────────────────────────────────── */

@media (max-width: 900px) {
  #notes-layout { grid-template-columns: 160px 1fr; }
  #notes-editor-panel { grid-column: 2; }
}

@media (max-width: 767px) {
  #notes-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  #notes-sidebar { display: none; }
  #notes-list-panel { border-right: none; }
  #notes-editor-panel { position: absolute; inset: 52px 0 0; background: var(--bg); z-index: 10; }
}
