/* ================================================
   TASK LIST VIEW - BEM STRUCTURE
   ================================================ */

/* Task List View Container - Root Block */
.tasknotes-plugin .task-list-view {
    padding: var(--tn-spacing-sm);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    gap: var(--tn-spacing-sm);
    max-width: 100%;
}

/* Task List View Header */
.tasknotes-plugin .task-list-view__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tn-spacing-sm) 0;
    border-bottom: 1px solid var(--tn-border-color);
    margin-bottom: var(--tn-spacing-sm);
}

.tasknotes-plugin .task-list-view__title {
    font-size: var(--tn-font-size-xl);
    font-weight: var(--tn-font-weight-semibold);
    color: var(--tn-text-normal);
    margin: 0;
}

.tasknotes-plugin .task-list-view__actions {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-sm);
}

/* Use consistent button system with primary accent background preserved */
.tasknotes-plugin .task-list-view__add-button {
    background: var(--tn-interactive-accent);
    color: var(--text-on-accent);
    border: none;
    box-shadow: none;
}

.tasknotes-plugin .task-list-view__add-button:hover {
    background: var(--tn-interactive-accent-hover);
    box-shadow: none;
}

/* Filter Bar Container */
.tasknotes-plugin .task-list-view__filter-container {
    margin-bottom: var(--tn-spacing-md);
}

/* Task List Container */
.tasknotes-plugin .task-list-view__tasks {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-xs);
    flex: 1;
    min-height: 0;
}

.tasknotes-plugin .task-list {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-xs);
    flex: 1;
    min-height: 0;
}


/* Loading Indicator */
.tasknotes-plugin .task-list-view__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tn-spacing-sm);
    padding: var(--tn-spacing-lg);
    color: var(--tn-text-muted);
    font-size: var(--tn-font-size-md);
    font-style: italic;
    font-weight: 400;
    background: var(--tn-bg-secondary);
    border: 1px solid var(--tn-border-color);
    border-radius: var(--tn-radius-md);
    margin-bottom: var(--tn-spacing-md);
}

.tasknotes-plugin .task-list-view__loading.is-hidden {
    display: none;
}

.tasknotes-plugin .task-list-view__loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid color-mix(in srgb, var(--tn-text-muted) 0.3, transparent);
    border-top: 2px solid var(--tn-text-muted);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

/* Task Group Section */
.tasknotes-plugin .task-list-view__group {
    margin-bottom: var(--tn-spacing-md);
}

.tasknotes-plugin .task-list-view__group-header {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-sm);
    justify-content: flex-start;
    padding: var(--tn-spacing-md) 0 var(--tn-spacing-sm);
    margin-bottom: var(--tn-spacing-sm);
    border-bottom: 1px solid var(--tn-border-color);
    position: relative;
    font-size: var(--tn-font-size-lg);
    font-weight: var(--tn-font-weight-medium);
    color: var(--tn-text-normal);
    letter-spacing: 0.01em;
    line-height: 1.4;
    cursor: pointer;
}

/* Count element within task list group headers */
.tasknotes-plugin .task-list-view__group-header .agenda-view__item-count {
    margin-left: auto;
    margin-right: 0;
}


/* Right side of group header: count + subgroup actions */
.tasknotes-plugin .task-list-view__group-header { display:flex; align-items:center; }
.tasknotes-plugin .task-group-right { margin-left:auto; display:flex; align-items:center; gap: var(--tn-spacing-xs); }

/* Override count margin when inside right-side container */
.tasknotes-plugin .task-group-right .agenda-view__item-count { margin-left: 0; margin-right: 0; }

/* Chevron/toggle styles (match preview-all) */
.tasknotes-plugin .task-group-header { cursor: pointer; }
.task-group-header { display: flex; align-items: center; justify-content: flex-start; gap: var(--tn-spacing-xs); }
.tasknotes-plugin .task-group-toggle svg,  .task-group-toggle .chevron, .task-group-toggle .chevron path { color: var(--tn-text-normal); }
.tasknotes-plugin .task-group-toggle svg,  .task-group-toggle .chevron path { stroke: currentColor; }
.tasknotes-plugin .task-group.is-collapsed .task-group-toggle svg,
.tasknotes-plugin .task-group.is-collapsed .task-group-toggle .chevron { transform: rotate(0deg); }
.tasknotes-plugin .task-group-toggle { display: contents; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: var(--tn-spacing-xs); border: none; background: transparent; color: var(--tn-text-normal); font-size: 14px; line-height: 1; }
.tasknotes-plugin .task-group-toggle .chevron { transition: transform var(--tn-transition-fast); }
.tasknotes-plugin .task-group .task-group-toggle .chevron,
.tasknotes-plugin .task-group .task-group-toggle svg { transform: rotate(90deg); }
.tasknotes-plugin .task-group.is-collapsed .task-cards { display: none; }

