/* ============================================================
   TASKS (detail drawer + reference chips)
   (split from style.css, lines 716-1095)
   ============================================================ */

/* ======================================================
   TASK DETAIL PANEL (side drawer)
   ====================================================== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.task-drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--custom-drawer-width, min(680px, 100vw));
    background: var(--bg-2);
    border-left: 1px solid var(--border);
    z-index: 201;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden !important;
    max-height: 100vh;
}
.task-drawer.open { transform: translateX(0); }

#drawer-inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.drawer-header-main { flex: 1; min-width: 0; }
.drawer-task-uid { margin-bottom: 6px; }
.drawer-title {
    font-family: var(--font-head);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 10px;
}
.drawer-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.drawer-body {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    overscroll-behavior: contain;
}
.drawer-section {
    margin-bottom: 28px;
}
.drawer-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.drawer-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.drawer-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.drawer-info-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-3);
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.drawer-info-item span { font-size: 0.9rem; }
.drawer-text {
    font-size: 0.9rem;
    color: var(--text-2);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ── Task rich-text editor (Quill) ─────────────────────────────
   Scoped entirely to task text areas. Quill snow CSS is loaded via
   CDN; we override it to match the dark design. Key rules:
   - ONE border on the outer .task-editor-container only
   - Quill's own internal borders are wiped out
   - Toolbar top corners are square (flush with the outer border)
   - Editor area bottom corners rounded to match the container     */
.task-editor-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-3);
    color: var(--text-1);
    font-size: 0.9rem;
    min-height: 120px;
    position: relative;
    /* NOTE: deliberately NOT overflow:hidden — Quill's link-insert tooltip
       (.ql-tooltip) is an absolutely-positioned popup that can extend
       above/below this box (e.g. when the editor is short). Clipping the
       container here was cutting the tooltip's URL input field off.
       Corner-rounding is done on the child elements instead (toolbar top
       corners, editor/handle bottom corners) so nothing visually bleeds
       out even without the clip. */
}

/* Toolbar — no border of its own, rounded top corners matching the outer box */
.task-editor-container .ql-toolbar {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
    background: var(--bg-4);
    padding: 6px 8px;
    flex-wrap: wrap;
}

/* Quill container wrapper — square by default; rounded bottom corners
   only when there's no resize handle below it (read-only editors) */
.task-editor-container .ql-container {
    border: none !important;
    border-radius: 0 !important;
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: var(--bg-3);
}
.task-editor-container.is-readonly .ql-container {
    border-radius: var(--radius-md) !important;
}

/* Quill's link/tooltip popup — make sure it always renders above
   surrounding drawer content instead of being clipped or hidden behind it */
.task-editor-container .ql-tooltip {
    z-index: 30;
}

/* Editor text area */
.task-editor-container .ql-editor {
    min-height: 80px;
    color: var(--text-1);
    line-height: 1.7;
    padding: 12px 14px;
    background: transparent;
    overflow-y: auto;
    resize: none; /* we provide our own drag handle below instead of the native corner grabber */
}
.task-editor-container .ql-editor.ql-blank::before {
    color: var(--text-3);
    font-style: normal;
}

/* Drag-to-resize handle — sits below the editor, centered grip,
   drag up/down to change the editor's height. Only added to editable
   (non read-only) editors; see taskEditor.js. */
.task-editor-resize-handle {
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    background: var(--bg-4);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    user-select: none;
    flex-shrink: 0;
}
.task-editor-resize-grip {
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    transition: background var(--transition);
}
.task-editor-resize-handle:hover .task-editor-resize-grip {
    background: var(--accent);
}
body.editor-resizing { cursor: ns-resize !important; user-select: none; }
body.editor-resizing * { cursor: ns-resize !important; }
body.editor-resizing .task-editor-resize-grip { background: var(--accent); }

