/* Table header styling for all editors */
[contenteditable="true"] table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

/* Header row styling - first row when marked as header */
[contenteditable="true"] table.has-header-row tr:first-child td,
[contenteditable="true"] table.has-header-row tr:first-child th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

/* Header column styling - first cell in each row when marked as header */
[contenteditable="true"] table.has-header-column td:first-child,
[contenteditable="true"] table.has-header-column th:first-child {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

/* Checkbox styling - circular checkboxes */
.note-editor input[type="checkbox"],
.task-note-editor input[type="checkbox"],
#projectDescriptionEditor input[type="checkbox"],
#areaDescriptionEditor input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-tertiary);
    border-radius: var(--radius-circle);
    margin-right: 8px;
    cursor: pointer;
    position: relative;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.note-editor input[type="checkbox"]:hover,
.task-note-editor input[type="checkbox"]:hover,
#projectDescriptionEditor input[type="checkbox"]:hover,
#areaDescriptionEditor input[type="checkbox"]:hover {
    border-color: var(--accent-blue);
}

.note-editor input[type="checkbox"]:checked,
.task-note-editor input[type="checkbox"]:checked,
#projectDescriptionEditor input[type="checkbox"]:checked,
#areaDescriptionEditor input[type="checkbox"]:checked {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.note-editor input[type="checkbox"]:checked::after,
.task-note-editor input[type="checkbox"]:checked::after,
#projectDescriptionEditor input[type="checkbox"]:checked::after,
#areaDescriptionEditor input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.note-editor input[type="checkbox"]:disabled,
.task-note-editor input[type="checkbox"]:disabled,
#projectDescriptionEditor input[type="checkbox"]:disabled,
#areaDescriptionEditor input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Island delete is two-step: the first Backspace marks the block, the second
   removes it. A toggle/callout can hold paragraphs and the removal is outside
   the undo stack. */
.island-pending-delete {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Completed to-do items styling */
.note-editor li,
.task-note-editor li,
#projectDescriptionEditor li,
#areaDescriptionEditor li,
.daily-note-editor li,
.event-note-editor li {
    cursor: pointer;
}

#projectDescriptionEditor ul,
#projectDescriptionEditor ol,
#areaDescriptionEditor ul,
#areaDescriptionEditor ol {
    padding-left: var(--editor-list-indent);
}

/* To-do lists get the SAME gutter as bullet/numbered lists; the ○/ring
   span is pulled back into it with a negative margin (below) so it hangs
   like a native list marker and the text starts on the shared indent edge.
   The inline style (padding-left: 24px) requires !important to override. */
.note-editor ul[style*="list-style: none"],
.task-note-editor ul[style*="list-style: none"],
#projectDescriptionEditor ul[style*="list-style: none"],
#areaDescriptionEditor ul[style*="list-style: none"],
.daily-note-editor ul[style*="list-style: none"],
.event-note-editor ul[style*="list-style: none"] {
    padding-left: var(--editor-list-indent) !important;
}

/* Style completed to-do items (starting with ●) */
.note-editor ul[style*="list-style: none"] li,
.task-note-editor ul[style*="list-style: none"] li,
#projectDescriptionEditor ul[style*="list-style: none"] li,
#areaDescriptionEditor ul[style*="list-style: none"] li,
.daily-note-editor ul[style*="list-style: none"] li,
.event-note-editor ul[style*="list-style: none"] li {
    /* Block with a hanging marker — NOT flex. Flex laid a nested sublist
       BESIDE the text, and flex-wrap dropped long text below the marker
       (anonymous flex items size at max-content). As a block, wrapped
       lines and nested sublists start at the text edge like every other
       list type. */
    display: block;
    transition: opacity var(--duration-fast) var(--ease-in-out), text-decoration var(--duration-fast) var(--ease-in-out);
}

@media (prefers-reduced-motion: reduce) {
    .note-editor ul[style*="list-style: none"] li,
    .task-note-editor ul[style*="list-style: none"] li,
    #projectDescriptionEditor ul[style*="list-style: none"] li,
    #areaDescriptionEditor ul[style*="list-style: none"] li,
    .daily-note-editor ul[style*="list-style: none"] li,
    .event-note-editor ul[style*="list-style: none"] li {
        transition: none;
    }
}

/* Keep circle span fixed-width so wrapped text aligns after it.
   user-select:none prevents cursor from entering the span and
   inheriting its blue color when editing adjacent text. */
