/* ══════════════════════════════════════════════════════════════
   TaskPoint — Task Detail Page
   /projects/{pid}/tasks/{tid}
   ══════════════════════════════════════════════════════════════ */

.td-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}

/* ── Main Column ── */
.td-main {
    min-width: 0;
}

.td-header {
    margin-bottom: 1.5rem;
}

.td-back-link {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 0.75rem;
}

.td-back-link:hover { color: var(--signal); }

.td-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.td-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.td-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.td-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.75rem;
    min-width: 0;
}

.td-meta-item > span:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-meta-label {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 500;
}

.td-meta-user {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ink);
    font-weight: 500;
}

/* ── Avatar ── */
.td-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--signal-soft);
    color: var(--signal);
    font-size: 0.55rem;
    font-weight: 700;
    flex-shrink: 0;
    vertical-align: middle;
}

.td-comment-author .td-avatar { width: 1.2rem; height: 1.2rem; font-size: 0.5rem; }

/* ── Show All Button ── */
.td-show-all-btn {
    background: none;
    border: none;
    color: var(--signal);
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
}

.td-show-all-btn:hover { background: var(--signal-soft); }

/* ── Upload Progress ── */
.td-upload-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--surface-2);
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
}

.td-upload-progress {
    flex: 1;
    height: 4px;
    background: var(--hairline);
    overflow: hidden;
}

.td-upload-fill {
    height: 100%;
    width: 0%;
    background: var(--signal);
    transition: width 0.2s;
}

.td-upload-text {
    font-size: 0.625rem;
    color: var(--muted);
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* ── Pending Files ── */
.td-pending-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.td-pending-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6875rem;
    color: var(--signal);
    background: var(--signal-soft);
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--hairline);
}

.td-pending-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.625rem;
    padding: 0;
    line-height: 1;
}

.td-pending-remove:hover { color: var(--err); }

.td-desc {
    font-size: 0.8125rem;
    color: var(--ink);
    line-height: 1.5;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--hairline);
    margin-bottom: 0;
}

.td-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.td-action-btn {
    width: 100%;
    text-align: center;
}

.td-action-hr {
    border: none;
    border-top: 1px solid var(--hairline);
    margin: 0.25rem 0;
}

/* ── Chat ── */
.td-chat {
    background: var(--surface);
    border: 1px solid var(--hairline);
    overflow: hidden;
}

.td-chat-messages {
    padding: 1rem;
    max-height: 55vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.td-chat-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--muted);
    font-size: 0.8125rem;
}

.td-comment {
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 0.75rem;
}

.td-comment:last-child { border-bottom: none; }

.td-comment-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.td-comment-author {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--ink);
    display: inline-flex; align-items: center; gap: 0.35rem;
}
.td-role-badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: 1px solid;
}
.td-role-badge.role-owner { color: var(--overdue); border-color: var(--overdue); }
.td-role-badge.role-manager { color: var(--approaching); border-color: var(--approaching); }

.td-comment-time {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    color: var(--muted);
}

.td-comment-actions {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.td-comment:hover .td-comment-actions { opacity: 1; }

.td-comment-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.6875rem;
    color: var(--muted);
    padding: 0.1rem 0.25rem;
}

.td-comment-action-btn:hover { color: var(--err); background: var(--overdue-soft); }

.td-comment-body {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--ink);
    word-break: break-word;
}

.td-comment-body .mention {
    color: var(--medium-priority);
    font-weight: 500;
    cursor: pointer;
}

.td-comment-body .mention:hover { text-decoration: underline; }

.td-comment-files {
    margin-top: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.td-file-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: var(--signal);
    text-decoration: none;
    background: var(--signal-soft);
    padding: 0.15rem 0.5rem;
}

.td-file-badge:hover { background: var(--signal); color: var(--on-signal); }
.td-file-badge:hover .td-file-preview { color: var(--on-signal); }

.td-file-preview {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.td-file-preview:hover { text-decoration: underline; }

/* ── Chat Input ── */
.td-chat-input-area {
    border-top: 1px solid var(--hairline);
    padding: 0.75rem;
    position: relative;
}

.td-chat-input {
    width: 100%;
    border: 1px solid var(--hairline);
    padding: 0.5rem 0.7rem;
    font-size: 0.8125rem;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--surface-2);
    outline: none;
    resize: vertical;
    min-height: 2.5rem;
}

