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17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
/**

 * 组件响应式布局样式

 * Widget Responsive Layout Styles

 */

/* CSS 自定义属性定义 */
:root {
  /* 断点变量 */
  --breakpoint-mobile: 768px;
  --breakpoint-tablet: 1024px;
  --breakpoint-desktop: 1025px;
  
  /* 间距变量 */
  --widget-gap-mobile: 0.75rem;
  --widget-gap-tablet: 1rem;
  --widget-gap-desktop: 1.25rem;
  
  /* 动画变量 */
  --widget-animation-duration: 0.3s;
  --widget-animation-timing: ease-in-out;
  
  /* 侧边栏宽度 */
  --sidebar-width-mobile: 100%;
  --sidebar-width-tablet: 280px;
  --sidebar-width-desktop: 320px;
  
  /* 组件最小高度 */
  --widget-min-height: 60px;
  --widget-max-height-mobile: 200px;
  --widget-max-height-tablet: 300px;
  --widget-max-height-desktop: 400px;
}

/* 基础侧边栏样式 */
#dynamic-sidebar {
  width: var(--sidebar-width-desktop);
  transition: all var(--widget-animation-duration) var(--widget-animation-timing);
  position: relative;
}

/* 组件容器基础样式 */
.widget-container {
  min-height: var(--widget-min-height);
  transition: all var(--widget-animation-duration) var(--widget-animation-timing);
  overflow: hidden;
}

/* 组件悬停效果 */
.widget-container:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.widget-container.widget-hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 移动端样式 (< 768px) */
@media (max-width: 767px) {
  #dynamic-sidebar {
    width: var(--sidebar-width-mobile);
    padding: 0.5rem;
  }
  
  .sidebar-top-section,
  .sidebar-sticky-section {
    gap: var(--widget-gap-mobile);
  }
  
  .widget-container {
    max-height: var(--widget-max-height-mobile);
  }
  
  /* 移动端隐藏的组件 */
  .widget-container[data-mobile-hidden="true"] {
    display: none;
  }
  
  /* 移动端特殊布局 */
  .sidebar-sticky-section {
    position: static !important;
    top: auto !important;
  }
  
  /* 移动端组件简化显示 */
  .widget-container[data-widget-type="announcement"] {
    order: -1; /* 公告优先显示 */
  }
  
  .widget-container[data-widget-type="categories"],
  .widget-container[data-widget-type="tags"] {
    /* 分类和标签在移动端可折叠 */
    max-height: 120px;
    overflow-y: auto;
  }
}

/* 平板端样式 (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  #dynamic-sidebar {
    width: var(--sidebar-width-tablet);
    padding: 0.75rem;
  }
  
  .sidebar-top-section,
  .sidebar-sticky-section {
    gap: var(--widget-gap-tablet);
  }
  
  .widget-container {
    max-height: var(--widget-max-height-tablet);
  }
  
  /* 平板端隐藏的组件 */
  .widget-container[data-tablet-hidden="true"] {
    display: none;
  }
  

}

/* 桌面端样式 (>= 1024px) */
@media (min-width: 1024px) {
  #dynamic-sidebar {
    width: var(--sidebar-width-desktop);
    padding: 1rem;
  }
  
  .sidebar-top-section,
  .sidebar-sticky-section {
    gap: var(--widget-gap-desktop);
  }
  
  .widget-container {
    max-height: var(--widget-max-height-desktop);
  }
  
  /* 桌面端隐藏的组件 */
  .widget-container[data-desktop-hidden="true"] {
    display: none;
  }
  
  /* 桌面端增强效果 */
  .widget-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  }
}

/* 超宽屏样式 (> 1440px) */
@media (min-width: 1441px) {
  #dynamic-sidebar {
    width: 360px;
  }
  
  .widget-container {
    max-height: 500px;
  }
}

/* 组件位置特定样式 */
.sidebar-top-section {
  /* 顶部组件区域 */
  margin-bottom: 1rem;
}

.sidebar-sticky-section {
  /* 粘性组件区域 */
  position: sticky;
  top: 1rem;
  z-index: 10;
}

/* 组件类型特定的响应式样式 */

/* Profile 组件 */
.widget-container[data-widget-type="profile"] {
  /* 用户资料组件始终保持固定高度 */
  min-height: 120px;
}

@media (max-width: 767px) {
  .widget-container[data-widget-type="profile"] {
    min-height: 100px;
  }
}

/* Announcement 组件 */
.widget-container[data-widget-type="announcement"] {
  /* 公告组件可以动态调整高度 */
  min-height: 80px;
}

