/*
 * tasks.css — task rows, the task popup, the task form and the My Tasks widget.
 *
 * CORE, and loaded on every page (web/core/config/config.php), because none of
 * these belong to one page: the popup and form open from the dashboard widget,
 * from ?viewtask= links in an email, and from any module that raises tasks.
 * The Tasks page's own layout (banner, tabs, board) is the module's styles.css.
 *
 * The intranet palette, as --tk- tokens so nothing here leaks into a page that
 * defines its own. Everything is under a .tk- class for the same reason.
 */

:root {
    --tk-ink: #12313B;
    --tk-muted: #4A626A;
    --tk-line: #D5E3E7;
    --tk-line-soft: #EAF1F3;
    --tk-field: #B9CDD3;
    --tk-ground: #F3F7F8;
    --tk-primary: #105460;
    --tk-primary-dark: #0B3A42;
    --tk-tint: #E4F1F4;
    --tk-tint-line: #CFE3E8;
    --tk-live: #2E7D47;
    --tk-warn-ink: #5A3E00;
    --tk-warn-bg: #FFF6E5;
    --tk-danger: #A3362A;
    --tk-danger-ink: #7E2A20;
    --tk-danger-bg: #FBEDEB;
}

/* ---------- rows ---------- */

.tk-list { list-style: none; margin: 0; padding: 0; }

