/* ── Board Toolbar ─────────────────────────────────────────── */

.board-section {
    padding: clamp(var(--space-sm), 4vw, var(--space-xl)) clamp(var(--space-sm), 4vw, var(--space-xl)) 0;
    background-color: var(--color-bg);
}

.board-top {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.board-top h1 {
    margin-right: auto;
}

.add-task-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 10px;
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.add-task-trigger-label {
    display: none;
}

.board-search-message {
    margin: calc(-1 * var(--space-md)) 0 var(--space-md);
    color: var(--color-text-muted);
    font-size: 16px;
}

.search-wrapper {
    position: relative;
    display: inline-block;
    order: 1;
    flex: 1 0 100%;
    width: 100%;
}

.search-wrapper input {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    padding: 12px 48px 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
}

/* ── Board Columns ─────────────────────────────────────────── */

.board-columns {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.board-column {
    min-width: 0;
    width: 100%;
}

.column-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-column-head);
    margin-bottom: 16px;
    width: 100%;
}

.column-head h3 {
    margin: 0;
}

.linediv {
    width: 1px;
    height: 21px;
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--color-border);
}

.empty-task {
    border: 1px dashed var(--color-text-muted);
    background-color: var(--color-empty-task-bg);
    color: var(--color-text-muted);
    text-align: center;
    padding: 16px;
    border-radius: var(--border-radius-md);
    pointer-events: none;
    width: 100%;
    box-sizing: border-box;
}

/* ── Task Card ─────────────────────────────────────────────── */

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    margin-bottom: 1.5rem;
}

.task-card {
    display: flex;
    flex-direction: column;
    background-color: var(--color-white);
    border-radius: var(--border-radius-xl);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-task-card);
    cursor: grab;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        opacity 0.15s ease;
        word-break: break-word;
    width: 220px;
    max-width: 220px;
    min-height: 170px;
    flex-shrink: 0;
}

.task-card:hover {
       transform: scale(1.02);
    }

.task-card.dragging {
    background-color: transparent;
    border: 2px dashed var(--color-border);
    box-shadow: none;
    cursor: grabbing;
}

.task-card.dragging * {
    visibility: hidden;
}

.task-card.drag-image {
    transform: rotate(3deg) scale(1.04);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    z-index: 1000;
    margin: 0;
}

.drop-indicator {
    border-radius: var(--border-radius-xl);
    border: 2px dashed var(--color-accent);
    background: rgba(var(--color-accent-rgb), 0.08);
    margin-bottom: 16px;
}

.task-category {
    max-width: fit-content;
    display: inline-block;
    color: var(--color-white);
    padding: 5px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 16px;
}

.user-story {
    background-color: var(--category-user-story);
}

.technical {
    background-color: var(--category-technical-task);
}

.bug {
    background-color: var(--category-bug);
}

.task-card h4 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    margin: 0 0 var(--space-2xs);
    color: var(--color-primary);
}

.task-card p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    color: var(--color-text-muted);
    margin: 0 0 16px;
    font-size: 16px;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 16px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background-color: #f4f4f4;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.progress-bar div {
    width: 0%;
    height: 100%;
    background-color: var(--color-progress);
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.avatar {
    display: inline-flex;
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-right: -8px;
    border: 1px solid var(--color-white);
}

.avatar-more {
    background: var(--color-primary);
}

/* ── Move Dropdown ─────────────────────────────────────────── */

.move-button {
    display: inherit;
    position: relative;
}

.category-nav {
    display: none;
    position: absolute;
    right: 0px;
    padding-left: 0px;
    z-index: 1;
}

/* Higher specificity than .dropdown's width:100% (global/dropdown.css) so it wins
   regardless of import order. */
.category-nav.dropdown {
    width: auto;
}

.category-nav.is-open {
    display: block;
}

.category-nav li {
    list-style-type: none;
    padding: 10px 0px;
}

.category-nav li:active {
    opacity: 0.6;
}

.category-nav ul {
    padding: 0 var(--space-md) var(--space-md) 20px;
    margin: 0px;
}

.category-nav h3 {
    margin: 0;
    padding: var(--space-md) var(--space-md) var(--space-xs) var(--space-md);
}

/* ── Add Task Modal ────────────────────────────────────────── */

.add-task-modal {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: clamp(var(--space-sm), 4vw, var(--space-xl));
    overflow-y: auto;
    box-sizing: border-box;
    position: relative;
}

.add-task-modal h1 {
    margin: 0 0 var(--space-lg);
}

