/* Shared styles for the ticket drawer, the rich-text editor it shares with
   the track-notes drawer, and checklist rendering. Loaded by board.html and
   project.html after their own <style> blocks; relies on each page's CSS
   variables (--surface, --text, --border, --red-bg …), which are identical
   across pages, so light/dark mode follow the page automatically. */

/* ── Rich-text editor (toolbar + contenteditable) ── */
.rte-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.rte-btn {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border: 0.5px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: 6px; cursor: pointer; font-size: 12.5px; line-height: 1; font-family: inherit;
}
.rte-btn:hover { border-color: var(--blue); color: var(--blue-text); }
.rte-btn.active { background: var(--blue-bg); color: var(--blue-text); border-color: var(--blue); }
.rte-btn.rte-btn-wide { width: auto; padding: 0 7px; font-size: 11px; gap: 4px; }
.rte-color-group { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding-left: 8px; border-left: 0.5px solid var(--border); }
.rte-swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border-strong); cursor: pointer; padding: 0; }
.rte-swatch-reset {
  width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border-strong); cursor: pointer;
  background: var(--surface); color: var(--text-3); font-size: 10px; line-height: 1; padding: 0;
}
.rte-editor {
  min-height: 70px; max-height: 220px; overflow-y: auto; border: 0.5px solid var(--border-strong);
  border-radius: var(--radius); padding: 8px 10px; font-family: inherit; font-size: 12.5px;
  color: var(--text); background: var(--surface); line-height: 1.5;
}
.rte-editor:focus { outline: none; border-color: var(--blue); }
.rte-editor:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.rte-editor.ticket-rte-editor { min-height: 160px; max-height: 50vh; }
body.dark .rte-editor, body.dark .rte-btn, body.dark .rte-swatch-reset {
  background: var(--surface-1); color: var(--text); border-color: var(--border-strong);
}

/* ── Rich-text rendering (editor, ticket notes view, track notes) ── */
.rte-editor ul, .ticket-notes-view ul, .track-note-body ul { margin-left: 1.1rem; }

/* Outline/legal numbering for nested ordered lists — "1." at the top level,
   "1.1"/"1.2" one level down, "1.1.1" below that, however deep Tab/Indent
   goes. Each nested <ol> gets its own counter-reset, so counters(..., ".")
   chains through however many ancestor <ol>s exist. */
.rte-editor ol, .ticket-notes-view ol, .track-note-body ol {
  list-style: none; counter-reset: rte-item; padding-left: 0; margin-left: 1.1rem;
}
.rte-editor ol > li, .ticket-notes-view ol > li, .track-note-body ol > li {
  counter-increment: rte-item; position: relative; padding-left: 1.6em;
}
.rte-editor ol > li::before, .ticket-notes-view ol > li::before, .track-note-body ol > li::before {
  content: counter(rte-item) "."; position: absolute; left: 0;
  color: var(--text-2); font-variant-numeric: tabular-nums;
}
.rte-editor ol ol > li::before, .ticket-notes-view ol ol > li::before, .track-note-body ol ol > li::before {
  content: counters(rte-item, ".");
}

/* Checklists: <ul class="ck"> with <li data-checked>. The checkbox itself is
   added at render time (tickets.js decorateChecklist) and stripped before
   save — the server never stores an <input>. */
ul.ck { list-style: none; margin-left: 0 !important; padding-left: 0; }
ul.ck ul.ck { margin-left: 1.4rem !important; }
ul.ck > li { position: relative; padding-left: 1.6em; padding-right: 1.5em; margin: 2px 0; }
ul.ck > li > .ck-box {
  position: absolute; left: 0; top: 0.2em; width: 14px; height: 14px; margin: 0;
  cursor: pointer; accent-color: var(--blue);
}
ul.ck > li[data-checked="true"] { color: var(--text-3); }
ul.ck > li[data-checked="true"] > .ck-text, .ticket-notes-view ul.ck > li[data-checked="true"] { text-decoration: line-through; }
.ticket-notes-view ul.ck > li[data-checked="true"] ul.ck { text-decoration: none; }
ul.ck > li.ck-rejected { color: var(--red-text); }
ul.ck > li.ck-na { color: var(--text-3); }
.ck-tag { font-size: 10.5px; opacity: 0.8; }
/* Hover-revealed per-line delete — same opacity-on-hover convention as
   .track-note-delete/.task-delete elsewhere in this app. contenteditable
   is kept false (set in tickets.js) so it's always clickable, including
   inside a contenteditable editor, and is never treated as text content. */
ul.ck > li > .ck-delete {
  position: absolute; right: 0; top: 0; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0; opacity: 0; transition: opacity 0.1s;
}
ul.ck > li:hover > .ck-delete { opacity: 1; }
ul.ck > li > .ck-delete:hover { color: var(--red-text); }

/* ── Ticket drawer (slides in from the LEFT) ── */
.ticket-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 300;
  opacity: 0; transition: opacity 0.18s; pointer-events: none;
}
.ticket-overlay.open { opacity: 1; pointer-events: auto; }
.ticket-drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: 100%; max-width: 480px;
  background: var(--surface); box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; transform: translateX(-100%);
  transition: transform 0.22s ease; color: var(--text); font-size: 13px;
}
.ticket-overlay.open .ticket-drawer { transform: translateX(0); }
.ticket-drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 1rem 1.25rem; border-bottom: 0.5px solid var(--border); flex-shrink: 0;
}
.ticket-drawer-header h3 { font-size: 15px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ticket-drawer-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.ticket-drawer-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ticket-drawer-link { font-size: 12px; color: var(--blue-text); text-decoration: none; font-weight: 500; white-space: nowrap; }
.ticket-drawer-link:hover { text-decoration: underline; }
.ticket-drawer-close { background: none; border: none; font-size: 20px; line-height: 1; color: var(--text-3); cursor: pointer; padding: 0 4px; }
.ticket-drawer-close:hover { color: var(--text); }
.ticket-drawer-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 1.1rem; }