.tk-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 11px 16px;
    border-bottom: 1px solid var(--tk-line-soft);
    background: #FFFFFF;
    font-size: 14px;
    color: var(--tk-ink);
}
.tk-row:last-child { border-bottom: 0; }
.tk-row:hover { background: #FAFCFC; }

/* a row that can be dragged has a fourth column for the grip */
.tk-row.tk-sortable { grid-template-columns: 20px minmax(0, 1fr) auto 18px; }
/* placed, because a row with no date or link has no third cell to push it */
.tk-row.tk-sortable > .tk-grip { grid-column: 4; grid-row: 1; }

.tk-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tk-row a.tk-row-title {
    color: var(--tk-ink);
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.tk-row a.tk-row-title:hover { color: var(--tk-primary); text-decoration: underline; }
.tk-row-sub { font-size: 12.5px; color: var(--tk-muted); }
.tk-row-repeat { color: var(--tk-muted); font-size: 11px; margin-left: 4px; }
.tk-row-trail { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* finished rows */
.tk-row.tk-done a.tk-row-title { color: var(--tk-muted); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--tk-field); }
.tk-row.tk-done .tk-row-sub { color: #6E848C; }

/* The checkbox, drawn rather than left to the browser, so it is the same size
   and color on every page that shows a task. */
input.tk-tick {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 2px solid var(--tk-field);
    border-radius: 5px;
    background: #FFFFFF;
    cursor: pointer;
    display: inline-grid;
    place-content: center;
}
input.tk-tick:hover { border-color: var(--tk-primary); }
input.tk-tick:focus-visible { outline: 2px solid var(--tk-primary); outline-offset: 2px; }
input.tk-tick:checked { background: var(--tk-primary); border-color: var(--tk-primary); }
input.tk-tick:checked::after {
    content: '';
    width: 9px;
    height: 5px;
    border: 2px solid #FFFFFF;
    border-top: 0;
    border-right: 0;
    transform: translateY(-1px) rotate(-45deg);
}
/* A module's task: finished there, so a dashed box where the checkbox would be
   says "not ticked here" instead of leaving a gap that reads as a bug. */
.tk-tick-elsewhere {
    width: 18px;
    height: 18px;
    border: 2px dashed var(--tk-field);
    border-radius: 5px;
    background: var(--tk-ground);
    display: inline-block;
}

/* the due chip */
.tk-due {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 11px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    background: var(--tk-ground);
    color: var(--tk-muted);
}
.tk-due-over { background: var(--tk-danger-bg); color: var(--tk-danger-ink); }
.tk-due-soon { background: var(--tk-warn-bg); color: var(--tk-warn-ink); }

/* where a module's task is done */
a.tk-go {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--tk-field);
    background: #FFFFFF;
    color: var(--tk-primary);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}
a.tk-go:hover { border-color: var(--tk-primary); background: var(--tk-tint); color: var(--tk-primary-dark); }

.tk-grip {
    color: #A9BCC2;
    cursor: grab;
    text-align: center;
    touch-action: none;
}
.tk-grip:hover { color: var(--tk-primary); }
.tk-grip:active { cursor: grabbing; }

.tk-count {
    display: inline-block;
    min-width: 20px;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--tk-tint);
    color: var(--tk-primary-dark);
    font: 700 11.5px/1.5 'Open Sans', sans-serif;
    text-align: center;
    vertical-align: middle;
}

.tk-empty { margin: 0; padding: 14px 16px; color: var(--tk-muted); font-size: 13.5px; }

/* ---------- quick add ---------- */

.tk-quick { display: flex; gap: 8px; align-items: center; margin: 0; }
.tk-quick .tk-quick-input { flex: 1; min-width: 0; height: 40px; border-color: var(--tk-field); border-radius: 8px; }
.tk-quick .tk-quick-input:focus { border-color: var(--tk-primary); box-shadow: 0 0 0 3px rgba(16, 84, 96, .15); }
.tk-quick.is-busy .tk-quick-input { background: var(--tk-ground); }

/* ---------- the task popup ---------- */

.tk-view { color: var(--tk-ink); }
.tk-view-head { padding: 0 0 12px; }
.tk-view-source { margin: 0 0 2px; font-size: 13px; color: var(--tk-muted); }
.tk-view-head h3 { margin: 0; font: 500 22px/1.25 'Roboto', sans-serif; color: var(--tk-ink); text-wrap: balance; }
.tk-view-body { display: grid; grid-template-columns: minmax(0, 1fr) 220px; border-top: 1px solid var(--tk-line); }
.tk-view-main { padding: 16px 18px 16px 0; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tk-view-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tk-view-actions .btn { display: inline-flex; align-items: center; gap: 7px; }
.tk-view-state { font-size: 13px; color: var(--tk-live); font-weight: 600; }
.tk-view-state:empty { display: none; }
.tk-view-note { margin: 0; padding: 10px 12px; background: var(--tk-tint); border-radius: 8px; font-size: 13.5px; }
.tk-view-desc { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.tk-view-desc img { max-width: 100%; height: auto; }
.tk-view-edit { margin: 0; }
.tk-view-side { padding: 16px 0 16px 18px; border-left: 1px solid var(--tk-line); font-size: 13px; }
.tk-view-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 12px; margin: 0; }
.tk-view-facts dt { color: var(--tk-muted); font-weight: 600; }
.tk-view-facts dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 640px) {
    .tk-view-body { grid-template-columns: minmax(0, 1fr); }
    .tk-view-main { padding-right: 0; }
    .tk-view-side { padding-left: 0; border-left: 0; border-top: 1px solid var(--tk-line); }
}

/* ---------- the task form ---------- */

.tk-form { display: flex; flex-direction: column; gap: 14px; color: var(--tk-ink); }
.tk-form .tk-form-title { margin: 0; font: 500 22px/1.25 'Roboto', sans-serif; color: var(--tk-ink); }
.tk-form-cat { color: var(--tk-muted); font-size: 16px; }
.tk-form label { font-weight: 700; font-size: 13.5px; text-transform: none; letter-spacing: 0; margin-bottom: 4px; }
.tk-form .label-info { display: block; margin-top: 4px; font-size: 12px; color: var(--tk-muted); }
.tk-form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.tk-form-field:empty { display: none; }
.tk-form-details .note-editor { border-color: var(--tk-field); border-radius: 8px; overflow: hidden; }
.tk-form-more { border: 1px solid var(--tk-line); border-radius: 10px; padding: 0 14px; }
.tk-form-more > summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 13.5px; color: var(--tk-primary); }
.tk-form-more[open] { padding-bottom: 14px; }
.tk-form-foot { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 12px; border-top: 1px solid var(--tk-line-soft); }
.tk-form-foot .tk-form-delete { margin-left: auto; }

@media (max-width: 640px) {
    .tk-form-row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- the dashboard widget ---------- */

.tk-widget { display: flex; flex-direction: column; gap: 10px; color: var(--tk-ink); }
.tk-widget-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tk-widget .tk-widget-title { margin: 0; font: 500 20px/1.2 'Roboto', sans-serif; display: inline-flex; align-items: center; gap: 8px; }
.tk-widget .tk-widget-title a { color: var(--tk-ink); text-decoration: none; }
.tk-widget .tk-widget-title a:hover { color: var(--tk-primary); }
.tk-widget .tk-widget-title i { color: var(--tk-primary); }
.tk-widget .tk-widget-more { padding: 3px 9px; font-size: 13px; }
.tk-widget .tk-quick-input { height: 36px; font-size: 13.5px; }
.tk-widget-list { border: 1px solid var(--tk-line); border-radius: 10px; overflow: hidden; background: #FFFFFF; }
.tk-list-compact .tk-row { padding: 8px 12px; gap: 10px; font-size: 13.5px; }
.tk-list-compact a.tk-go { height: 26px; font-size: 12px; }
.tk-widget-all { align-self: flex-start; font-size: 13px; font-weight: 600; color: var(--tk-primary); text-decoration: none; }
.tk-widget-all:hover { text-decoration: underline; }
