/*
 * Application styles, on top of the PrimeFaces saga-blue theme.
 *
 * Colours come from the theme's custom properties (--surface-*, --text-*, --primary-color) so the
 * page follows the theme rather than restating its palette. Selectors starting with `ui-` are the
 * theme's own class names, reached into where a component has to fill its pane or lose a border.
 */

html,
body {height: 100%;margin: 0;font-size: 0.875rem;}
.notes-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
}

.app-bar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--surface-border);
    background: var(--surface-card);
}

.app-bar i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.app-bar__title {
    font-size: 1.05rem;
    font-weight: 600;
}

.app-main {
    flex: 1;
    min-height: 0;
}

/* The form wraps the whole workspace, so it has to carry the height through. */
.app-form {
    height: 100%;
}

/* The splitter and both panels must be height-constrained all the way down, otherwise the tree and
   the note list grow past the viewport instead of scrolling inside their pane. */
.workspace {
    height: 100%;
    border: 0;
    border-radius: 0;
}

.workspace .ui-splitter-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.workspace .ui-splitter-panel > * {
    flex: 1;
    min-height: 0;
}

.right-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Bottom-right corner spinner while an ajax request is in flight. */
.ajax-status {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 2000;
    color: var(--primary-color);
    font-size: 1.5rem;
}

/* ---------------------------------------------------------------- folders */

.tree-pane {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    min-height: 0;
    padding: 0.75rem;
}

/* Header plus the "All notes" row: one ajax update target, so they are one block. */
.tree-pane__top {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 0.5rem;
}

.tree-pane__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.tree-pane__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.tree-pane__header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.tree-pane__all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 0;
    border-radius: var(--border-radius);
    background: transparent;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.tree-pane__all:hover {
    background: var(--surface-hover);
}

/* saga-blue publishes no highlight custom property; this is its .ui-state-highlight pair. */
.tree-pane__all.is-active {
    color: var(--text-color);
}

.tree-pane .ui-tree {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: auto;
    border: 0;
    padding: 0;
}

.tree-pane__empty {
    padding: 0.4rem 0.6rem;
    color: var(--text-color-secondary);
}

.tree-pane__footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start; /* align to left */
    padding: 0.5rem 0.75rem 0 0.75rem;
    margin-top: auto; /* push to bottom */
}

.logout-button {
    padding: 0.4rem 0.6rem;
    font-weight: 600;
}

/* The node label is what the theme sizes; the row content has to span the node so the actions can
   sit at its right edge. */
.tree-pane .ui-treenode-content {
    width: 100%;
}

.tree-pane .ui-treenode-label {
    flex: 1;
    min-width: 0;
}

.tree-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
}

.tree-node__label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Row actions stay out of the way until the row is hovered or holds focus, so the tree reads as a
   list of names rather than a wall of buttons. Focus-within keeps them keyboard-reachable. */
.tree-node__actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.125rem;
    opacity: 0;
    transition: opacity 0.12s ease-in-out;
}

.tree-node:hover .tree-node__actions,
.tree-node:focus-within .tree-node__actions {
    opacity: 1;
}