.ticket-flag-banner {
  display: none; align-items: center; gap: 8px; border-radius: var(--radius); padding: 8px 12px;
  font-size: 12px; font-weight: 500;
}
.ticket-flag-banner.on { display: flex; }
.ticket-flag-banner.flag-critical { background: var(--red-bg); color: var(--red-text); border: 0.5px solid var(--red); }
.ticket-flag-banner.flag-at_risk { background: var(--amber-bg); color: var(--amber-text); border: 0.5px solid var(--amber); }
.ticket-flag-banner.flag-resolved { background: var(--green-bg); color: var(--green-text); border: 0.5px solid var(--green); }

/* Shared outline utility — a flag is a BOLD OUTLINE, never a fill (the
   fill is the ticket's track color — see .card/.ticket-row's inline
   --track-color and the background rules near the bottom of this file).
   Applied directly as a second class alongside .card / .ticket-row /
   .dashboard-ticket-row, so one definition covers every surface a
   flagged ticket can appear on. */
.flag-critical { box-shadow: inset 0 0 0 3px var(--red); }
.flag-at_risk { box-shadow: inset 0 0 0 3px var(--amber); }
.flag-resolved { box-shadow: inset 0 0 0 3px var(--green); }

.ticket-track-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0;
}

/* Fills a card/row with its track's pastel color (set as --track-color
   inline by razor/assets/tickets.js's trackStyle()) blended against the
   page's own surface — one rule works in both themes since it mixes
   against whatever --surface currently is, and a left accent bar keeps
   the color legible even where the blend reads subtle. Pages opt in by
   adding `.ticket-track-fill` alongside their own card/row class. */
.ticket-track-fill {
  background: color-mix(in srgb, var(--track-color, transparent) 50%, var(--surface));
  border-left: 4px solid var(--track-color, transparent);
}

.ticket-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.ticket-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.ticket-field select, .ticket-field input[type="date"] {
  font-family: inherit; font-size: 12.5px; font-weight: normal; text-transform: none; letter-spacing: 0;
  color: var(--text); background: var(--surface); border: 0.5px solid var(--border-strong);
  border-radius: 6px; padding: 6px 8px;
}
body.dark .ticket-field select, body.dark .ticket-field input[type="date"] { background: var(--surface-1); }
.ticket-field select:disabled, .ticket-field input:disabled { opacity: 0.6; }
.ticket-select.s-todo { color: var(--gray-text); }
.ticket-select.s-in_progress { color: var(--blue-text); border-color: var(--blue); }
.ticket-select.s-int_blocked { color: var(--red-text); border-color: var(--red); }
.ticket-select.s-ext_blocked { color: var(--amber-text); border-color: var(--amber); }
.ticket-select.s-done { color: var(--green-text); border-color: var(--green); }
.ticket-flag-select.flag-critical { background: var(--red-bg); color: var(--red-text); border-color: var(--red); }
.ticket-flag-select.flag-at_risk { background: var(--amber-bg); color: var(--amber-text); border-color: var(--amber); }
.ticket-flag-select.flag-resolved { background: var(--green-bg); color: var(--green-text); border-color: var(--green); }
.ticket-flag-since { font-size: 10.5px; font-weight: normal; color: var(--text-3); text-transform: none; letter-spacing: 0; margin-top: 2px; }

.ticket-notes { display: flex; flex-direction: column; gap: 8px; }
.ticket-notes-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.ticket-notes-actions { display: flex; gap: 10px; text-transform: none; letter-spacing: 0; }
.ticket-link-btn { background: none; border: none; padding: 0; font: inherit; font-size: 12px; color: var(--blue-text); cursor: pointer; font-weight: 500; }
.ticket-link-btn:hover { text-decoration: underline; }
.ticket-link-btn.ticket-link-btn-danger { color: var(--red-text); }
.ticket-notes-view { font-size: 12.5px; line-height: 1.55; color: var(--text); word-wrap: break-word; min-height: 40px; }
.ticket-notes-view p { margin: 0 0 4px; }
.ticket-notes-empty { font-size: 12px; color: var(--text-3); font-style: italic; }
.ticket-notes-edit { display: flex; flex-direction: column; gap: 6px; }
.ticket-edit-actions { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.ticket-btn {
  font: inherit; font-size: 12px; font-weight: 500; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  background: var(--text); color: var(--surface); border: 1px solid var(--text);
}
body.dark .ticket-btn { background: var(--surface-1); color: var(--text); border-color: var(--border-strong); }
.ticket-btn:disabled { opacity: 0.6; cursor: default; }
.ticket-btn-cancel { background: none; color: var(--text-2); border-color: transparent; }
.ticket-btn-cancel:hover { color: var(--text); }
.ticket-drawer-meta { font-size: 11px; color: var(--text-3); border-top: 0.5px solid var(--border); padding-top: 10px; }
.ticket-drawer-error { background: var(--red-bg); color: var(--red-text); border: 0.5px solid var(--red); border-radius: var(--radius); padding: 8px 12px; font-size: 12px; display: none; }
.ticket-drawer-error.on { display: block; }

@media (max-width: 560px) {
  .ticket-controls { grid-template-columns: 1fr; }
}