/* Subgroup styles and chevron behavior */
.tasknotes-plugin .task-subgroups-container { margin-left: var(--tn-spacing-lg); }
.tasknotes-plugin .task-subgroup-header { display:flex; align-items:center; gap: var(--tn-spacing-xs); cursor: pointer; padding: 2px 0; font-size: var(--tn-font-size-lg); font-weight: var(--tn-font-weight-medium); }
.tasknotes-plugin .task-subgroup-header .agenda-view__item-count { margin-left: auto; }
.tasknotes-plugin .task-subgroup-toggle { display: contents; align-items:center; justify-content:center; width:16px; height:16px; border:none; background:transparent; color: var(--tn-text-normal); font-size: 12px; line-height: 1; }
.tasknotes-plugin .task-subgroup-toggle .chevron { transition: transform var(--tn-transition-fast); }
.tasknotes-plugin .task-subgroup .task-subgroup-toggle .chevron,
.tasknotes-plugin .task-subgroup .task-subgroup-toggle svg { transform: rotate(90deg); }
.tasknotes-plugin .task-subgroup.is-collapsed .task-subgroup-toggle .chevron,
.tasknotes-plugin .task-subgroup.is-collapsed .task-subgroup-toggle svg { transform: rotate(0deg); }
.tasknotes-plugin .task-subgroup.is-collapsed .task-cards { display: none; }
.tasknotes-plugin .task-group.is-collapsed .task-subgroups-container { display: none; }

/* Per-group subgroup actions */
.tasknotes-plugin .task-subgroup-actions { display:flex; align-items:center; gap: 4px; margin-left: 0; }
.tasknotes-plugin .task-subgroup-action { border:none; background:transparent; color: var(--tn-text-muted); cursor:pointer; padding: 0; }
.tasknotes-plugin .task-subgroup-action:hover { color: var(--tn-text-normal); }


.tasknotes-plugin .task-list-view__project-link {
    color: var(--tn-text-normal);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.tasknotes-plugin .task-list-view__project-link:hover {
    color: var(--tn-interactive-accent);
    text-decoration: underline;
}

.tasknotes-plugin .task-list-view__group-content {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-xs);
}

/* Empty State */
.tasknotes-plugin .task-list-view__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--tn-spacing-xl);
    text-align: center;
    color: var(--tn-text-muted);
    background: var(--tn-bg-secondary);
    border: 1px solid var(--tn-border-color);
    border-radius: var(--tn-radius-md);
    margin: var(--tn-spacing-lg) 0;
}

.tasknotes-plugin .task-list-view__empty-title {
    font-size: var(--tn-font-size-lg);
    font-weight: var(--tn-font-weight-medium);
    margin-bottom: var(--tn-spacing-sm);
    color: var(--tn-text-normal);
}

.tasknotes-plugin .task-list-view__empty-description {
    font-size: var(--tn-font-size-lg);
    line-height: 1.6;
    max-width: 400px;
}

/* Task Item Container (wraps task cards) */
.tasknotes-plugin .task-list-view__task-item {
    position: relative;
    background: var(--tn-bg-primary);
    border: 1px solid var(--tn-border-color);
    border-radius: var(--tn-radius-sm);
    transition: all var(--tn-transition-fast);
    overflow: hidden;
}

.tasknotes-plugin .task-list-view__task-item:hover {
    background: var(--tn-interactive-hover);
    border-color: var(--tn-border-color-hover);
    transform: translateY(-1px);
    box-shadow: var(--tn-shadow-medium);
}

.tasknotes-plugin .task-list-view__task-item:focus-within {
    border-color: var(--tn-interactive-accent);
    box-shadow: none;
}

/* Task Item States */
.tasknotes-plugin .task-list-view__task-item--completed {
    opacity: 0.7;
    background: var(--tn-bg-secondary);
}

.tasknotes-plugin .task-list-view__task-item--overdue {
    border-left: 4px solid var(--tn-color-error);
    background: color-mix(in srgb, var(--tn-color-error) 0.05, var(--tn-bg-primary));
}

.tasknotes-plugin .task-list-view__task-item--due-today {
    border-left: 4px solid var(--tn-interactive-accent);
    background: color-mix(in srgb, var(--tn-interactive-accent) 0.05, var(--tn-bg-primary));
}

.tasknotes-plugin .task-list-view__task-item--archived {
    opacity: 0.5;
    background: transparent;
}

/* Task Item Priority Indicators */
.tasknotes-plugin .task-list-view__task-item--priority-high {
    border-left: 3px solid var(--tn-color-error);
}

.tasknotes-plugin .task-list-view__task-item--priority-normal {
    border-left: 3px solid var(--tn-interactive-accent);
}

.tasknotes-plugin .task-list-view__task-item--priority-low {
    border-left: 3px solid var(--tn-text-muted);
}

/* Task Update Animation */
.tasknotes-plugin .task-list-view__task-item--updating {
    animation: task-update 1.5s ease;
}

@keyframes task-update {
    0% {
        background-color: var(--tn-bg-primary);
        transform: scale(1);
    }
    20% {
        background-color: var(--tn-interactive-accent-hover);
        transform: scale(1.02);
    }
    100% {
        background-color: var(--tn-bg-primary);
        transform: scale(1);
    }
}


/* Responsive Design */
@media (max-width: 768px) {
    .tasknotes-plugin .task-list-view {
        padding: var(--tn-spacing-xs);
        gap: var(--tn-spacing-xs);
    }

    .tasknotes-plugin .task-list-view__header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--tn-spacing-sm);
    }

    .tasknotes-plugin .task-list-view__actions {
        justify-content: center;
    }

    .tasknotes-plugin .task-list-view__add-button {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .tasknotes-plugin .task-list-view__group-header {
        font-size: var(--tn-font-size-md);
        padding: var(--tn-spacing-sm) 0 var(--tn-spacing-xs);
    }

    .tasknotes-plugin .task-list-view__empty {
        padding: var(--tn-spacing-lg);
    }

    .tasknotes-plugin .task-list-view__empty-title {
        font-size: var(--tn-font-size-md);
    }

    .tasknotes-plugin .task-list-view__empty-description {
        font-size: var(--tn-font-size-sm);
    }
}
