/* ==========================================
   Chat Switchboard — Preact NotesPane Kit CSS
   ==========================================
   v0.37.9: Styles for the composable NotesPane kit.
   sw-notes-pane prefixed, no conflicts with legacy.
   ========================================== */

/* ── Container ─────────────────────────────── */

.sw-notes-pane {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--bg, #0e0e10);
}

/* ── Toolbar ───────────────────────────────── */

.sw-notes-pane__toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border, #2e2e35);
    background: var(--bg-surface, #18181b);
    flex-shrink: 0;
}

.sw-notes-pane__toolbar-spacer { flex: 1; }

.sw-notes-pane__toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: none;
    border: 1px solid var(--border, #2e2e35);
    border-radius: 4px;
    color: var(--text-2, #9898a8);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.sw-notes-pane__toolbar-btn:hover {
    color: var(--accent, #6c9fff);
    border-color: var(--accent, #6c9fff);
    background: var(--accent-dim, rgba(108,159,255,0.12));
}

/* ── Search + Filters ──────────────────────── */

.sw-notes-pane__search-row {
    display: flex;
    padding: 6px 10px 0;
    flex-shrink: 0;
}

.sw-notes-pane__search-input {
    width: 100%;
    background: var(--input-bg, #1a1a1f);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 4px;
    color: var(--text, #e8e8ed);
    font-size: 12px;
    font-family: inherit;
    padding: 5px 8px;
    outline: none;
    transition: border-color 0.15s;
}

.sw-notes-pane__search-input:focus {
    border-color: var(--accent, #6c9fff);
}

.sw-notes-pane__filter-row {
    display: flex;
    gap: 4px;
    padding: 4px 10px 6px;
    flex-shrink: 0;
}

.sw-notes-pane__filter-select {
    flex: 1;
    background: var(--input-bg, #1a1a1f);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 4px;
    color: var(--text-2, #9898a8);
    font-size: 11px;
    font-family: inherit;
    padding: 3px 6px;
    cursor: pointer;
    outline: none;
}

.sw-notes-pane__filter-select:focus {
    border-color: var(--accent, #6c9fff);
}

/* ── Tag Cloud ─────────────────────────────── */

.sw-notes-pane__tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 0 10px 6px;
    flex-shrink: 0;
}

.sw-notes-pane__tag-chip {
    display: inline-flex;
    padding: 1px 6px;
    background: var(--purple-dim, rgba(167,139,250,0.1));
    color: var(--purple, #a78bfa);
    font-size: 10px;
    border-radius: 3px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}

.sw-notes-pane__tag-chip:hover,
.sw-notes-pane__tag-chip--active {
    border-color: var(--purple, #a78bfa);
    background: rgba(167,139,250,0.18);
}

/* ── Note List ─────────────────────────────── */

.sw-notes-pane__list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sw-notes-pane__list-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-3, #6b6b7b);
    font-size: 13px;
}

.sw-notes-pane__pinned-divider {
    padding: 2px 10px;
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border, #2e2e35);
    background: var(--bg-surface, #18181b);
}

/* ── Note List Item ────────────────────────── */

.sw-notes-pane__item {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border, #2e2e35);
    cursor: pointer;
    transition: background 0.12s;
}

.sw-notes-pane__item:hover {
    background: var(--bg-hover, #2a2a30);
}

.sw-notes-pane__item--selected {
    background: var(--accent-dim, rgba(108,159,255,0.12));
}

.sw-notes-pane__item-checkbox {
    flex-shrink: 0;
    margin-top: 2px;
}

.sw-notes-pane__item-body {
    flex: 1;
    min-width: 0;
}

.sw-notes-pane__item-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.sw-notes-pane__item-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #e8e8ed);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sw-notes-pane__item-time {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-3, #6b6b7b);
}

.sw-notes-pane__item-preview {
    font-size: 12px;
    color: var(--text-2, #9898a8);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sw-notes-pane__item-preview mark {
    background: var(--warning-dim, rgba(234,179,8,0.2));
    color: var(--warning-light, #fbbf24);
    border-radius: 2px;
    padding: 0 1px;
}

.sw-notes-pane__item-meta {
    display: flex;
    gap: 4px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.sw-notes-pane__item-folder {
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
    background: var(--bg-raised, #222227);
    padding: 0 4px;
    border-radius: 2px;
}

.sw-notes-pane__item-tag {
    font-size: 10px;
    color: var(--purple, #a78bfa);
    background: var(--purple-dim, rgba(167,139,250,0.1));
    padding: 0 4px;
    border-radius: 2px;
}

.sw-notes-pane__item-pin {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-3, #6b6b7b);
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.sw-notes-pane__item:hover .sw-notes-pane__item-pin,
.sw-notes-pane__item-pin--active {
    opacity: 1;
}

.sw-notes-pane__item-pin--active {
    color: var(--accent, #6c9fff);
}

/* ── Selection Bar ─────────────────────────── */

.sw-notes-pane__selection-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-surface, #18181b);
    border-top: 1px solid var(--border, #2e2e35);
    font-size: 12px;
    color: var(--text-2, #9898a8);
    flex-shrink: 0;
}

.sw-notes-pane__selection-bar label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* ── Load More ─────────────────────────────── */

.sw-notes-pane__load-more {
    display: block;
    width: 100%;
    padding: 8px;
    background: none;
    border: none;
    border-top: 1px solid var(--border, #2e2e35);
    color: var(--accent, #6c9fff);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.sw-notes-pane__load-more:hover {
    background: var(--accent-dim, rgba(108,159,255,0.12));
}

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

.sw-notes-pane__editor-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border, #2e2e35);
    background: var(--bg-surface, #18181b);
    flex-shrink: 0;
}

.sw-notes-pane__editor-header-spacer { flex: 1; }

.sw-notes-pane__editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 10px;
    gap: 6px;
}

.sw-notes-pane__editor-title {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border, #2e2e35);
    color: var(--text, #e8e8ed);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 0;
    outline: none;
}

.sw-notes-pane__editor-title:focus {
    border-color: var(--accent, #6c9fff);
}

.sw-notes-pane__editor-meta {
    display: flex;
    gap: 6px;
}

.sw-notes-pane__editor-meta input {
    flex: 1;
    background: var(--input-bg, #1a1a1f);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 4px;
    color: var(--text-2, #9898a8);
    font-size: 11px;
    font-family: inherit;
    padding: 3px 6px;
    outline: none;
}

.sw-notes-pane__editor-meta input:focus {
    border-color: var(--accent, #6c9fff);
    color: var(--text, #e8e8ed);
}

.sw-notes-pane__editor-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sw-notes-pane__editor-textarea {
    flex: 1;
    width: 100%;
    min-height: 120px;
    background: var(--input-bg, #1a1a1f);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 4px;
    color: var(--text, #e8e8ed);
    font-size: 13px;
    font-family: var(--mono, 'JetBrains Mono', monospace);
    line-height: 1.6;
    padding: 8px;
    resize: none;
    outline: none;
}

.sw-notes-pane__editor-textarea:focus {
    border-color: var(--accent, #6c9fff);
}

.sw-notes-pane__editor-footer {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-3, #6b6b7b);
    padding-top: 4px;
    flex-shrink: 0;
}

/* ── Reader ────────────────────────────────── */

.sw-notes-pane__reader {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* With outline: side-by-side layout */
.sw-notes-pane__reader--with-outline {
    flex-direction: row;
}

.sw-notes-pane__reader-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    min-height: 0;
}

/* ── Outline Sidebar (sticky, right side) ─── */

.sw-notes-pane__outline-sidebar {
    width: 160px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 12px 8px;
    border-left: 1px solid var(--border, #2e2e35);
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100%;
}

@media (max-width: 600px) {
    .sw-notes-pane__reader--with-outline { flex-direction: column; }
    .sw-notes-pane__outline-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border, #2e2e35);
        position: static;
        max-height: none;
    }
}

.sw-notes-pane__reader-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text, #e8e8ed);
    margin: 0 0 4px;
    line-height: 1.3;
}

.sw-notes-pane__reader-meta {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.sw-notes-pane__reader-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text, #e8e8ed);
}

/* Reader markdown */
.sw-notes-pane__reader-content p { margin: 0 0 0.6em; }
.sw-notes-pane__reader-content p:last-child { margin-bottom: 0; }

.sw-notes-pane__reader-content pre {
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.5;
    font-family: var(--mono, 'JetBrains Mono', monospace);
}

.sw-notes-pane__reader-content code {
    background: var(--bg-surface, #18181b);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.88em;
    font-family: var(--mono, 'JetBrains Mono', monospace);
}

.sw-notes-pane__reader-content pre code {
    background: none; padding: 0; border-radius: 0; font-size: inherit;
}

.sw-notes-pane__reader-content ul,
.sw-notes-pane__reader-content ol { margin: 4px 0; padding-left: 1.5em; }

.sw-notes-pane__reader-content blockquote {
    border-left: 3px solid var(--accent, #6c9fff);
    padding: 4px 12px;
    margin: 8px 0;
    color: var(--text-2, #9898a8);
}

.sw-notes-pane__reader-content a {
    color: var(--accent, #6c9fff);
    text-decoration: none;
}
.sw-notes-pane__reader-content a:hover { text-decoration: underline; }

.sw-notes-pane__reader-content table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.sw-notes-pane__reader-content th,
.sw-notes-pane__reader-content td { border: 1px solid var(--border, #2e2e35); padding: 4px 8px; }
.sw-notes-pane__reader-content th { background: var(--bg-surface, #18181b); font-weight: 600; }

/* ── Daily Nav ─────────────────────────────── */

.sw-notes-pane__daily-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 8px;
    font-size: 12px;
    color: var(--text-2, #9898a8);
}

.sw-notes-pane__daily-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ── Outline / TOC ─────────────────────────── */

/* Outline items shared by sidebar + inline fallback */
.sw-notes-pane__outline-sidebar,
.sw-notes-pane__outline {
    /* shared base */
}

.sw-notes-pane__outline-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3, #6b6b7b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 0 4px;
}

.sw-notes-pane__outline-item {
    display: block;
    padding: 2px 0;
    font-size: 12px;
    color: var(--text-2, #9898a8);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.12s;
}

.sw-notes-pane__outline-item:hover {
    color: var(--accent, #6c9fff);
}

.sw-notes-pane__outline-item--h2 { padding-left: 12px; }
.sw-notes-pane__outline-item--h3 { padding-left: 24px; }

/* ── Backlinks ─────────────────────────────── */

.sw-notes-pane__backlinks {
    border-top: 1px solid var(--border, #2e2e35);
    padding: 8px 0;
    margin-top: 12px;
}

.sw-notes-pane__backlinks-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3, #6b6b7b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
}

.sw-notes-pane__backlinks-badge {
    background: var(--accent-dim, rgba(108,159,255,0.12));
    color: var(--accent, #6c9fff);
    font-size: 10px;
    padding: 0 5px;
    border-radius: 8px;
    font-weight: 600;
}

.sw-notes-pane__backlinks-list {
    margin-top: 4px;
}

.sw-notes-pane__backlink-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
    cursor: pointer;
    color: var(--accent, #6c9fff);
    transition: color 0.12s;
}

.sw-notes-pane__backlink-item:hover {
    color: var(--accent-hover, #84b0ff);
}

.sw-notes-pane__backlink-folder {
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
}

/* ── Wikilinks ─────────────────────────────── */

.sw-notes-pane__wikilink {
    display: inline;
    padding: 1px 5px;
    background: var(--accent-dim, rgba(108,159,255,0.12));
    color: var(--accent, #6c9fff);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.92em;
    transition: background 0.12s;
}

.sw-notes-pane__wikilink:hover {
    background: rgba(108,159,255,0.22);
}

.sw-notes-pane__wikilink--transclusion {
    color: var(--purple, #a78bfa);
    background: var(--purple-dim, rgba(167,139,250,0.1));
}

.sw-notes-pane__wikilink--transclusion:hover {
    background: rgba(167,139,250,0.2);
}

.sw-notes-pane__transclusion {
    border: 1px solid var(--border, #2e2e35);
    border-left: 3px solid var(--purple, #a78bfa);
    border-radius: 4px;
    margin: 8px 0;
    overflow: hidden;
}

.sw-notes-pane__transclusion-header {
    padding: 4px 8px;
    background: var(--bg-surface, #18181b);
    font-size: 11px;
}

.sw-notes-pane__transclusion-content {
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-2, #9898a8);
}

/* ── Unlinked Mentions ─────────────────────── */

.sw-notes-pane__unlinked {
    border-top: 1px solid var(--border, #2e2e35);
    padding: 8px 0;
    margin-top: 8px;
}

.sw-notes-pane__unlinked-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3, #6b6b7b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 0 4px;
}

.sw-notes-pane__unlinked-item {
    display: inline-flex;
    padding: 1px 6px;
    margin: 1px 2px;
    background: var(--bg-raised, #222227);
    color: var(--text-2, #9898a8);
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
    border: 1px dashed var(--border, #2e2e35);
    transition: border-color 0.12s, color 0.12s;
}

.sw-notes-pane__unlinked-item:hover {
    border-color: var(--accent, #6c9fff);
    color: var(--accent, #6c9fff);
}

/* ── Graph ─────────────────────────────────── */

.sw-notes-pane__graph {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sw-notes-pane__graph-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border, #2e2e35);
    background: var(--bg-surface, #18181b);
    flex-shrink: 0;
}

.sw-notes-pane__graph-stats {
    font-size: 11px;
    color: var(--text-3, #6b6b7b);
}

.sw-notes-pane__graph-canvas-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
}

.sw-notes-pane__graph-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── Quick Switcher ────────────────────────── */

.sw-notes-pane__switcher-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay, rgba(0,0,0,0.55));
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    z-index: 9999;
}

.sw-notes-pane__switcher {
    width: min(420px, 90vw);
    background: var(--bg-surface, #18181b);
    border: 1px solid var(--border, #2e2e35);
    border-radius: 8px;
    box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,0.5));
    overflow: hidden;
}

.sw-notes-pane__switcher-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border, #2e2e35);
    color: var(--text, #e8e8ed);
    font-size: 15px;
    font-family: inherit;
    padding: 12px 14px;
    outline: none;
}

.sw-notes-pane__switcher-results {
    max-height: 300px;
    overflow-y: auto;
}

.sw-notes-pane__switcher-section {
    padding: 4px 12px 2px;
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sw-notes-pane__switcher-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.sw-notes-pane__switcher-item:hover,
.sw-notes-pane__switcher-item--active {
    background: var(--accent-dim, rgba(108,159,255,0.12));
}

.sw-notes-pane__switcher-item-title {
    flex: 1;
    font-size: 13px;
    color: var(--text, #e8e8ed);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sw-notes-pane__switcher-item-folder {
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
}

.sw-notes-pane__switcher-create {
    padding: 8px 14px;
    border-top: 1px solid var(--border, #2e2e35);
    font-size: 12px;
    color: var(--accent, #6c9fff);
    cursor: pointer;
    transition: background 0.1s;
}

.sw-notes-pane__switcher-create:hover {
    background: var(--accent-dim, rgba(108,159,255,0.12));
}

.sw-notes-pane__switcher-hint {
    padding: 6px 14px;
    font-size: 10px;
    color: var(--text-3, #6b6b7b);
    text-align: right;
    border-top: 1px solid var(--border, #2e2e35);
}

/* ── Save-to-Note Dialog ───────────────────── */

.sw-notes-pane__save-mode {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.sw-notes-pane__save-mode label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-2, #9898a8);
}

.sw-notes-pane__save-search-results {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
}

.sw-notes-pane__save-search-item {
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text, #e8e8ed);
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.1s;
}

.sw-notes-pane__save-search-item:hover,
.sw-notes-pane__save-search-item--selected {
    background: var(--accent-dim, rgba(108,159,255,0.12));
}

.sw-notes-pane__save-preview {
    max-height: 120px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-raised, #222227);
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-2, #9898a8);
}

/* ── Shared: loading spinner ───────────────── */

.sw-notes-pane__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-3, #6b6b7b);
    font-size: 13px;
}
