/* ============================================================================
   Task Modal Comments Panel
   ============================================================================ */

/* Comment count badge on toolbar button */
.comment-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-md);
    background: var(--accent-fill);
    color: #FFFFFF;
    font-size: var(--font-size-2xs);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Make the comments button position: relative for the badge */
.modal-action-btn[data-action="comments"] {
    position: relative;
}

/* Modal content wrapper for side-by-side layout */
.modal-content-wrapper {
    display: flex;
    flex: 1;
    min-height: 0;
}

.modal-content-wrapper > .task-note-editor {
    flex: 1;
    min-width: 0;
}

/* Expanded modal when comments are open */
.task-modal.has-comments:not(.fullscreen) {
    max-width: 1100px;
}

/* When comments are open, strip all padding from modal-body so the comments panel
   spans the full height (header divider to bottom edge) and flush right.
   Padding is moved to the editor content side instead. */
.task-modal.has-comments .modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.task-modal.has-comments .modal-content-wrapper > .task-note-editor {
    padding: var(--space-8);
}

.task-modal.has-comments.fullscreen .modal-content-wrapper > .task-note-editor {
    padding: 32px 48px;
}

/* Comments panel within the modal */
.modal-comments-panel {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 0 0 var(--radius-lg) 0;
}

.modal-comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.modal-comments-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--text-primary);
}

.modal-comments-count {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 6px;
    border-radius: var(--radius-lg);
}

.modal-comments-thread {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.modal-comments-empty {
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    padding: 32px 16px;
}

.modal-comment {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.modal-comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-circle);
    background: var(--accent-fill);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    flex-shrink: 0;
}

.modal-comment-content {
    flex: 1;
    min-width: 0;
}

.modal-comment-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.modal-comment-name {
    font-size: var(--font-size-12);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-comment-time {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
}

.modal-comment-body {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.comment-mention {
    color: var(--accent-blue);
    font-weight: 600;
    cursor: default;
    border-radius: var(--radius-sm);
    padding: 0 2px;
    background: rgba(74, 144, 217, 0.08);
}

.modal-comments-reply {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}

.modal-comments-input {
    flex: 1;
    min-height: 32px;
    max-height: 80px;
    overflow-y: auto;
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    transition: border-color var(--transition-fast);
}

.modal-comments-input:focus {
    border-color: var(--accent-blue);
}

.modal-comments-input:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    pointer-events: none;
}

.modal-comments-send {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-circle);
    background: var(--accent-fill);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.modal-comments-send:hover {
    background: var(--accent-fill-hover);
}

.modal-comments-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Dark mode for conversation and comments */
[data-theme="dark"] .conversation-overlay {
    background: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .conversation-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .modal-comments-count {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .activity-item:hover {
    background: rgba(74, 144, 217, 0.06);
}

[data-theme="dark"] .conversation-reply-input {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .modal-comments-input {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .conversation-message.own .conversation-message-content {
    background: rgba(74, 144, 217, 0.15);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .conversation-overlay {
        background: rgba(0, 0, 0, 0.5);
    }
    :root:not([data-theme="light"]) .conversation-close:hover {
        background: rgba(255, 255, 255, 0.08);
    }
    :root:not([data-theme="light"]) .modal-comments-count {
        background: rgba(255, 255, 255, 0.08);
    }
    :root:not([data-theme="light"]) .activity-item:hover {
        background: rgba(74, 144, 217, 0.06);
    }
}

/* Reduced motion — disable slide/fade animations */
@media (prefers-reduced-motion: reduce) {
    .conversation-overlay,
    .conversation-panel {
        transition: none;
    }
    .task-modal.has-comments {
        transition: none;
    }
}

/* Responsive: conversation panel full width on small screens */
@media (max-width: 600px) {
    .conversation-panel {
        width: 100%;
    }
    .modal-comments-panel {
        width: 280px;
    }
}

/* Activity toggle button for small screens */
.activity-toggle-responsive {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.activity-toggle-responsive:hover {
    background: var(--bg-secondary);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* Responsive: hide activity panel on small screens, show toggle button */
@media (max-width: 1024px) {
    #inboxActivityPanel {
        display: none !important;
    }
    .activity-toggle-responsive {
        display: flex;
    }
}

@media (max-width: 768px) {
    .inbox-view .task-row,
    .today-view .task-row,
    .area-view .task-row,
    .tasks-view .task-row,
    .project-modal-main .task-row,
    .area-modal-main .task-row {
        padding: 8px 14px; /* 46px, as on wide screens — still a full touch target */
    }
    .inbox-view .new-task-row,
    .today-view .new-task-row:not(.today-tasks-header .new-task-row),
    .area-view .new-task-row,
    .tasks-view .new-task-row,
    .project-modal-main .new-task-row,
    .area-modal-main .new-task-row {
        padding: 8px 14px;
    }
    /* Narrower rows narrow the padding gutter the drag handle sits in */
    .task-drag-handle {
        width: 14px;
    }
}

/* Reduced motion — keep hover feedback but remove transform */
@media (prefers-reduced-motion: reduce) {
    .inbox-view .task-row,
    .today-view .task-row,
    .area-view .task-row,
    .tasks-view .task-row,
    .project-modal-main .task-row {
        transition: box-shadow var(--duration-fast) var(--ease-in-out), background var(--duration-fast) var(--ease-in-out);
    }
    .inbox-view .task-row:hover,
    .today-view .task-row:hover,
    .area-view .task-row:hover,
    .tasks-view .task-row:hover,
    .project-modal-main .task-row:hover {
        transform: none;
    }
}

/* ============================================================================
   END INBOX CARD ROWS + ACTIVITY PANEL
   ============================================================================ */
