/* ──────────────────────────────────────────────────────────────────────
   Notebook editor — file tree pane + TipTap editor pane.
   Reuses .editor-sidebar / .btn / .tiptap-* from editor.css.
   ────────────────────────────────────────────────────────────────────── */

/* Make the main column fill the viewport so the two panes can scroll. */
.editor-page .editor-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    padding: 0;
    overflow: hidden;
}

.editor-page .editor-header {
    flex-shrink: 0;
    margin: 0;
    padding: 0.9rem 1.5rem;
}

.notebook-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.notebook-select-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.notebook-header-left .styled-select {
    min-width: 220px;
    max-width: 320px;
}

.editor-page .editor-actions {
    align-items: center;
    gap: 0.75rem;
}

/* ─── Workspace: tree pane | editor pane ─────────────────────────────── */
.notebook-workspace {
    flex: 1;
    display: flex;
    gap: 1rem;
    min-height: 0;
    padding: 0 1rem 1rem 1rem;
    overflow: hidden;
}

.notebook-tree-panel {
    width: 280px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.notebook-tree-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem;
    border-bottom: 1px solid var(--border-color);
}

.notebook-tree-search {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.notebook-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.notebook-icon-button:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.notebook-icon-button iconify-icon {
    font-size: 1.1rem;
}

/* ─── Tree (VS Code style) ───────────────────────────────────────────── */
.notebook-tree,
.notebook-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 0.4rem 0.35rem 1rem;
}

.notebook-tree[hidden],
.notebook-search-results[hidden] {
    display: none;
}

.tree-children[hidden] {
    display: none;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.4rem;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: nowrap;
}

.tree-row:hover {
    background: var(--bg-hover, rgba(0, 0, 0, 0.06));
}

.tree-note.is-active {
    background: var(--accent-color);
    color: #fff;
}

.tree-caret {
    width: 0.85rem;
    flex: 0 0 auto;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-align: center;
}

.tree-icon {
    flex: 0 0 auto;
    font-size: 1rem;
    color: var(--text-secondary);
}

.tree-note.is-active .tree-icon {
    color: #fff;
}

.tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-row.is-drop-target,
.notebook-tree.is-drop-target {
    outline: 2px dashed var(--accent-color);
    outline-offset: -2px;
    background: rgba(212, 163, 115, 0.12);
}

.tree-children.is-drop-target {
    background: rgba(212, 163, 115, 0.12);
}

/* ─── Search results ─────────────────────────────────────────────────── */
.notebook-search-result {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.55rem;
    margin-bottom: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.notebook-search-result:hover {
    border-color: var(--accent-color);
}

.notebook-search-result strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}

.notebook-search-result span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notebook-search-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.5rem;
}

/* ─── Editor pane ────────────────────────────────────────────────────── */
.notebook-editor-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.notebook-note-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 0.25rem 0.75rem;
}

.notebook-note-meta {
    min-width: 0;
}

.notebook-note-meta h1 {
    margin: 0;
    font-size: 1.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notebook-note-path {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.no-note-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}

.no-note-selected[hidden] {
    display: none;
}

.no-note-selected h3 {
    margin: 0 0 0.4rem;
}

/* TipTap container fills the pane and scrolls internally */
.notebook-editor-pane .tiptap-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.notebook-editor-pane .tiptap-container[hidden] {
    display: none;
}

.notebook-editor-pane .tiptap-toolbar {
    flex-shrink: 0;
}

.notebook-editor-pane .tiptap-editor {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
}

.notebook-editor-pane .tiptap-editor .ProseMirror {
    min-height: auto;
    padding-bottom: 40vh;
}

.tiptap-editor.drag-over {
    outline: 2px dashed var(--accent-color);
    outline-offset: -4px;
    background: rgba(212, 163, 115, 0.1);
}

.tiptap-editor .editor-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.5rem 0;
}

/* ─── Tables ─────────────────────────────────────────────────────────── */
.tiptap-editor table {
    border-collapse: collapse;
    table-layout: fixed;
    width: 100%;
    margin: 1rem 0;
    overflow: hidden;
}

.tiptap-editor table td,
.tiptap-editor table th {
    border: 1px solid var(--border-color, #555);
    padding: 0.4rem 0.6rem;
    vertical-align: top;
    min-width: 80px;
    position: relative;
    box-sizing: border-box;
}

.tiptap-editor table th {
    font-weight: 700;
    text-align: left;
}

.tiptap-editor table .selectedCell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(212, 163, 115, 0.2);
    pointer-events: none;
}

.tiptap-editor table .column-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--accent-color, #d4a373);
    cursor: col-resize;
    z-index: 20;
}

.tiptap-editor .tableWrapper {
    overflow-x: auto;
}

/* ─── Inline highlight tags (parity with logbook) ────────────────────── */
.tiptap-editor .tag {
    display: inline;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.95em;
}

.tiptap-editor .tag.treasure {
    background-color: #F7ECA2;
    color: var(--treasure-color-dark, #91682f);
}

.tiptap-editor .tag.location {
    background-color: #C4E299;
    color: var(--location-color-dark, #638b48);
}

.tiptap-editor .tag.character {
    background-color: #EAA6C0;
    color: var(--character-color-dark, #9E4963);
}

/* ─── Context menu ───────────────────────────────────────────────────── */
.notebook-context-menu {
    position: fixed;
    z-index: 1000;
    min-width: 11rem;
    display: flex;
    flex-direction: column;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.notebook-context-menu[hidden] {
    display: none;
}

.notebook-context-menu-item {
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: 0.45rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.notebook-context-menu-item:hover:not(:disabled) {
    background: var(--accent-color);
    color: #fff;
}

.notebook-context-menu-item:disabled {
    opacity: 0.4;
    cursor: default;
}

.notebook-context-menu-item-danger {
    color: #c0392b;
}

/* ─── Modal ──────────────────────────────────────────────────────────── */
.notebook-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
}

.notebook-modal-overlay[hidden] {
    display: none;
}

.notebook-modal {
    width: min(420px, calc(100vw - 2rem));
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    padding: 1.25rem;
}

.notebook-modal h3 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.notebook-modal-message {
    margin: 0 0 0.75rem;
    color: #555;
    font-size: 0.9rem;
}

.notebook-modal-message[hidden] {
    display: none;
}

.notebook-modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.65rem;
    font: inherit;
    border: 1px solid #c4c4c4;
    border-radius: 5px;
}

.notebook-modal-input[hidden] {
    display: none;
}

.notebook-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.1rem;
}

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 820px) {
    .notebook-tree-panel {
        width: 220px;
        min-width: 200px;
    }
}