.folder-form {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.folder-form label {
    margin-top: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.folder-form input,
.folder-form textarea {
    width: 100%;
}

.folder-form small {
    color: var(--text-color-secondary);
}

/* --------------------------------------------------------------------- notes */

.notes-pane {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    min-height: 0;
    padding: 0.75rem;
}

.notes-pane__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.notes-pane__title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.notes-pane__title h2 {
    margin: 0;
    overflow: hidden;
    font-size: 1.125rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-pane__title small {
    color: var(--text-color-secondary);
}

/* Search icon inside the field: PrimeFaces has no icon-field component, so the icon is positioned
   over the input and the input keeps room for it. */
.notes-pane__search {
    position: relative;
    display: block;
    width: 100%;
}

.notes-pane__search > i {
    position: absolute;
    top: 50%;
    left: 0.75rem;
    color: var(--text-color-secondary);
    transform: translateY(-50%);
    pointer-events: none;
}

.notes-pane__search input {
    width: 100%;
    padding-left: 2.25rem;
}

.notes-pane__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.notes-pane__state {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-color-secondary);
}

.notes-pane__state i {
    font-size: 2rem;
}

.notes-pane__state p {
    margin: 0;
}

.note-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.note-list .ui-datalist-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 0;
    padding: 0;
    background: transparent;
}

.note-list .ui-datalist-data {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.note-list .ui-datalist-empty-message {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* The row itself is the list item the component styles; the box is on the inner element, because only
   the open note is highlighted and the item class is the same for every row. */
.note-row__body {
    display: flex;
    align-items: flex-start;
    gap: 0.25rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    background: var(--surface-card);
}

.note-row__body:hover {
    border-color: var(--primary-color);
}
.note-row__body a:hover {
    text-decoration: none;
    color: white;
    font-weight: bold;
}

.note-row__body.is-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.note-row__open {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.note-row__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-row__meta {
    flex: 0 0 auto;
    margin-left: auto;
    color: var(--text-color-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.note-row__preview {
    overflow: hidden;
    color: var(--text-color-secondary);
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-row__delete {
    margin: 0.5rem 0.4rem 0 0;
}

/* -------------------------------------------------------------------- editor */

.note-editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    min-height: 0;
    padding: 0.75rem;
    overflow-y: auto;
}

.note-editor__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.note-editor__header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.note-editor__actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.note-editor__dirty {
    color: var(--text-color-secondary);
    font-style: italic;
}

.note-editor__fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.note-editor__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.note-editor__field label {
    font-weight: 600;
    font-size: 0.875rem;
}

.note-editor__field input,
.note-editor__field textarea {
    width: 100%;
}


.noborder{border: 0!important; }
.tox-tinymce.tox-fullscreen{z-index: 10200!important;}
.tox-tinymce-aux{z-index: 10300!important;}
.tox.tox-silver-sink.tox-tinymce-aux{z-index: 10300!important;}
.tox-tinymce.tox-fullscreen .tox-editor-header{z-index: 10201!important;}
.tox-tinymce.tox-fullscreen .tox-menubar{z-index: 10202!important;}
.tox-tinymce.tox-fullscreen .tox-toolbar{z-index: 10202!important;}
.tox .tox-tbtn__select-label, .tox .tox-mbtn.tox-mbtn--select {font-size: 19px!important;}
.tox .tox-menu {font-size: 19px!important;}
.tox .tox-collection__item {font-size: 19px!important;}
.tox .tox-collection__item-label {font-size: 19px!important;}
.tox .tox-collection__item-checkmark {width: 20px;}

.ui-treenode-label{padding: 0!important;}
.ui-tree-container li{padding: 0!important;}

.tox .tox-editor-header, .tox-promotion {background-color: rgb(42, 50, 61) !important;}
.tox .tox-menubar {background-color: rgb(42, 50, 61) !important;}
.tox .tox-toolbar, .tox .tox-toolbar__primary {background-color: rgb(42, 50, 61) !important;}
.tox .tox-menu {background-color: rgb(42, 50, 61) !important;border-color: rgb(70, 80, 95) !important;}
.tox .tox-collection {background-color: rgb(42, 50, 61) !important;}
.tox .tox-collection__item {
    background-color: rgb(42, 50, 61) !important;
    color: #ffffff !important;
}

.tox .tox-collection__item-label {color: #ffffff !important;}

/* Hover/selected menu item */
.tox .tox-collection__item--active {background-color: rgb(60, 72, 88) !important;color: #ffffff !important;}
/* Icons inside menu items */
.tox .tox-collection__item svg {fill: #ffffff !important;}
/* Toolbar select buttons */
.tox .tox-mbtn.tox-mbtn--select {background-color: rgb(42, 50, 61) !important;color: #ffffff !important;}
/* Text inside toolbar select buttons */
.tox .tox-mbtn.tox-mbtn--select .tox-mbtn__select-label {color: #ffffff !important;}
/* Dropdown arrow */
.tox .tox-mbtn.tox-mbtn--select svg {fill: #ffffff !important;}
/* Hover */
.tox .tox-mbtn.tox-mbtn--select:hover {background-color: rgb(60, 72, 88) !important;}
.tox .tox-tbtn {background-color: rgb(42, 50, 61) !important;color: #ffffff !important;}
.tox .tox-tbtn svg {fill: #ffffff !important;}
.tox .tox-tbtn:hover {background-color: rgb(60, 72, 88) !important;}

/* Android-style switch for note hide toggle */
.switch { position: relative; display:inline-block; width:46px; height:26px; }
.switch input { opacity:0; width:0; height:0; position:absolute; left:-9999px; }
.slider { position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background:#cfcfcf; transition:.18s; border-radius:34px; }
.slider:before { position:absolute; content:""; height:20px; width:20px; left:3px; bottom:3px; background:white; transition:.18s; border-radius:50%; box-shadow:0 1px 3px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--primary-color); }
.switch input:focus + .slider { box-shadow: 0 0 0 3px rgba(0,0,0,0.08); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius:34px; }
.slider.round:before { border-radius:50%; }

/* Layout for the label before the switch: force a single horizontal row */
.note-editor__toggle { display:flex !important; flex-direction:row; align-items:center; gap:8px; align-self:flex-start; }
.note-editor__toggle-label { margin:0; font-weight:600; display:inline-flex; align-items:center; white-space:nowrap; }
.note-editor__toggle .switch { margin-left:8px; flex:0 0 auto; }
