/* ============================================================
   NOTES SYSTEM
   ============================================================ */

.notes-shell {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* ---- Sidebar ---- */
.notes-sidebar {
    width: 260px;
    min-width: 260px;
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.notes-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.95rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.notes-empty-nav {
    padding: 1.5rem 1rem;
    color: #9ca3af;
    font-size: 0.85rem;
    text-align: center;
}

/* ---- Category ---- */
.notes-category-header {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    gap: 0.5rem;
    transition: background 0.1s;
}

.notes-category-header:hover { background: #f1f5f9; }
.notes-category.active > .notes-category-header { background: #e0f2fe; }

.notes-category-name { flex: 1; font-weight: 600; font-size: 0.875rem; }

.notes-category-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.notes-category-header:hover .notes-category-actions { opacity: 1; }

/* ---- Section ---- */
.notes-sections { padding-left: 4px; }

.notes-section-header {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    font-size: 0.825rem;
    color: #374151;
    gap: 0.25rem;
    transition: background 0.1s;
}

.notes-section-header:hover { background: #f1f5f9; }
.notes-section-header.active { color: #2563eb; font-weight: 500; }

.notes-section-actions { display: flex; gap: 2px; margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.notes-section-header:hover .notes-section-actions { opacity: 1; }

.notes-add-section {
    padding: 0.3rem 1rem;
    font-size: 0.78rem;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.1s;
}

.notes-add-section:hover { color: #2563eb; }

/* ---- Page tree ---- */
.notes-page-item {
    padding: 0.28rem 0.75rem;
    font-size: 0.82rem;
    cursor: pointer;
    color: #374151;
    border-radius: 4px;
    margin: 1px 4px;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-page-item:hover { background: #f1f5f9; }
.notes-page-item.active { background: #dbeafe; color: #1d4ed8; font-weight: 500; }

/* ---- Main content ---- */
.notes-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.notes-no-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #9ca3af;
}

/* ---- Page header ---- */
.notes-page-header {
    padding: 1rem 1.5rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 5;
}

.notes-page-title-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.notes-page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: text;
}

.notes-title-input {
    font-size: 1.5rem;
    font-weight: 700;
    border: none;
    border-bottom: 2px solid #3b82f6;
    outline: none;
    width: 100%;
    max-width: 600px;
    background: transparent;
}

.notes-page-meta { font-size: 0.75rem; color: #9ca3af; }

.notes-page-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.notes-subpages-label { font-size: 0.8rem; color: #6b7280; }

/* ---- Canvas ---- */
.notes-canvas {
    flex: 1;
    position: relative;
    min-height: 600px;
    padding: 1rem;
    background: #fafafa;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 24px 24px;
}

/* ---- Block ---- */
.notes-block {
    position: absolute;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    min-height: 60px;
    overflow: visible;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.notes-block:hover { border-color: #93c5fd; }
.notes-block-active { border-color: #3b82f6 !important; box-shadow: 0 0 0 2px rgba(59,130,246,0.2); z-index: 10; }

.notes-block-toolbar {
    position: absolute;
    top: -34px;
    right: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 2px 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    z-index: 20;
}

.notes-block-drag-handle {
    cursor: grab;
    color: #9ca3af;
    font-size: 1.1rem;
    padding: 0 4px;
    user-select: none;
}

.notes-block-text,
.notes-block-heading {
    padding: 0.5rem 0.75rem;
    min-height: 40px;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.notes-block-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e293b;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.5rem;
}

/* ---- Table block ---- */
.notes-table-block { overflow-x: auto; padding: 0.5rem; }

.notes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.notes-table td {
    border: 1px solid #e5e7eb;
    padding: 0.3rem 0.5rem;
    min-width: 80px;
    outline: none;
    vertical-align: top;
}

.notes-table .notes-table-header {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
}

.notes-table-row-actions {
    border: none !important;
    width: 20px;
    padding: 0 !important;
    vertical-align: middle;
}

.notes-table-cell-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
    padding: 0;
    min-width: 60px;
}

.notes-table-header-input {
    font-weight: 600;
    color: #374151;
}

.notes-table-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.4rem;
}

/* ---- Resize handle ---- */
.notes-block-resize {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, #93c5fd 50%);
    border-bottom-right-radius: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.notes-block:hover .notes-block-resize,
.notes-block-active .notes-block-resize { opacity: 1; }

/* ---- Rich text format buttons ---- */
.notes-fmt-btn {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 3px;
    padding: 1px 5px;
    cursor: pointer;
    font-size: 0.78rem;
    color: #374151;
    line-height: 1.4;
    transition: background 0.1s;
}

.notes-fmt-btn:hover { background: #f1f5f9; }

.notes-fmt-sep {
    display: inline-block;
    width: 1px;
    height: 16px;
    background: #e5e7eb;
    margin: 0 3px;
    vertical-align: middle;
}

/* ---- Search ---- */
.notes-search-bar {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.notes-search-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    font-size: 0.82rem;
    outline: none;
    background: #f8fafc;
}

.notes-search-input:focus { border-color: #93c5fd; background: #fff; }

.notes-search-results { padding: 0.25rem 0; }

/* ---- Inline rename ---- */
.notes-inline-rename {
    border: none;
    border-bottom: 1px solid #3b82f6;
    outline: none;
    background: transparent;
    font-size: inherit;
    font-weight: inherit;
    width: 100%;
    padding: 0;
}

/* ---- Image block ---- */
.notes-block-image-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.notes-block-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.notes-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    gap: 0.5rem;
    cursor: pointer;
    width: 100%;
    height: 100%;
    font-size: 0.8rem;
}

.notes-image-placeholder:hover { color: #3b82f6; }

/* ---- Toolbar divider ---- */
.notes-toolbar-divider {
    display: inline-block;
    width: 1px;
    height: 24px;
    background: #e5e7eb;
    margin: 0 4px;
    vertical-align: middle;
}

/* ---- Page item with rename input ---- */
.notes-page-item span { cursor: pointer; display: block; }

/* ---- Print media query ---- */
@media print {
    .notes-sidebar,
    .notes-page-header,
    .notes-block-toolbar,
    .notes-block-resize { display: none !important; }

    .notes-shell { display: block; }
    .notes-canvas { position: relative; min-height: unset; background: none; }
    .notes-block { box-shadow: none; border: 1px solid #ccc; }
}
/* ---- Dialogs ---- */
.notes-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notes-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.notes-dialog h5 { margin: 0 0 1rem; font-weight: 700; }

.notes-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.notes-colour-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0.5rem 0 0.75rem;
    align-items: center;
}

.notes-colour-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.1s;
}

.notes-colour-swatch:hover { transform: scale(1.15); }
.notes-colour-swatch.selected { border-color: #1e293b; transform: scale(1.15); }
