﻿@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #0366d6;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: grey;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* global CSS file */
.dropzone {
    position: relative;
    border: 2px dashed rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 24px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: transparent;
    color: white;
}

    .dropzone label {
        z-index: 1;
        pointer-events: none;
        color: white;
    }

    .dropzone input[type="file"] {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
        z-index: 2;
    }

.dropzone-active {
    border-color: #3399ff;
    background: rgba(51, 153, 255, 0.06);
}


.rich-text-content ol,
.rich-text-content ul {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

.rich-text-content li {
    list-style-position: outside;
}

.rich-text-content li > .ql-ui {
    display: none;
}

.rich-text-content li[data-list="bullet"]::marker {
    content: "•  ";
}

.rich-text-content li[data-list="bullet"].ql-indent-1 {
    margin-left: 1.5rem;
}

.rich-text-content li[data-list="bullet"].ql-indent-1::marker {
    content: "◦  ";
}

.rich-text-content li[data-list="bullet"].ql-indent-2 {
    margin-left: 3rem;
}

.rich-text-content li[data-list="bullet"].ql-indent-2::marker {
    content: "▪  ";
}

.rich-text-content li[data-list="ordered"]::marker {
    content: counter(list-item) ". ";
}

/* ===== Notes page layout (global because scoped CSS does not reach RenderFragment-emitted elements) ===== */

.notes-shell {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    height: calc(100vh - 200px);
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
    padding: 6px;
    scrollbar-gutter: stable;
    background: #0d1117 !important; /* outer shell — shows in the gap between columns */
}

/* Tweak these three to recolor the columns. */
.notes-shell .notes-rail {
    background: #0a0d12; /* column 1 */
}
.notes-shell .notes-browser {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    align-self: stretch !important;
    overflow: hidden;
    box-sizing: border-box;
    flex: 0 0 auto !important;
    background: #11151d;
}

.notes-shell .notes-browser-search {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px;
    padding: 4px 8px;
    min-height: 56px;
    flex: 0 0 auto !important;
    box-sizing: border-box;
    background: #151a24;
}

.notes-shell .notes-browser-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 4px;
    min-height: 40px;
    flex: 0 0 auto !important;
    box-sizing: border-box;
    background: #11151d;
}

.notes-shell .notes-browser-actions .rail-toolbar,
.notes-shell .notes-browser-actions .middle-toolbar {
    min-height: 40px;
    align-items: center !important;
    padding: 0 8px;
}

.notes-shell .notes-browser-body {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 4px;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden;
}

.notes-shell .notes-middle {
    background: #1f1f1f; /* column 2 */
}
.notes-shell .notes-editor {
    background: #1c1c1c; /* notes / editor area */
}

.notes-shell .notes-rail,
.notes-shell .notes-middle,
.notes-shell .notes-editor {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    align-self: stretch !important;
    overflow: hidden;
    box-sizing: border-box;
}

.notes-shell .notes-rail {
    width: 260px;
    min-width: 220px;
    border-right: 1px solid rgba(255,255,255,0.08);
    padding-right: 6px;
}

.notes-shell .rail-toolbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    gap: 4px;
    padding: 4px 8px;
    min-height: 56px;
    flex: 0 0 auto !important;
    box-sizing: border-box;
}

.notes-shell .rail-scroll {
    display: block !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto;
    padding: 4px 0 16px 0;
}

.notes-shell .rail-section,
.notes-shell .rail-group-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 8px;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    margin: 2px 4px;
    border-left: 3px solid transparent;
    min-height: 36px;
}

.notes-shell .rail-section:hover,
.notes-shell .rail-group-header:hover {
    background: rgba(255,255,255,0.05);
}

.notes-shell .rail-section[draggable="true"] {
    cursor: grab;
}

.notes-shell .rail-section[draggable="true"]:active {
    cursor: grabbing;
}

.notes-shell .rail-selected {
    background: rgba(63, 81, 181, 0.32) !important;
    border-left-color: #7986cb !important;
    font-weight: 600;
}

/* Reorder indicator: a 3px bar between rows showing where the dragged item will land. */
.notes-shell .rail-section,
.notes-shell .rail-group-header,
.notes-shell .note-row,
.notes-shell .rail-group-droptail {
    position: relative;
}

.notes-shell .rail-drop-before::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 4px;
    right: 4px;
    height: 5px;
    background: #7986cb;
    border-radius: 3px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 6px rgba(121, 134, 203, 0.7);
}