.add-task-modal--edit {
    width: 525px;
    max-width: 100%;
    height: auto;
    max-height: 90vh;
    padding: 0;
}

/* align-items: stretch overrides add-task.css's >=768px .form-columns rule,
   which pairs flex-start with flex-direction: row - the edit modal stays
   column until its own 1024px switch below, so flex-start there would
   shrink each .form-col to its widest child instead of the full width.
   padding-top is a fixed value (not the usual clamp) because it exists to
   clear .add-task-modal > .close-btn, which is pinned at a fixed
   top: 24px / height: 32px regardless of viewport - not something that
   should shrink on narrow screens. */
.add-task-modal--edit .form-columns {
    padding: calc(24px + 32px + var(--space-sm)) clamp(var(--space-sm), 4vw, var(--space-xl)) 0;
    flex-direction: column;
    align-items: stretch;
}

.add-task-modal--edit .form-divider {
    display: none;
}

.add-task-modal--edit .form-col {
    padding: 0;
}

/* The regular add-task.css .task-form reserves 140px for its fixed mobile
   footer - the edit drawer's footer is sticky/in-flow instead, so that
   space would just be a dead gap here. */
.add-task-modal--edit .task-form {
    padding-bottom: 0;
}

.add-task-modal--edit .form-footer {
    position: sticky;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-md);
    padding: var(--space-md) clamp(var(--space-sm), 4vw, var(--space-xl));
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
}

.add-task-modal > .close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
}

.drag-area {
    cursor: pointer;
    min-height: 150px;
    display: flex;
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
}

.drag-area.drag-over {
    background-color: #e7f3ff;
    border-radius: var(--border-radius-xl);
    border: 2px dashed var(--color-progress);
    transition: background-color 0.2s ease;
}

/* Unconditional: only takes effect once .form-footer is position:fixed (mobile,
   see add-task.css), inert at desktop where it's position:static. */
.add-task-modal .form-footer {
    bottom: 0;
}

/* 768px here (not the usual 1024px tier) — synced with the .task-detail block
   further down and with global/modal.css's .modal--right, since both need to
   flip to the same full-screen-vs-centered-dialog point. This is just the
   modal's own breakpoint, independent of the board layout's own 1024px tier
   below. */
@media (min-width: 768px) {
    .add-task-modal {
        width: 1100px;
        height: auto;
        max-width: 90vw;
        max-height: 95vh;
        border-radius: var(--border-radius-lg);
    }
}

/* Restores the same two-column form-columns/form-divider layout add-task.css
   gives the regular add-task modal at this width — .add-task-modal--edit's
   own rules above (single column, narrow 525px) are mobile/tablet-only. */
@media (min-width: 1024px) {
    .add-task-modal--edit {
        width: 1100px;
        padding: clamp(var(--space-sm), 4vw, var(--space-xl));
    }

    .add-task-modal--edit .form-columns {
        padding: 0;
        flex-direction: row;
        align-items: flex-start;
    }

    .add-task-modal--edit .form-divider {
        display: block;
    }

    .add-task-modal--edit .form-col {
        padding: 0 var(--space-lg);
    }

    .add-task-modal--edit .form-footer {
        position: static;
        margin-top: 0;
        padding: var(--space-sm) 0 0 0;
        border-top: none;
        background: transparent;
    }
}

/* 1366px is intentional here (not the usual 1024px tier) — the board keeps its
   mobile/tablet layout (stacked columns, horizontally-scrolling cards) all the
   way through the most common laptop width, only switching to the 5-column
   desktop grid once there's genuinely enough room for it. */
@media (min-width: 1366px) {
    .board-top {
        flex-wrap: nowrap;
        gap: var(--space-md);
        margin-bottom: 40px;
    }

    .search-wrapper {
        order: 0;
        flex: 0 1 auto;
        width: auto;
    }

    .add-task-trigger {
        display: inline-block;
        width: auto;
        height: auto;
        padding: 8px var(--space-md);
        border-radius: var(--border-radius-md);
        font-size: 16px;
        line-height: normal;
        flex-shrink: 1;
    }

    .add-task-trigger-label {
        display: inline;
    }

    .search-wrapper input {
        width: 200px;
        box-sizing: content-box;
        font-size: 16px;
        padding: 10px var(--space-2xs);
    }

    .board-columns {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
    }

    .drag-area {
        flex-direction: column;
        overflow-x: visible;
    }


    .task-card {
        width: auto;
        max-width: none;
        min-height: auto;
        flex-shrink: 1;
    }

    .board-column {
        width: auto;
    }

    .column-head {
        width: auto;
    }

    .empty-task {
        width: auto;
        box-sizing: content-box;
    }


    .task-card p {
        font-size: 16px;
    }

    .progress-row {
        font-size: 16px;
    }

    .avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .move-button {
        display: none;
    }
}


