/* ================================================
   AGENDA VIEW - BEM STRUCTURE
   ================================================ */

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

/* Agenda View Controls */
.tasknotes-plugin .agenda-view__controls {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-md);
    margin-bottom: var(--tn-spacing-md);
}

/* Header Section */
.tasknotes-plugin .agenda-view__header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--tn-spacing-lg) var(--tn-spacing-md);
    margin-bottom: var(--tn-spacing-lg);
    position: relative;
    background: transparent;
}

.tasknotes-plugin .agenda-view__header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.tasknotes-plugin .agenda-view__nav-section {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-xs);
}

.tasknotes-plugin .agenda-view__title-section {
    flex: 1;
    display: flex;
    justify-content: center;
    margin: 0 var(--tn-spacing-lg);
}

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

.tasknotes-plugin .agenda-view__period-title {
    font-size: var(--tn-font-size-xl);
    font-weight: var(--tn-font-weight-medium);
    color: var(--tn-text-normal);
    text-align: center;
    white-space: nowrap;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

/* Use consistent button system */
.tasknotes-plugin .agenda-view__nav-button {
    /* Remove individual styles - use tn-btn tn-btn--icon tn-btn--lg tn-btn--ghost classes */
    border-radius: 50%;
    font-size: 1.25rem;
    font-weight: var(--tn-font-weight-medium);
}

.tasknotes-plugin .agenda-view__nav-button:active {
    opacity: 0.8;
}

.tasknotes-plugin .agenda-view__nav-button--prev {
    /* Specific styling for previous button if needed */
}

.tasknotes-plugin .agenda-view__nav-button--next {
    /* Specific styling for next button if needed */
}

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

/* Settings Section */
.tasknotes-plugin .agenda-view__settings {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--tn-spacing-md);
    background: var(--tn-bg-secondary);
    border: 1px solid var(--tn-border-color);
    border-radius: var(--tn-radius-md);
    gap: var(--tn-spacing-md);
    flex-wrap: wrap;
    margin-bottom: var(--tn-spacing-md);
    box-shadow: var(--tn-shadow-light);
}

.tasknotes-plugin .agenda-view__settings-left {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-sm);
}

.tasknotes-plugin .agenda-view__settings-right {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-md);
}

/* Period Selector */
.tasknotes-plugin .agenda-view__period-select {
    appearance: none;
    padding: var(--tn-spacing-sm) var(--tn-spacing-xl) var(--tn-spacing-sm) var(--tn-spacing-md);
    border: 1px solid var(--tn-border-color);
    border-radius: var(--tn-radius-sm);
    background: var(--tn-bg-primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right var(--tn-spacing-sm) center;
    background-repeat: no-repeat;
    background-size: 16px;
    color: var(--tn-text-normal);
    font-family: inherit;
    font-size: var(--tn-font-size-md);
    font-weight: 400;
    min-width: 120px;
    min-height: var(--tn-input-height-md);
    cursor: pointer;
    transition: all var(--tn-transition-fast);
}

.tasknotes-plugin .agenda-view__period-select:hover {
    border-color: var(--tn-border-color-hover);
    background-color: var(--tn-interactive-hover);
}

.tasknotes-plugin .agenda-view__period-select:focus {
    outline: none;
    border-color: var(--tn-interactive-accent);
    background-color: color-mix(in srgb, var(--tn-interactive-accent) 0.1, var(--tn-bg-primary));
}

/* Today Button */
.tasknotes-plugin .agenda-view__today-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tn-spacing-xs);
    padding: var(--tn-spacing-sm) var(--tn-spacing-md);
    border: none;
    border-radius: var(--tn-radius-md);
    background: transparent;
    color: var(--tn-text-muted);
    font-family: inherit;
    font-size: var(--tn-font-size-sm);
    font-weight: var(--tn-font-weight-medium);
    line-height: 1.25;
    height: var(--tn-button-height-md);
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--tn-transition-fast);
    overflow: hidden;
    box-shadow: none;
}

.tasknotes-plugin .agenda-view__today-button:hover {
    background: var(--tn-interactive-hover);
    color: var(--tn-text-normal);
}

.tasknotes-plugin .agenda-view__today-button:focus-visible {
    outline: 2px solid var(--tn-interactive-accent);
    outline-offset: 2px;
}

.tasknotes-plugin .agenda-view__today-button:active {
    background: var(--tn-interactive-active);
    transform: translateY(1px);
}