/* Drop-into indicator: filled highlight on the target container. */
.notes-shell .rail-drop-into {
    outline: 2px solid #7986cb !important;
    outline-offset: -2px;
    background: rgba(121, 134, 203, 0.28) !important;
}

/* Legacy fallback (kept in case any markup still references it). */
.notes-shell .rail-drop-hover {
    outline: 2px dashed rgba(63, 81, 181, 0.9);
    background: rgba(63, 81, 181, 0.18);
}

.notes-shell .rail-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.92rem;
}

.notes-shell .rail-name-edit {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
}

.notes-shell .rail-kebab {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
}

.notes-shell .rail-group {
    margin: 4px 0;
}

.notes-shell .rail-group-children {
    padding-left: 18px;
    border-left: 1px solid rgba(255,255,255,0.06);
    margin-left: 12px;
}

.notes-shell .rail-group-droptail {
    height: 24px;
    margin: 2px 4px;
    border-radius: 4px;
}

.notes-shell .rail-section-system {
    opacity: 0.85;
    font-style: italic;
}

.notes-shell .notes-middle {
    width: 320px;
    min-width: 260px;
    border-right: 1px solid rgba(255,255,255,0.08);
    padding-right: 6px;
}

.notes-shell .middle-toolbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-end !important;
    gap: 6px;
    padding: 4px 8px;
    min-height: 56px;
    flex: 0 0 auto !important;
    box-sizing: border-box;
}

.notes-shell .notes-browser-body > .notes-middle > .middle-toolbar,
.notes-shell .notes-browser-body > .notes-middle > .middle-toolbar + .mud-divider {
    display: none !important;
}

.notes-shell .middle-scroll {
    display: block !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto;
}

.notes-shell .note-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    border-left: 3px solid transparent;
    min-height: 40px;
    user-select: none;
    -webkit-user-select: none;
}

.notes-shell .note-row:hover {
    background: rgba(255,255,255,0.05);
}

.notes-shell .note-row.note-can-drag {
    cursor: grab;
}

.notes-shell .note-row.note-can-drag:active {
    cursor: grabbing;
}

.notes-shell.note-pointer-dragging,
.notes-shell.note-pointer-dragging .note-row.note-can-drag {
    cursor: grabbing;
}

.notes-shell .note-dragging-source {
    opacity: 0.55;
}

.notes-shell .note-selected {
    background: rgba(63, 81, 181, 0.32) !important;
    border-left-color: #7986cb !important;
    font-weight: 600;
}

.notes-shell .note-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-user-drag: none;
}

.notes-shell .notes-editor {
    flex: 1 0 520px !important;
    min-width: 420px;
    padding-left: 6px;
}

.notes-shell .editor-toolbar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px;
    padding: 4px 8px;
    min-height: 56px;
    flex: 0 0 auto !important;
    box-sizing: border-box;
}

.notes-shell .editor-status {
    font-size: 0.8rem;
    min-width: 110px;
    text-align: right;
}

.notes-shell .editor-body {
    display: block !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto;
    padding: 8px;
}

.notes-shell .empty-editor {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-style: italic;
}

.notes-shell .rail-chevron {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 2px;
    margin-right: 2px;
    border-radius: 3px;
}

.notes-shell .rail-chevron:hover {
    background: rgba(255,255,255,0.12);
}

/* Force MudDivider inside a Notes column (or popout) to a 1px line — without
   this it stretches to fill remaining vertical space and creates a huge gap. */
.notes-shell hr.mud-divider,
.notes-popout-shell hr.mud-divider {
    flex: 0 0 auto !important;
    height: 1px !important;
    min-height: 0 !important;
    max-height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-width: 1px 0 0 0 !important;
    box-sizing: border-box !important;
    align-self: stretch !important;
}

/* Custom rounded-tab SVG icons for sections and section groups.
   fill="currentColor" makes the tint follow the CSS color property,
   so changing color is just a matter of overriding the color rule. */
.notes-shell .rail-section-icon,
.notes-shell .rail-group-icon {
    color: #4a90e2; /* default tab color; override per-row via inline style if needed */
    flex-shrink: 0;
    display: inline-block;
}

.notes-shell .rail-group-icon {
    color: #9aa0a6; /* neutral; section groups never participate in the color palette */
}

/* Column resize handles (column 1 + column 2). Thin transparent strip at the right edge
   that highlights on hover; drag changes the column width. */
.notes-shell .col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    z-index: 20;
    background: transparent;
    user-select: none;
}