.td-chat-input:focus { border-color: var(--signal); }

.td-chat-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.td-attach-info {
    font-size: 0.75rem;
    color: var(--approaching);
    line-height: 1;
}

/* ── Mention Dropdown ── */
.td-mention-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0.75rem;
    right: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--hairline);
    box-shadow: var(--card-hover-shadow);
    z-index: 50;
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 0.25rem;
}

.td-mention-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.7rem;
    border: none;
    background: none;
    font-size: 0.75rem;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-body);
}

.td-mention-item:hover { background: var(--surface-2); }

/* ── Sidebar ── */
.td-sidebar {
    position: sticky;
    top: 5rem;
}

.td-sidebar-section {
    background: var(--surface);
    border: 1px solid var(--hairline);
    padding: 1rem;
}

.td-history {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.td-history-item {
    font-size: 0.6875rem;
    line-height: 1.4;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--hairline);
    word-break: break-word;
}

.td-sidebar .td-history-item {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.td-history-item:last-child { border-bottom: none; }

.td-history-time {
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    color: var(--muted);
    margin-right: 0.3rem;
}

.td-file-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 0.75rem;
    gap: 0.4rem;
}

.td-file-row:last-child { border-bottom: none; }

.td-file-row a {
    color: var(--signal);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.td-file-row a:hover { text-decoration: underline; }

.td-file-meta {
    display: block;
    font-size: 0.625rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.td-file-delete {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 0.6875rem;
    padding: 0.1rem 0.2rem;
    flex-shrink: 0;
}

.td-file-delete:hover { color: var(--err); background: var(--overdue-soft); }

.td-file-size {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    color: var(--muted);
    white-space: nowrap;
}

/* ── XLSX Preview ── */
.xlsx-scroll {
    -webkit-overflow-scrolling: touch;
}

.xlsx-table {
    border-collapse: collapse;
    font-size: 0.6875rem;
    font-family: var(--font-body);
}

.xlsx-table td, .xlsx-table th {
    border: 1px solid var(--hairline-strong);
    padding: 0.2rem 0.45rem;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

.xlsx-table thead th {
    font-weight: 600;
    color: var(--muted);
    text-align: center;
}

.xlsx-table tbody tr:hover td {
    filter: brightness(0.96);
}

[data-theme="dark"] .xlsx-table tbody tr:hover td {
    filter: brightness(1.15);
}

.xlsx-row-num {
    background: #F5F6F3 !important;
    color: var(--muted) !important;
    text-align: center;
    font-size: 0.625rem;
    min-width: 2rem;
    font-family: var(--font-mono);
}

[data-theme="dark"] .xlsx-row-num {
    background: var(--surface-2) !important;
}

.xlsx-col-letter {
    background: #F0F1EF !important;
    font-weight: 600;
    text-align: center;
    font-size: 0.625rem;
    font-family: var(--font-mono);
    color: var(--muted);
}

[data-theme="dark"] .xlsx-col-letter {
    background: var(--surface-2) !important;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .td-layout { grid-template-columns: 1fr; }
    .td-sidebar { position: static; }
    .td-chat-messages { max-height: 40vh; }
    .td-meta-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 480px) {
    .td-title { font-size: 0.95rem; }
    .td-meta-grid { grid-template-columns: 1fr 1fr; }
    .td-meta-item { padding: 0.5rem; }
    .td-chat-buttons { flex-wrap: wrap; }
    .td-chat-buttons .btn { font-size: 0.5625rem; padding: 0.25rem 0.5rem; }
    .td-attach-info { font-size: 0.75rem; }
    .td-comment-body { font-size: 0.75rem; }
    .td-action-btn { font-size: 0.6875rem; padding: 0.5rem 0.75rem; }
    .td-sidebar-section { padding: 0.75rem; }
    .td-show-all-btn { font-size: 0.6875rem; }
    .xlsx-table td, .xlsx-table th { font-size: 0.5625rem; padding: 0.15rem 0.3rem; }
}
