/* 日历组件 - 移动优先 */
.calendar-section {
    margin-top: 0;
    width: 100%;
    max-height: none;
    overflow: visible;
}

.calendar-container {
    padding: var(--spacing-2);
    overflow: visible;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* 防止内容溢出 */
    overflow-x: hidden;
}

/* 300px宽度时的特殊优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .calendar-container {
        padding: var(--spacing-2);
        max-width: 100%;
    }
}

@media (min-width: 1024px) {
    .calendar-container {
        padding: var(--spacing-3);
    }
}

.calendar-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-2);
    margin-bottom: var(--spacing-3);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* 第一行：视图切换按钮组 */
.calendar-header .calendar-view-switch {
    order: 1;
    width: 100%;
    margin-bottom: 0;
}

/* 第二行：年份和月份下拉框 */
.calendar-header .calendar-title {
    order: 2;
    width: 100%;
}

.calendar-title {
    display: flex;
    flex-direction: row;
    gap: var(--spacing-2);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.calendar-select-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    flex: 1;
}

.calendar-year-select,
.calendar-month-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    /* 确保文字不被截断 */
    text-overflow: ellipsis;
    overflow: visible;
    white-space: nowrap;
    /* 垂直对齐 - 修复文字被切除问题 */
    height: auto;
    min-height: 32px;
    line-height: 1.5;
    padding-top: 6px;
    padding-bottom: 6px;
    vertical-align: middle;
}

.calendar-view-switch {
    width: 100%;
    max-width: 100%;
    display: flex;
    gap: var(--spacing-2);
    box-sizing: border-box;
    flex-shrink: 0;
    align-self: flex-start;
    align-items: stretch;
    margin-bottom: var(--spacing-2);
}

@media (min-width: 768px) {
    .calendar-view-switch {
        width: auto;
        align-self: flex-start;
        align-items: center;
        margin-bottom: var(--spacing-2);
    }
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
}

@media (min-width: 768px) {
    .view-btn {
        height: 100%;
        min-height: 32px;
    }
}

.calendar-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.calendar-nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.calendar-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    flex: 1;
    justify-content: center;
}

.calendar-year-btn,
.calendar-month-btn {
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.calendar-year-btn:hover,
.calendar-month-btn:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.calendar-view-switch {
    display: flex;
    gap: var(--spacing-2);
    margin-bottom: var(--spacing-4);
    padding: 3px;
    background: var(--background-color);
    border-radius: var(--radius-md);
}

.view-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    white-space: nowrap;
}

.view-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.view-btn:hover:not(.active) {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: var(--spacing-2);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* 防止网格溢出 */
    min-width: 0;
}

/* 300px宽度时的特殊优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .calendar-weekdays {
        gap: 1px;
    }
}

.weekday {
    text-align: center;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 2px 1px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 300px宽度时的特殊优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .weekday {
        font-size: 10px;
        padding: 3px 1px;
    }
    
    .calendar-day {
        padding: 4px 2px !important;
        min-height: 48px !important;
    }
    
    .day-number {
        font-size: 11px !important;
    }
    
    .day-count {
        font-size: 9px !important;
        padding: 1px 3px !important;
    }
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* 防止网格溢出 */
    min-width: 0;
}

/* 300px宽度时的特殊优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .calendar-days {
        gap: 1px;
    }
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 3px 1px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    min-height: 40px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    touch-action: manipulation;
    /* 防止内容溢出 */
    overflow: hidden;
    min-width: 0;
}

.calendar-day:hover {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
}

.calendar-day.other-month {
    opacity: 0.3;
    cursor: default;
}

.calendar-day.other-month:hover {
    background: var(--surface-color);
    border-color: transparent;
}

.calendar-day.today {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
    font-weight: 600;
}

.calendar-day.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.calendar-day.selected .day-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.calendar-day.has-posts {
    font-weight: 500;
}

.day-number {
    font-size: 11px;
    line-height: 1.2;
    margin-bottom: 2px;
    font-weight: 500;
}

@media (min-width: 768px) {
    .day-number {
        font-size: 12px;
        margin-bottom: 3px;
    }
}

@media (min-width: 1024px) {
    .day-number {
        font-size: 13px;
        margin-bottom: 4px;
    }
}

.day-count {
    font-size: 9px;
    padding: 1px 3px;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-color);
    line-height: 1.2;
    min-width: 16px;
    text-align: center;
    font-weight: 500;
    margin-top: 0;
}

@media (min-width: 768px) {
    .day-count {
        font-size: 9px;
        padding: 1px 4px;
        min-width: 18px;
        margin-top: 0;
    }
}

@media (min-width: 1024px) {
    .day-count {
        font-size: 10px;
    }
}

.calendar-day.selected .day-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* 年视图 */
.calendar-year-view {
    padding: var(--spacing-2);
}

.year-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-2);
}

.year-month-item {
    padding: var(--spacing-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-color);
}

.year-month-item:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.year-month-item.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.month-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.month-count {
    font-size: 12px;
    opacity: 0.7;
}

.year-month-item.active .month-count {
    opacity: 0.9;
}

/* 移动设备优化 */
@media (max-width: 767px) {
    .page-title {
        font-size: 1.5rem;
        margin-bottom: var(--spacing-4);
    }
    
    .news-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-2);
    }
    
    .news-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .ai-news-action-btn {
        padding: 4px 8px !important;
    }
    
    .year-months {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tags-container {
        max-height: 300px;
        overflow-y: auto;
        padding: var(--spacing-2);
    }
    
    .tag-item {
        font-size: 11px;
        padding: 0 8px;
        height: 26px;
        line-height: 26px;
    }
    
    .tag-count {
        height: 16px;
        line-height: 1.2;
    }
    
    .tag-count {
        font-size: 9px;
        padding: 1px 4px;
        min-width: 18px;
    }
    
    .calendar-section {
        max-height: none;
    }
    
    .calendar-container {
        max-height: none;
        overflow: visible;
    }
}