.notes-shell .col-resize-handle:hover,
.notes-shell .col-resize-handle.resizing {
    background: rgba(121, 134, 203, 0.4);
}

/* The columns must be position: relative so the absolute handle anchors correctly. */
.notes-shell .notes-rail,
.notes-shell .notes-middle {
    position: relative;
}

/* Read-only note badge in the notes list. */
.notes-shell .note-readonly-badge {
    color: #9aa0a6;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Read-only visual cues for the body editor. Input is actually blocked by
   MudHtmlEditor.ReadOnly (which calls Quill's enable(false)); these styles
   just reinforce the read-only feel without breaking scroll. */
.notes-shell .editor-body-readonly .ql-editor {
    cursor: default;
    caret-color: transparent;
}

@media (max-width: 900px) {
    .notes-shell {
        height: calc(100dvh - 190px);
        padding: 4px;
        gap: 4px;
    }

    .notes-shell .notes-editor {
        flex-basis: 420px !important;
        min-width: 360px;
    }
}

@media (max-width: 600px) {
    .mud-main-content:has(.notes-shell) {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .notes-shell {
        padding: 2px;
        gap: 2px;
    }

    .notes-shell .notes-browser-body {
        gap: 2px;
    }

    .notes-shell .notes-editor {
        flex-basis: 390px !important;
        min-width: 340px;
        padding-left: 2px;
    }

    .notes-shell .editor-toolbar {
        gap: 6px;
        padding: 4px 6px;
    }

    .notes-shell .editor-body {
        padding: 6px;
    }
}

/* Match the Save button height to the Name textfield (Outlined + Dense ≈ 40px). */
.notes-shell .editor-toolbar .save-button {
    height: 40px;
    min-height: 40px;
    padding-top: 0;
    padding-bottom: 0;
}

.notes-shell .editor-toolbar .editor-name-field {
    flex: 1 1 auto;
    min-width: 220px;
    max-width: none;
}

.notes-shell .editor-toolbar .editor-last-modified-field {
    flex: 0 0 220px;
    min-width: 190px;
}

@media (max-width: 900px) {
    .notes-shell .editor-toolbar {
        flex-wrap: wrap;
        align-items: flex-start !important;
    }

    .notes-shell .editor-toolbar .editor-name-field {
        flex: 1 1 170px;
        min-width: 140px;
    }

    .notes-shell .editor-toolbar .editor-last-modified-field {
        flex: 1 1 170px;
        min-width: 150px;
    }

    .notes-shell .editor-toolbar .save-button,
    .notes-shell .editor-toolbar .mud-icon-button {
        flex: 0 0 auto;
    }

    .notes-shell .editor-status {
        flex: 1 1 100px;
        min-width: 0;
        text-align: left;
    }
}

@media (max-width: 600px) {
    .notes-shell .editor-toolbar .editor-name-field,
    .notes-shell .editor-toolbar .editor-last-modified-field {
        flex: 0 0 100%;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
    }
}

/* Popout window: edge-to-edge editor only, no rail / middle column. */
.notes-popout-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #1c1c1c;
    color: var(--mud-palette-text-primary, #e0e0e0);
}

.notes-popout-shell .editor-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    min-height: 56px;
    flex: 0 0 auto;
}

.notes-popout-shell .editor-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 8px;
}

.notes-popout-shell .editor-body-readonly .ql-editor {
    cursor: default;
    caret-color: transparent;
}

.notes-popout-shell .save-button {
    height: 40px;
    min-height: 40px;
    padding-top: 0;
    padding-bottom: 0;
}

/* Placeholder shown in the main window while the note is open in a popup. */
.notes-shell .popout-placeholder {
    flex-direction: column;
    text-align: center;
    gap: 4px;
}

/* Popout window: strip the app bar, nav drawer, and any layout padding. */
body.notes-popout-active .mud-appbar,
body.notes-popout-active .mud-drawer,
body.notes-popout-active .mud-drawer-container,
body.notes-popout-active .mud-overlay {
    display: none !important;
}

body.notes-popout-active .mud-main-content {
    padding: 0 !important;
    margin: 0 !important;
}

body.notes-popout-active .mud-layout {
    height: 100vh !important;
}

body.notes-popout-active {
    overflow: hidden;
}

body.notes-popout-active.notes-quick-active {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body.notes-popout-active.notes-quick-active .mud-layout {
    height: auto !important;
    min-height: 100dvh !important;
}