/* Toolbar icon colours */
.task-editor-container .ql-toolbar button,
.task-editor-container .ql-toolbar .ql-picker-label {
    color: var(--text-2) !important;
}
.task-editor-container .ql-toolbar button:hover,
.task-editor-container .ql-toolbar button.ql-active,
.task-editor-container .ql-toolbar .ql-picker-label:hover {
    color: var(--accent) !important;
}
.task-editor-container .ql-toolbar button svg .ql-stroke,
.task-editor-container .ql-toolbar .ql-picker-label svg .ql-stroke {
    stroke: var(--text-2) !important;
}
.task-editor-container .ql-toolbar button:hover svg .ql-stroke,
.task-editor-container .ql-toolbar button.ql-active svg .ql-stroke {
    stroke: var(--accent) !important;
}
.task-editor-container .ql-toolbar button svg .ql-fill,
.task-editor-container .ql-toolbar .ql-picker-label svg .ql-fill {
    fill: var(--text-2) !important;
}
.task-editor-container .ql-toolbar button:hover svg .ql-fill,
.task-editor-container .ql-toolbar button.ql-active svg .ql-fill {
    fill: var(--accent) !important;
}

/* Dropdowns */
.task-editor-container .ql-picker-options {
    background: var(--bg-4) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-1) !important;
}
.task-editor-container .ql-picker-item { color: var(--text-2) !important; }
.task-editor-container .ql-picker-item:hover { color: var(--accent) !important; }
.task-editor-container .ql-picker-label { color: var(--text-2) !important; }

/* Modal variant — slightly smaller editor area */
.task-editor-modal .ql-editor { min-height: 80px; }

/* Read-only rich text display — renders stored HTML from the editor */
.task-editor-readonly {
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-2);
}
.task-editor-readonly p   { margin: 0 0 0.5em; }
.task-editor-readonly ul,
.task-editor-readonly ol  { padding-left: 1.4em; margin: 0 0 0.5em; }
.task-editor-readonly h1,
.task-editor-readonly h2,
.task-editor-readonly h3  { margin: 0.6em 0 0.3em; color: var(--text-1); }
.task-editor-readonly blockquote {
    border-left: 3px solid var(--accent);
    margin: 0.5em 0;
    padding-left: 12px;
    color: var(--text-3);
}
.task-editor-readonly code {
    background: var(--bg-3);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 0.85em;
}
.task-editor-readonly pre {
    background: var(--bg-3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.85em;
}
.drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.drawer-state-select {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    color: var(--text-1);
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
}
.drawer-state-select:focus { border-color: var(--accent); }

/* ======================================================
   TASK / PROJECT REFERENCE CHIPS  ("🔗 link a task" feature)
   Rendered both inside a mounted Quill editor (as a registered embed
   blot) and inside plain `.task-editor-readonly` divs (raw stored
   HTML, no Quill instance at all) — so these rules must not depend
   on Quill being present. Click handling is delegated globally by
   watch.js.
   ====================================================== */
.task-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-ring);
    border-radius: 99px;
    padding: 2px 10px 2px 8px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    vertical-align: middle;
    transition: var(--transition);
    user-select: none;
}
.task-ref-chip:hover {
    background: var(--accent-strong);
    color: var(--on-accent);
    border-color: var(--accent);
}
.task-ref-icon { font-size: 0.95em; line-height: 1; }
.task-ref-label { line-height: 1; }

/* "Link a Task or Project" picker modal results */
.taskref-results {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 4px 0 8px;
}
.taskref-hint { font-size: 0.85rem; color: var(--text-3); padding: 10px 2px; line-height: 1.5; }
.taskref-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin: 8px 2px 2px;
}
.taskref-group-label:first-child { margin-top: 2px; }
.taskref-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}
.taskref-result-item:hover { background: var(--bg-3); border-color: var(--border); }
.taskref-result-icon { font-size: 1.1rem; flex-shrink: 0; }
.taskref-result-info { flex: 1; min-width: 0; }
.taskref-result-title {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.taskref-result-sub { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

