/* Design 1a — "flat board". The board is DEFEX page furniture, not a tinted surface of its
   own: a #F4F6FA ground (--defex-inner-bg) carrying white columns and white cards, each
   separated by the 1px ghost rule (--defex-ghost-edge). Before this the column was a
   --mud-palette-tertiary slab holding a shadowed card on a tinted dialog body, so three
   blue-ish surfaces stacked and nothing read as foreground. Colour is now reserved for
   status (the column dot) and for genuine urgency (an overdue chip on a card). */
.kanban-root {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    overflow-x: auto;
    padding: 20px;
}

.kanban-column {
    flex: 0 0 288px;
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--defex-ghost-edge, #DEE2ED);
    border-radius: var(--mud-default-borderradius, 5px);
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 280px);
    padding: 0;
    transition: border-color 120ms ease, background 120ms ease;
    outline: 2px solid transparent;
    outline-offset: -2px;
}

.kanban-column.drag-over {
    outline-color: var(--mud-palette-primary, #594ae2);
    background: var(--defex-inner-bg, #F4F6FA);
}

.kanban-column.collapsed {
    flex-basis: 48px;
}

.kanban-column.collapsed .kanban-column-header {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    justify-content: flex-start;
    padding: 12px 6px;
    border-bottom: 0;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--defex-ghost-edge, #DEE2ED);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--mud-palette-text-primary, rgba(0, 0, 0, 0.87));
    cursor: pointer;
    user-select: none;
}

/* The count is a plain muted number, not a filled pill: on a white header a filled
   counter competes with the status dot for the one bit of colour the header carries. */
.kanban-column-count {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--mud-palette-text-secondary, #6B7280);
    padding: 0;
    border-radius: 0;
    background: transparent;
}

.kanban-column-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1 1 auto;
    scrollbar-width: thin;
}

.kanban-column-actions {
    display: flex;
    align-items: center;
    margin-left: 2px;
}

.kanban-column-footer {
    padding: 0;
    margin-top: 2px;
}

/* Bordered, unshadowed at rest — the lift arrives on hover, so a full column does not
   read as a stack of floating tiles. */
.kanban-card {
    background: var(--mud-palette-surface, #fff);
    border: 1px solid var(--defex-ghost-edge, #DEE2ED);
    border-radius: var(--mud-default-borderradius, 5px);
    padding: 0;
    box-shadow: none;
    cursor: grab;
    transition: box-shadow 120ms cubic-bezier(.4, 0, .2, 1), border-color 120ms ease;
}

.kanban-card:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, .08), 0 1px 3px rgba(0, 0, 0, .06);
    border-color: color-mix(in srgb, var(--defex-ghost-edge, #DEE2ED) 60%, var(--mud-palette-text-secondary, #6B7280));
    transform: none;
}

.kanban-card:focus-visible {
    outline: 2px solid var(--mud-palette-primary, #594ae2);
    outline-offset: 1px;
}

.kanban-card:active {
    cursor: grabbing;
}

/* To Do card: hover-reveal "mark complete" radio that slides the title to the right.
   The toggle expands from 0 width on card hover/focus, pushing the title across with it. */
.todo-title-row {
    display: flex;
    align-items: center;
    min-width: 0;
    margin-top: 4px;
}

.todo-complete-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateX(-6px);
    transition: width 150ms ease, opacity 150ms ease, transform 150ms ease;
}

.kanban-card:hover .todo-complete-toggle,
.kanban-card:focus-within .todo-complete-toggle {
    width: 26px;
    opacity: 1;
    transform: translateX(0);
}

.todo-complete-toggle .todo-complete-btn {
    padding: 1px;
}

/* To Do card: compact notes/conversation count buttons (icon + count beside it). */
.todo-count-btn {
    min-width: 0;
    padding: 1px 6px;
}

.todo-count-btn .mud-button-label {
    font-size: 0.75rem;
    font-weight: 600;
    gap: 2px;
}

/* ---- To Do labels (coloured tags) ---- */

/* Label picker button pinned to the top-right corner of the card. */
.todo-card-body {
    position: relative;
}

.todo-card-label-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 2;
}

/* Reserve space at the top so the title / chips don't run under the pinned button. */
.todo-card-body .todo-title-row,
.todo-card-body .todo-label-chips {
    padding-right: 30px;
}

/* Coloured label chips shown on cards, rows and detail pages. */
.todo-label-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.todo-label-chip {
    display: inline-flex;
    align-items: center;
    max-width: 160px;
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.45;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Transparent full-screen catcher that closes the picker on an outside click. */
.todo-label-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: transparent;
}

/* Label picker popover (Trello-style). */
.todo-label-picker {
    width: 280px;
    max-width: 90vw;
}

.todo-label-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 0;
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.todo-label-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.todo-label-bar {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.todo-label-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.todo-label-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    box-sizing: border-box;
    transition: transform 80ms ease, border-color 80ms ease;
}

.todo-label-swatch:hover {
    transform: scale(1.08);
}

.todo-label-swatch.selected {
    border-color: var(--mud-palette-text-primary, rgba(0, 0, 0, 0.7));
}

/* ============================================================
   MY TO DO LIST — design 1a chrome (MyToDoTask.razor)

   Header and toolbar stay white, the board sits on the flat #F4F6FA ground. The dialog
   is .defex-dialog-fullbleed, and dialogs.css paints those bodies with the Design D
   blue radial ground; on a board that ground is the third blue-ish surface in the stack
   and the columns stop reading as foreground, so this one dialog opts out into a flat
   fill. Scoped by the .todo-board-dialog marker so every other full-bleed dialog keeps
   the shared ground.
   ============================================================ */
.mud-dialog.todo-board-dialog .mud-dialog-content > .mud-paper {
    background: var(--mud-palette-surface, #fff) !important;
}

.todo-board-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 20px;
    background: var(--mud-palette-surface, #fff);
    border-bottom: 1px solid var(--defex-ghost-edge, #DEE2ED);
}

.todo-board-toolbar .todo-toolbar-label {
    color: var(--mud-palette-text-secondary, #6B7280);
}

/* The board ground. Flat, edge to edge, and the only non-white surface in the dialog. */
.todo-board-ground {
    background: var(--defex-inner-bg, #F4F6FA);
    min-height: 240px;
}

/* View switch as underline tabs. MudToggleGroup is the control the page already uses;
   only its skin changes here — a filled segmented pair sitting above the content would
   again be the heaviest thing on screen. */
.todo-view-tabs.mud-toggle-group {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    gap: 0;
}

.todo-view-tabs .mud-toggle-item {
    border: 0 !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 0;
    background: transparent !important;
    color: var(--mud-palette-text-secondary, #6B7280) !important;
    padding: 12px 16px;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0;
}

.todo-view-tabs .mud-toggle-item:hover {
    color: var(--mud-palette-text-primary) !important;
}

/* SelectedClass is a MudToggleGroup parameter, so the marker is guaranteed regardless of
   MudBlazor's own selected-state class names. Both forms are matched because the class
   lands on the item element in the current build and on its wrapper in others. */
.todo-view-tabs .mud-toggle-item.todo-toggle-selected,
.todo-view-tabs .todo-toggle-selected .mud-toggle-item {
    border-bottom-color: var(--mud-palette-primary) !important;
    color: var(--mud-palette-text-primary) !important;
    background: transparent !important;
}

/* Group-by segmented control: light, bordered, selected segment washed with primary
   rather than filled black. */
.todo-groupby-toggle.mud-toggle-group {
    border: 1px solid var(--defex-ghost-edge, #DEE2ED);
    border-radius: var(--mud-default-borderradius, 5px);
    overflow: hidden;
    background: var(--mud-palette-surface, #fff);
}

.todo-groupby-toggle .mud-toggle-item {
    border: 0 !important;
    border-right: 1px solid var(--defex-ghost-edge, #DEE2ED) !important;
    border-radius: 0;
    background: var(--mud-palette-surface, #fff) !important;
    color: var(--mud-palette-text-secondary, #6B7280) !important;
    padding: 5px 14px;
    font-size: 0.75rem;
    font-weight: 500;
}

.todo-groupby-toggle .mud-toggle-item:last-child {
    border-right: 0 !important;
}

.todo-groupby-toggle .mud-toggle-item:hover {
    background: var(--defex-inner-bg, #F4F6FA) !important;
}

.todo-groupby-toggle .mud-toggle-item.todo-toggle-selected,
.todo-groupby-toggle .todo-toggle-selected .mud-toggle-item {
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-surface)) !important;
    color: var(--mud-palette-text-primary) !important;
}

/* Column status dot — the board's one piece of saturated colour, replacing the filled
   status pill that used to outweigh the to-dos it labelled. */
.todo-column-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

/* Completed to-dos recede: the card is done, so it drops to the inner fill and its
   title goes secondary and struck through. */
.kanban-card:has(> .todo-card--done) {
    background: var(--defex-inner-bg, #F4F6FA);
}

.todo-card--done .todo-title-row .mud-typography {
    color: var(--mud-palette-text-secondary, #6B7280) !important;
    text-decoration: line-through;
}

/* Per-column "Add a To Do" — a quiet primary text button, not a grey block. */
.kanban-column-footer .todo-add-card-btn {
    justify-content: flex-start;
    color: var(--mud-palette-primary);
    font-size: 0.78125rem;
    font-weight: 500;
}

/* ============================================================
   1a corrections — measured against the design, not the description.

   Two things the first pass got wrong:

   1. THE COLUMNS STILL STOPPED HALFWAY. 1a's whole board is a grid
      (grid-template-columns:repeat(4,1fr)); the flex track kept the old fixed 288px
      basis, so on a 1536px dialog three status columns filled 900px and the right
      two-fifths stayed empty — the exact defect 1a was drawn to fix. auto-fit rather
      than a literal 4: this board also groups by Priority (5) and Due Date (6), so a
      hard column count would either overflow or strand cells.

   2. THE ACCENT RESOLVED TO NAVY. 1a's active tab underline is #155DFC and its selected
      Group-by segment is #D8E2F8; both were wired to --mud-palette-primary, which in this
      theme is near-black (#0B1220), so the selected states came back grey. The accent is
      a local literal here, the same way every other Design D surface file carries its own
      (--adx-brand, --gsh-accent, --alc-brand).
   ============================================================ */
.mud-dialog.todo-board-dialog {
    --todo-accent: #155DFC;
    --todo-accent-wash: #D8E2F8;
}

.defex-theme-dark .mud-dialog.todo-board-dialog {
    --todo-accent: #6E9BFF;
    --todo-accent-wash: rgba(110, 155, 255, 0.20);
}

/* The board fills the dialog. Scoped to this dialog so the ToDoTasks widget board keeps
   its scrolling flex track, where a narrow host column makes 1fr cells unreadable. */
.todo-board-dialog .kanban-root {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
    gap: 16px;
    align-items: start;
    overflow-x: visible;
}

.todo-board-dialog .kanban-column {
    flex: initial;
    min-width: 0;
}

/* 1a puts the count beside the name as muted running text ("3 to dos"), not as a
   right-aligned figure — the header then reads as one phrase instead of a label and a
   number pinned to opposite ends. The unit comes from Kanban's CountSuffix. */
.todo-board-dialog .kanban-column-count {
    margin-left: 0;
    margin-right: auto;
}

.todo-view-tabs .mud-toggle-item.todo-toggle-selected,
.todo-view-tabs .todo-toggle-selected .mud-toggle-item {
    border-bottom-color: var(--todo-accent, #155DFC) !important;
}

.todo-groupby-toggle .mud-toggle-item.todo-toggle-selected,
.todo-groupby-toggle .todo-toggle-selected .mud-toggle-item {
    background: var(--todo-accent-wash, #D8E2F8) !important;
}

.kanban-column-footer .todo-add-card-btn {
    color: var(--todo-accent, #155DFC);
}

/* Card due date — 1a's quiet meta line. Muted by default; it earns colour only when the
   date is the urgent thing on the card (the razor adds --urgent from GetDueDateSeverity). */
.todo-card-due {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--mud-palette-text-secondary, #6B7280);
    white-space: nowrap;
}

.todo-card-due .mud-icon-root {
    font-size: 0.875rem;
}

.todo-card-due--urgent {
    color: #8F1C1C;
    font-weight: 500;
}

.defex-theme-dark .todo-card-due--urgent {
    color: #FF8A80;
}

/* The completed tick sits on the title's first line, ahead of the struck description. */
.todo-done-tick {
    flex: 0 0 auto;
    margin-right: 6px;
    font-size: 1rem !important;
}

/* ============================================================
   A FIXED SHELL. The dialog used to size itself to the board: three columns and it was
   short, a full Open column and it was tall, and switching Board/Calendar or Group by
   resized it under the pointer — the Add To Do button and the tab strip moved every time
   the content changed. Everything inside was doing its own viewport arithmetic
   (max-height: calc(100dvh - 380px) on the board, calc(100dvh - 360px) on the calendar,
   calc(100dvh - 280px) per column), so three different sums decided the height and none
   of them agreed.

   Now one rule owns it: the dialog is a fixed-height flex column, the title bar and
   toolbar are auto-height, and the ground is the single scroll box. min-height:0 on every
   flex child is load-bearing — a flex item's default min-height:auto refuses to shrink
   below its content, which is exactly how a "fixed" height silently grows again.

   Fullscreen (UIConstants.IsCompactView passes FullScreen) is excluded: MudBlazor sizes
   that itself, and a calc() height there would leave a gap at the bottom of the screen.
   ============================================================ */
.mud-dialog.todo-board-dialog:not(.mud-dialog-fullscreen) {
    height: calc(100dvh - 140px);
    max-height: calc(100dvh - 140px);
}

.mud-dialog.todo-board-dialog {
    display: flex;
    flex-direction: column;
}

/* Beats dialogs.css's shared .defex-dialog-fullbleed rule, which caps the content at
   calc(100dvh - 200px) and scrolls it — with a fixed shell the cap is now the shell's job
   and the scroll belongs to the ground, or the board gets two nested scrollbars. */
.mud-dialog.todo-board-dialog .mud-dialog-content {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mud-dialog.todo-board-dialog .mud-dialog-content > .mud-paper {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* THE one scroll box. */
.todo-board-ground {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.todo-board-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.todo-board-scroll {
    flex: 1 1 auto;
    min-height: 0;
}

/* The columns no longer cap themselves against the viewport — the ground already bounds
   them, and a second cap meant a column could scroll inside a board that also scrolled. */
.todo-board-dialog .kanban-column {
    max-height: none;
}

.todo-calendar-surface {
    flex: 1 1 auto;
    min-height: 420px;
}