/* Toggle Controls */
.tasknotes-plugin .agenda-view__toggle {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-sm);
    cursor: pointer;
    user-select: none;
    font-size: var(--tn-font-size-md);
    color: var(--tn-text-normal);
    padding: var(--tn-spacing-sm);
    border-radius: var(--tn-radius-sm);
    transition: background-color var(--tn-transition-fast);
}

.tasknotes-plugin .agenda-view__toggle:hover {
    background: var(--tn-interactive-hover);
}


/* Content Area */
.tasknotes-plugin .agenda-view__content {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-sm);
    flex: 1;
    min-height: 0;
}

/* Loading Indicator */
.tasknotes-plugin .agenda-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);
    box-shadow: var(--tn-shadow-light);
}

.tasknotes-plugin .agenda-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;
}

/* Day Section */
.tasknotes-plugin .agenda-view__day {
    margin-bottom: var(--tn-spacing-md);
}

.tasknotes-plugin .agenda-view__day-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--tn-spacing-sm);
    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;
    cursor: pointer;
}

/* Day section container (like task groups) */
.tasknotes-plugin .agenda-view__day-section {
    margin-bottom: var(--tn-spacing-md);
}

/* Day items container */
.tasknotes-plugin .agenda-view__day-items {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-xs);
}

/* Collapsed state */
.tasknotes-plugin .agenda-view__day-section.is-collapsed .agenda-view__day-items {
    display: none;
}

/* Chevron/toggle styles for agenda day headers (consistent with TaskList view) */
.tasknotes-plugin .agenda-view__day-header .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 .agenda-view__day-header .task-group-toggle svg,
.tasknotes-plugin .agenda-view__day-header .task-group-toggle .chevron,
.tasknotes-plugin .agenda-view__day-header .task-group-toggle .chevron path {
    color: var(--tn-text-normal);
}

.tasknotes-plugin .agenda-view__day-header .task-group-toggle svg,
.tasknotes-plugin .agenda-view__day-header .task-group-toggle .chevron path {
    stroke: currentColor;
}

.tasknotes-plugin .agenda-view__day-header .task-group-toggle .chevron {
    transition: transform var(--tn-transition-fast);
}

.tasknotes-plugin .agenda-view__day-section .task-group-toggle .chevron,
.tasknotes-plugin .agenda-view__day-section .task-group-toggle svg {
    transform: rotate(90deg);
}

.tasknotes-plugin .agenda-view__day-section.is-collapsed .task-group-toggle svg,
.tasknotes-plugin .agenda-view__day-section.is-collapsed .task-group-toggle .chevron {
    transform: rotate(0deg);
}

.tasknotes-plugin .agenda-view__day-header-text {
    display: flex;
    align-items: center;
    gap: var(--tn-spacing-sm);
}

.tasknotes-plugin .agenda-view__day-name {
    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;
}

