/* ============================================
   notes.css — Notes list panel, rich-text editor, Markdown mode, fullscreen,
   quick-capture, note templates, version history, encryption indicator.
   Part of the app.css split.
   ============================================ */

/* ===== Notes Panel ===== */
.notes-panel {
    width: 360px; border-right: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-darkest);
    display: flex; flex-direction: column;
}
.notes-list { padding: 8px; flex: 1; overflow-y: auto; }

.notes-pagination {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 10px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 0.78rem; color: var(--text-secondary);
}
.notes-pagination-info { white-space: nowrap; }
.notes-pagination-btns { display: flex; align-items: center; gap: 4px; }
.notes-pagination-btns button:disabled { opacity: 0.35; cursor: not-allowed; }
.notes-pagination-page { padding: 0 4px; font-weight: 500; color: var(--text-primary); white-space: nowrap; }

.note-card {
    padding: 14px 16px; margin-bottom: 6px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer; transition: all var(--transition);
    position: relative;
}
.note-card:hover {
    background: var(--bg-elevated);
    border-color: var(--border);
}
.note-card.active {
    border-color: var(--gold);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 1px var(--gold-dim), var(--shadow-sm);
}
.note-card.dragging {
    opacity: 0.5; transform: rotate(2deg);
}
.note-card-header {
    display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;
}
.note-card-pin {
    color: var(--gold); font-size: 0.85rem; flex-shrink: 0; margin-top: 2px;
}
.note-card-title {
    font-weight: 600; font-size: 0.93rem; flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.note-card-preview {
    font-size: 0.8rem; color: var(--text-muted);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; line-height: 1.4; margin-bottom: 8px;
}
.note-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.72rem; color: var(--text-muted);
}
.note-card-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.note-mini-badge {
    padding: 1px 7px; border-radius: 8px;
    font-size: 0.68rem; font-weight: 500;
    color: #fff;
}
.note-card-category {
    display: flex; align-items: center; gap: 4px;
}
.note-card-category .cat-dot {
    width: 6px; height: 6px; border-radius: 50%;
}
.note-card-viewonly {
    color: var(--info); font-size: 0.75rem;
}

.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 1rem; margin-bottom: 6px; color: var(--text-secondary); }
.empty-state p { font-size: 0.85rem; }

/* ===== Editor Panel ===== */
.editor-panel {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0; background: var(--bg-darkest);
}
.editor-toolbar {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg-dark); flex-shrink: 0;
}
.editor-toolbar .editor-meta { flex: 1; display: flex; gap: 8px; }
.meta-select {
    padding: 6px 10px; font-size: 0.8rem;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-secondary);
    max-width: 160px;
}
.editor-actions { display: flex; gap: 2px; }

.editor-badges {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 8px 20px; min-height: 0;
}
.editor-badges:empty { padding: 0; }
.editor-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 10px;
    font-size: 0.75rem; font-weight: 500; color: #fff;
}

.view-only-banner {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 20px; background: var(--gold-dim);
    color: var(--gold); font-size: 0.85rem; font-weight: 500;
}

.editor-title {
    display: block; width: 100%; padding: 16px 20px 8px;
    background: transparent; border: none; color: var(--text-primary);
    font-family: var(--font); font-size: 1.5rem; font-weight: 700;
    outline: none;
}
.editor-title::placeholder { color: var(--text-muted); }
.editor-title:disabled { opacity: 0.7; }

.format-toolbar {
    display: flex; align-items: center; gap: 2px;
    padding: 6px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg-dark); flex-shrink: 0;
    overflow-x: auto; flex-wrap: nowrap;
}
.fmt-btn {
    width: 32px; height: 32px; display: flex;
    align-items: center; justify-content: center;
    border: none; background: transparent;
    color: var(--text-secondary); border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition);
    flex-shrink: 0; font-size: 1rem;
}
.fmt-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.fmt-btn.active { color: var(--gold); background: var(--gold-dim); }
.fmt-divider {
    width: 1px; height: 20px; background: var(--border);
    margin: 0 4px; flex-shrink: 0;
}