@media (max-width: 767px) {
  .widget-container[data-widget-type="announcement"] {
    min-height: 60px;
    font-size: 0.875rem;
  }
}

/* Categories 和 Tags 组件 */
.widget-container[data-widget-type="categories"],
.widget-container[data-widget-type="tags"] {
  /* 分类和标签组件支持滚动 */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

.widget-container[data-widget-type="categories"]::-webkit-scrollbar,
.widget-container[data-widget-type="tags"]::-webkit-scrollbar {
  width: 4px;
}

.widget-container[data-widget-type="categories"]::-webkit-scrollbar-track,
.widget-container[data-widget-type="tags"]::-webkit-scrollbar-track {
  background: transparent;
}

.widget-container[data-widget-type="categories"]::-webkit-scrollbar-thumb,
.widget-container[data-widget-type="tags"]::-webkit-scrollbar-thumb {
  background-color: rgba(156, 163, 175, 0.5);
  border-radius: 2px;
}

/* TOC 组件 */
.widget-container[data-widget-type="toc"] {
  /* 目录组件在移动端隐藏 */
  max-height: 400px;
  overflow-y: auto;
}

@media (max-width: 767px) {
  .widget-container[data-widget-type="toc"] {
    display: none;
  }
}



/* 动画效果 */

/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 滑入动画 */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 缩放动画 */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 动画类 */
.widget-animation-fade {
  animation: fadeIn var(--widget-animation-duration) var(--widget-animation-timing) forwards;
}

.widget-animation-slide {
  animation: slideIn var(--widget-animation-duration) var(--widget-animation-timing) forwards;
}

.widget-animation-scale {
  animation: scaleIn var(--widget-animation-duration) var(--widget-animation-timing) forwards;
}

/* 初始状态 */
.widget-container {
  opacity: 0;
}

.widget-container.widget-animated {
  opacity: 1;
}

/* 加载状态 */
.widget-loading {
  position: relative;
  overflow: hidden;
}

.widget-loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* 错误状态 */
.widget-error {
  border: 2px dashed #ef4444;
  background-color: #fef2f2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  text-align: center;
  font-size: 0.875rem;
}

/* 空状态 */
.widget-empty {
  border: 2px dashed #d1d5db;
  background-color: #f9fafb;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  text-align: center;
  font-size: 0.875rem;
}

/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
  .widget-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  .widget-container.widget-hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
  
  .widget-error {
    border-color: #f87171;
    background-color: #450a0a;
    color: #fca5a5;
  }
  
  .widget-empty {
    border-color: #4b5563;
    background-color: #111827;
    color: #9ca3af;
  }
  
  .widget-loading::before {
    background: linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, 0.1),
      transparent
    );
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  .widget-container {
    border: 2px solid currentColor;
  }
  
  .widget-container:hover {
    border-width: 3px;
  }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
  .widget-container,
  .widget-animation-fade,
  .widget-animation-slide,
  .widget-animation-scale {
    animation: none;
    transition: none;
  }
  
  .widget-container {
    opacity: 1;
    transform: none;
  }
  
  .widget-container:hover {
    transform: none;
  }
}

/* 打印样式 */
@media print {
  #dynamic-sidebar {
    display: none;
  }
}

/* 容器查询支持 (现代浏览器) */
@supports (container-type: inline-size) {
  #dynamic-sidebar {
    container-type: inline-size;
  }
  
  @container (max-width: 280px) {
    .widget-container {
      font-size: 0.875rem;
    }
    
    .widget-container[data-widget-type="categories"],
    .widget-container[data-widget-type="tags"] {
      max-height: 150px;
    }
  }
  
  @container (min-width: 360px) {
    .widget-container {
      padding: 1.25rem;
    }
  }
}

/* 工具类 */
.widget-hidden {
  display: none !important;
}

.widget-visible {
  display: block !important;
}

.widget-compact {
  padding: 0.5rem !important;
  font-size: 0.875rem !important;
}

.widget-expanded {
  padding: 1.5rem !important;
  font-size: 1rem !important;
}

/* 调试样式 (开发环境) */
[data-debug="true"] .widget-container {
  border: 1px solid #3b82f6;
  position: relative;
}

[data-debug="true"] .widget-container::before {
  content: attr(data-widget-type) ' [' attr(data-widget-order) ']';
  position: absolute;
  top: -1px;
  left: -1px;
  background: #3b82f6;
  color: white;
  font-size: 10px;
  padding: 2px 4px;
  z-index: 1000;
}