.tasknotes-plugin .agenda-view__day-name--today {
    background: var(--tn-interactive-accent);
    color: var(--tn-bg-primary);
    padding: var(--tn-spacing-xs) var(--tn-spacing-md);
    border-radius: var(--tn-radius-md);
    font-size: var(--tn-font-size-sm);
    font-weight: var(--tn-font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    min-height: 28px;
    box-shadow: var(--tn-shadow-light);
}

.tasknotes-plugin .agenda-view__day-date {
    font-size: var(--tn-font-size-md);
    color: var(--tn-text-muted);
    font-weight: 400;
    letter-spacing: 0.01em;
}

.tasknotes-plugin .agenda-view__item-count {
    background: none;
    color: var(--text-muted);
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: var(--tn-font-size-xs);
    font-weight: var(--tn-font-weight-medium);
    line-height: 1.2;
    display: inline-flex;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    text-align: center;
}

/* Day Content */
.tasknotes-plugin .agenda-view__day-content {
    display: flex;
    flex-direction: column;
    gap: var(--tn-spacing-xs);
}

.tasknotes-plugin .agenda-view__day-content--flat {
    gap: var(--tn-spacing-xs);
}


/* Empty States */
.tasknotes-plugin .agenda-view__empty {
    padding: var(--tn-spacing-xl) var(--tn-spacing-lg);
    text-align: center;
    background: var(--tn-bg-secondary);
    border: 1px solid var(--tn-border-color);
    border-radius: var(--tn-radius-md);
    margin: var(--tn-spacing-lg) 0;
    box-shadow: var(--tn-shadow-light);
}

.tasknotes-plugin .agenda-view__empty-title {
    margin: 0 0 var(--tn-spacing-md) 0;
    color: var(--tn-text-normal);
    font-size: var(--tn-font-size-lg);
    font-weight: var(--tn-font-weight-medium);
    line-height: 1.3;
}

.tasknotes-plugin .agenda-view__empty-description {
    margin: 0 0 var(--tn-spacing-md) 0;
    color: var(--tn-text-muted);
    font-size: var(--tn-font-size-md);
    line-height: 1.5;
    font-weight: 400;
}

.tasknotes-plugin .agenda-view__empty-description:last-child {
    margin-bottom: 0;
}

.tasknotes-plugin .agenda-view__empty-tip {
    font-style: italic;
    font-size: var(--tn-font-size-md);
    color: var(--tn-text-muted);
    margin-top: var(--tn-spacing-sm);
}

.tasknotes-plugin .agenda-view__empty-tip span {
    font-weight: var(--tn-font-weight-medium);
    color: var(--tn-text-normal);
    font-style: normal;
}

/* Error States */
.tasknotes-plugin .agenda-view__error {
    padding: var(--tn-spacing-lg);
    text-align: center;
    color: var(--tn-color-error);
    background: color-mix(in srgb, var(--tn-color-error) 0.05, var(--tn-bg-secondary));
    border: 1px solid color-mix(in srgb, var(--tn-color-error) 0.3, transparent);
    border-radius: var(--tn-radius-md);
    font-size: var(--tn-font-size-md);
    font-weight: var(--tn-font-weight-medium);
    line-height: 1.5;
    box-shadow: var(--tn-shadow-light);
}


.tasknotes-plugin .agenda-view .tasks-container {
    margin-bottom: var(--tn-spacing-xs);
}

/* Note Date Display in Flat List */
.tasknotes-plugin .agenda-view__note-date {
    display: inline-block;
    margin-left: var(--tn-spacing-sm);
    padding: var(--tn-spacing-xs) var(--tn-spacing-sm);
    background: var(--tn-bg-secondary);
    border-radius: var(--tn-radius-sm);
    font-size: var(--tn-font-size-xs);
    color: var(--tn-text-muted);
    font-weight: var(--tn-font-weight-medium);
}

/* Responsive Design */
@media (max-width: 768px) {
    .tasknotes-plugin .agenda-view {
        padding: var(--tn-spacing-xs);
    }
    
    .tasknotes-plugin .agenda-view__header-content {
        flex-direction: column;
        gap: var(--tn-spacing-md);
    }
    
    .tasknotes-plugin .agenda-view__title-section {
        order: -1;
        margin: 0;
    }
    
    .tasknotes-plugin .agenda-view__period-title {
        font-size: var(--tn-font-size-lg);
    }
    
    .tasknotes-plugin .agenda-view__nav-section,
    .tasknotes-plugin .agenda-view__actions-section {
        justify-content: center;
    }
    
    .tasknotes-plugin .agenda-view__nav-button {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .tasknotes-plugin .agenda-view__settings {
        flex-direction: column;
        align-items: stretch;
        gap: var(--tn-spacing-sm);
    }
    
    .tasknotes-plugin .agenda-view__settings-left,
    .tasknotes-plugin .agenda-view__settings-right {
        justify-content: space-between;
        width: 100%;
    }
    
    .tasknotes-plugin .agenda-view__settings-right {
        gap: var(--tn-spacing-sm);
    }
    
    .tasknotes-plugin .agenda-view__day-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--tn-spacing-xs);
    }
    
    .tasknotes-plugin .agenda-view__day-header-text {
        width: 100%;
        justify-content: space-between;
    }
    
    .tasknotes-plugin .agenda-view__item-count {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .tasknotes-plugin .agenda-view__header-content {
        gap: var(--tn-spacing-xs);
    }
    
    .tasknotes-plugin .agenda-view__period-title {
        font-size: var(--tn-font-size-md);
        min-width: 120px;
    }
    
    .tasknotes-plugin .agenda-view__nav-button {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .tasknotes-plugin .agenda-view__settings-left,
    .tasknotes-plugin .agenda-view__settings-right {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tasknotes-plugin .agenda-view__toggle {
        justify-content: space-between;
    }
}