.editor-content {
    flex: 1; padding: 16px 20px; overflow-y: auto;
    outline: none; line-height: 1.7;
    font-size: 0.95rem; color: var(--text-primary);
    min-height: 200px;
}
.editor-content:empty::before {
    content: 'Start writing...';
    color: var(--text-muted);
}
.editor-content[contenteditable="false"] {
    cursor: default;
}
.editor-content h1 { font-size: 1.6rem; font-weight: 700; margin: 16px 0 8px; color: var(--text-primary); }
.editor-content h2 { font-size: 1.3rem; font-weight: 600; margin: 14px 0 6px; color: var(--text-primary); }
.editor-content h3 { font-size: 1.1rem; font-weight: 600; margin: 12px 0 4px; color: var(--text-primary); }
.editor-content p { margin: 6px 0; }
.editor-content ul, .editor-content ol { padding-left: 24px; margin: 6px 0; }
.editor-content li { margin: 3px 0; }
.editor-content blockquote {
    border-left: 3px solid var(--gold); padding: 8px 16px;
    margin: 10px 0; background: var(--bg-card);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary); font-style: italic;
}
.editor-content pre {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 16px;
    margin: 10px 0; overflow-x: auto;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem; line-height: 1.5;
    color: var(--text-primary);
}
.editor-content code {
    background: var(--bg-card); padding: 2px 6px;
    border-radius: 3px; font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em; color: var(--gold);
}
.editor-content pre code { background: transparent; padding: 0; color: inherit; }
.editor-content hr {
    border: none; border-top: 1px solid var(--border);
    margin: 16px 0;
}
.editor-content .checklist-item {
    display: flex; align-items: flex-start; gap: 8px;
    margin: 4px 0; list-style: none;
}
.editor-content .checklist-item input[type="checkbox"] {
    margin-top: 5px; accent-color: var(--gold);
    width: 16px; height: 16px; cursor: pointer;
}
.editor-content a { color: var(--gold); text-decoration: underline; }
.editor-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 0.9rem;
    table-layout: auto;
}
.editor-content th, .editor-content td {
    border: 1px solid var(--border-light);
    padding: 8px 12px;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}
.editor-content th {
    background: var(--bg-elevated);
    color: var(--gold);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}
.editor-content tr:nth-child(even) td { background: var(--bg-card); }
.editor-content tr:hover td { background: var(--bg-hover); }

.editor-status {
    display: flex; align-items: center; gap: 16px;
    padding: 6px 20px; border-top: 1px solid var(--border);
    font-size: 0.72rem; color: var(--text-muted);
    background: var(--bg-dark); flex-shrink: 0;
}

/* ===== Markdown Editor ===== */
.editor-markdown {
    flex: 1; padding: 16px 20px; overflow-y: auto;
    background: transparent; border: none; resize: none; outline: none;
    color: var(--text-primary);
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem; line-height: 1.8;
    min-height: 200px;
}
.editor-markdown::placeholder { color: var(--text-muted); }

/* Dim WYSIWYG-only buttons in markdown mode */
.markdown-mode .fmt-btn:not(#mdToggleBtn) { opacity: 0.3; pointer-events: none; }
#mdToggleBtn.active { color: var(--gold); background: var(--gold-dim); }

/* ===== Fullscreen ===== */
body.fullscreen .sidebar,
body.fullscreen .notes-panel { display: none !important; }
body.fullscreen .editor-panel { position: fixed !important; inset: 0 !important; z-index: 500 !important; }
body.fullscreen #noteFullscreenBtn i::before { content: '\EEE2'; } /* ri-fullscreen-exit-line */

/* ===== Quick Capture Button ===== */
.quick-capture-btn {
    position: fixed; bottom: 28px; right: 28px; z-index: 300;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--gold); color: var(--text-inverse);
    border: none; cursor: pointer; font-size: 1.6rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 24px var(--gold-glow);
    transition: all var(--transition);
}
.quick-capture-btn:hover { background: var(--gold-light); transform: scale(1.1); box-shadow: 0 6px 32px var(--gold-glow); }
.quick-capture-btn:active { transform: scale(0.95); }