.note-editor ul[style*="list-style: none"] li > span:first-child,
.task-note-editor ul[style*="list-style: none"] li > span:first-child,
#projectDescriptionEditor ul[style*="list-style: none"] li > span:first-child,
#areaDescriptionEditor ul[style*="list-style: none"] li > span:first-child,
.daily-note-editor ul[style*="list-style: none"] li > span:first-child,
.event-note-editor ul[style*="list-style: none"] li > span:first-child {
    /* Hanging marker: a 16px box (shared by the open and completed rings,
       so toggling never shifts the text) pulled back into the gutter.
       Net advance is 16px − 20px = −4px; the \a0 that follows (~4px)
       brings the text back to the li content edge — the same left edge as
       bullet/numbered text. */
    display: inline-block;
    width: 16px;
    margin-left: calc(-1 * var(--todo-marker-col));
    text-align: center;
    cursor: pointer;
    line-height: inherit;
    -webkit-user-select: none;
    user-select: none;
}

/* To-do ring. BOTH states are drawn by the same CSS ring, centred on the
   marker's line box, so an open and a completed item are the same size and sit
   on the same line at the same x. The open state used to be the ○ text glyph
   (ink ~11px, baseline-aligned, centred by advance width) while the completed
   state was a 16px CSS ring centred on a 16px-tall box — so the completed ring
   rendered larger, further left and ~3px higher than the open one.
   The ○/● glyph stays in the DOM (the toggle and persistence code read it) but
   is transparent; !important beats the inline colour the creation code writes. */
.note-editor ul[style*="list-style: none"] li > span:first-child,
.task-note-editor ul[style*="list-style: none"] li > span:first-child,
#projectDescriptionEditor ul[style*="list-style: none"] li > span:first-child,
#areaDescriptionEditor ul[style*="list-style: none"] li > span:first-child,
.daily-note-editor ul[style*="list-style: none"] li > span:first-child,
.event-note-editor ul[style*="list-style: none"] li > span:first-child {
    position: relative;
    color: transparent !important;
}

.note-editor ul[style*="list-style: none"] li > span:first-child::before,
.task-note-editor ul[style*="list-style: none"] li > span:first-child::before,
#projectDescriptionEditor ul[style*="list-style: none"] li > span:first-child::before,
#areaDescriptionEditor ul[style*="list-style: none"] li > span:first-child::before,
.daily-note-editor ul[style*="list-style: none"] li > span:first-child::before,
.event-note-editor ul[style*="list-style: none"] li > span:first-child::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: var(--radius-circle);
    border: 2px solid var(--accent-blue);
    background: transparent;
}

/* Completed: the same ring plus an inner dot. Outside the editors (read-only
   renders) the span has no ring of its own, so the geometry is repeated here. */
.todo-completed {
    position: relative;
    display: inline-block;
    width: 16px;
    text-align: center;
    color: transparent !important;
}

.todo-completed::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: var(--radius-circle);
    border: 2px solid var(--accent-blue);
    background: transparent;
}

.todo-completed::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: var(--radius-circle);
    background: var(--accent-blue);
}

.todo-item-completed {
    color: var(--text-completed);
}

/* Horizontal rule styling */
.note-editor hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 1.5em 0;
}

.note-modal.fullscreen .note-editor {
    min-height: unset;
    height: 100%;
}

.note-modal-footer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) 28px;
    border-top: 1px solid var(--border-light);
}

.note-modal-footer .modal-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.note-modal-footer .modal-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.note-modal-footer .modal-action-btn.active {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.note-modal-footer .modal-action-btn svg {
    width: 18px;
    height: 18px;
}

.note-modal-footer .note-meta {
    order: -1;
    margin-right: auto;
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
}

/* Note modal delete button */
.note-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.note-delete-btn svg {
    width: 18px;
    height: 18px;
}

.note-delete-btn:hover {
    background: var(--color-danger-light);
    color: var(--color-red-text);
}

/* Note Dropdown (Area/Project selection) */
.note-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    max-height: 300px;
    overflow-y: auto;
    z-index: var(--z-layer-picker);
}

.note-dropdown-item {
    display: flex;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.note-dropdown-item:hover {
    background: var(--bg-hover);
}

.note-dropdown-item.active {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.note-dropdown-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.note-dropdown-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Note tags dropdown — reuses .dropdown-item inside .note-dropdown */
.note-tags-dropdown {
    padding: var(--space-1);
    min-width: 220px;
    max-width: 280px;
    max-height: calc(100vh - 100px);
}

.note-tags-dropdown .dropdown-item {
    margin: 0;
}

.dropdown-check {
    margin-left: auto;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--accent-blue);
}

.dropdown-check svg {
    width: 16px;
    height: 16px;
}