/* ── Task Detail Modal ───────────────────────────────────── */

.task-detail {
    width: 90vw;
    max-height: 95vh;
    padding: clamp(var(--space-sm), 4vw, var(--space-lg));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    word-break: break-word;
}

.task-header{
    display: flex;
    justify-content: space-between;
}

.task-header-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs);
}

.ai-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
}

/* the text is cut out of the gradient background */
.ai-hint-text {
    background: var(--gradient-ai-text);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}


.task-detail-title {
    color: var(--color-text);
    margin: 0;
}

.task-detail-description {
    color: var(--color-text);
    font-size: 1rem;
    line-height: 1.5;
    margin: 0;
}

.task-detail-label {
    font-weight: var(--font-weight-regular);
    color: var(--color-primary);
    margin: 0;
}

.task-detail-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.task-detail-row .task-detail-label {
    min-width: 100px;
}

/* Creator row: on mobile the tag wrapper is moved first and takes a full
   line (the tag inside keeps its own width); on desktop it's all one row. */
.task-detail-creator {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs);
}

/* Basis 0 keeps label, name and hint on one line even at 320px: the name
   takes the space left between them and is cut with "…" if it's too long. */
.creator-name {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.creator-tag-wrap {
    order: -1;
    flex-basis: 100%;
}

.creator-tag,
.creator-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px var(--space-xs);
    border-radius: var(--border-radius-xs);
    font-size: 16px;
}

.creator-tag {
    color: var(--color-tag-text);
}

.creator-tag--member {
    background: var(--color-member-bg);
}

.creator-tag--external {
    background: var(--color-external-bg);
}

/* pushed to the right end; label, tag and name stay together on the left */
.creator-link {
    margin-left: auto;
    color: var(--color-column-head);
}

/* beats base.css a:hover (blue, underline, scale); the icon keeps its color */
.creator-link:hover {
    background: var(--color-primary);
    color: var(--color-white);
    text-decoration: none;
    transform: none;
}

.task-detail-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.task-detail-contact {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 16px;
}

/* Caps the list to --visible-rows (40px avatar height + gap each) before
   scrolling vertically: 2 rows up to 768px, 3 up to 1024px, 4 from there. */
.task-detail-assigned-list {
    --visible-rows: 2;
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
    max-height: calc(var(--visible-rows) * 40px + (var(--visible-rows) - 1) * var(--space-2xs));
    overflow-y: auto;
}

.task-detail-muted {
    color: var(--color-text-muted);
    font-size: 16px;
    margin: 0;
}

/* Caps the list to --visible-rows (20px checkbox icon + 2 * 4px vertical
   padding each) before scrolling vertically: same 2/3/4 row steps as
   .task-detail-assigned-list above. */
.task-detail-subtask-list {
    --visible-rows: 2;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: calc(var(--visible-rows) * 28px + (var(--visible-rows) - 1) * var(--space-xs));
    overflow-y: auto;
}

@media (min-width: 768px) {
    .task-detail-assigned-list,
    .task-detail-subtask-list {
        --visible-rows: 3;
    }

    /* Creator row: everything in one row, spread out by space-between */
    .creator-tag-wrap {
        order: 0;
        flex-basis: auto;
    }

    .task-detail-creator .task-detail-label {
        /* 8px gap + 16px = the 24px label gap of the rows above */
        margin-right: var(--space-sm);
    }

    .creator-name {
        flex: 0 1 auto;
    }
}

@media (min-width: 1024px) {
    .task-detail-assigned-list,
    .task-detail-subtask-list {
        --visible-rows: 4;
    }
}

.task-detail-subtask .checkbox {
    padding: var(--space-xs) 0;
    font-size: 16px;
}

.priority-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-xs) 12px;
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
}

.task-detail-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: auto;
    padding-top: var(--space-md);
}

.task-detail-action {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--space-2xs) 12px;
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    color: var(--color-primary);
    transition: background var(--transition-fast);
}

.task-detail-action:hover { background: var(--color-bg); }

.task-detail-action-divider {
    width: 1px;
    height: 24px;
    background: var(--color-border);
}

/* 768px synced with the block above and global/modal.css — see comment there */
@media (min-width: 768px) {
    .task-detail {
        width: 525px;
        gap: var(--space-md);
    }
}