/* ===== Templates Modal ===== */
.modal-xl { max-width: 780px; }
.template-layout {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    gap: 16px; align-items: start;
}
.template-preview {
    min-height: 100%; max-height: 62vh; overflow: auto;
    padding: 18px; background: var(--bg-card);
    border-radius: var(--radius); border: 1px solid var(--border);
}
.template-preview-empty {
    min-height: 220px; display: flex; align-items: center; justify-content: center;
    text-align: center; color: var(--text-muted); font-size: 0.9rem;
}
.template-preview-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.template-preview-head i { font-size: 1.8rem; color: var(--gold); }
.template-preview-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.template-preview-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.template-preview-title { font-size: 0.82rem; font-weight: 700; color: var(--gold); margin-bottom: 10px; }
.template-preview-body { color: var(--text-secondary); font-size: 0.84rem; line-height: 1.55; }
.template-preview-body h2, .template-preview-body h3 { color: var(--text-primary); }

/* Template grid + card — the version below (moved verbatim from the old
   "V3 FEATURES STYLES" block) is the one that actually wins the cascade
   since it was declared later in the original single-file app.css; kept
   in this same relative order so behavior is unchanged. */
.template-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.template-card {
    padding: 20px 14px; background: var(--bg-elevated);
    border-radius: var(--radius); border: 1px solid var(--border);
    cursor: pointer; text-align: center; transition: all var(--transition);
}
.template-card:hover { border-color: var(--gold); background: var(--bg-hover); transform: translateY(-2px); box-shadow: var(--shadow); }
.template-card.active { border-color: var(--gold); background: rgba(186,154,66,0.08); box-shadow: var(--shadow); }
.template-card i { font-size: 2rem; color: var(--gold); margin-bottom: 10px; display: block; }
.template-card-name { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.template-card-desc { font-size: 0.73rem; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.template-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.template-card:hover {
  background: rgba(186,154,66,0.08);
  border-color: rgba(186,154,66,0.3);
}
.template-card.active {
  border-color: var(--gold);
  background: rgba(186,154,66,0.12);
}
.template-card i {
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 8px;
}
.template-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.template-card-desc {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ===== Version History Modal ===== */
.history-layout {
    display: flex; min-height: 420px; overflow: hidden;
}
.history-list {
    width: 220px; flex-shrink: 0; overflow-y: auto;
    border-right: 1px solid var(--border); padding: 12px;
    background: var(--bg-dark);
}
.history-preview {
    flex: 1; overflow-y: auto; padding: 16px;
}
.history-item {
    padding: 10px 12px; border-radius: var(--radius-sm);
    cursor: pointer; border: 1px solid transparent; margin-bottom: 6px;
    transition: all var(--transition);
}
.history-item:hover { background: var(--bg-hover); }
.history-item.active { border-color: var(--gold); background: var(--gold-dim); }
.history-item-time { font-size: 0.75rem; color: var(--gold); font-weight: 600; }
.history-item-title { font-size: 0.82rem; color: var(--text-primary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-preview { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-empty { color: var(--text-muted); text-align: center; padding-top: 60px; font-size: 0.88rem; }
.history-preview-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.history-preview-body {
    font-size: 0.88rem; line-height: 1.7; color: var(--text-secondary);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
}
.history-preview-body h1 { font-size: 1.3rem; margin: 10px 0 6px; }
.history-preview-body h2 { font-size: 1.1rem; margin: 8px 0 4px; }
.history-preview-body h3 { font-size: 1rem; margin: 6px 0 4px; }

/* ===== Encrypted note indicator ===== */
.encrypted-banner {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 20px; background: rgba(186,154,66,0.08);
    color: var(--gold); font-size: 0.82rem; font-weight: 500;
    border-bottom: 1px solid var(--border);
}
.encrypted-banner i { font-size: 1rem; }
.note-card-encrypted { color: var(--gold); font-size: 0.75rem; }

@media (max-width: 768px) {
    .quick-capture-btn { bottom: 20px; right: 16px; width: 50px; height: 50px; font-size: 1.4rem; }
    .history-layout { flex-direction: column; }
    .history-list { width: 100%; height: 160px; border-right: none; border-bottom: 1px solid var(--border); }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
    .template-layout { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .editor-title { font-size: 1.2rem; padding: 12px 16px 6px; }
    .editor-content { padding: 12px 16px; }
}
