/* 儿童友好设计颜色变量 */
:root {
  --kid-yellow: #FFEFD5;
  --kid-blue: #87CEEB;
  --kid-pink: #FFB6C1;
  --kid-green: #98FB98;
  --kid-purple: #DDA0DD;
}

/* 卡通阴影效果 */
.shadow-cartoon {
  box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.15);
}

/* 触发按钮 - 白色背景,橙色图标 */
.knowledge-drawer-trigger {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: white;
  border: 3px solid #f0f0f0;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #FF9A3C;
  cursor: pointer;
  z-index: 999;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.knowledge-drawer-trigger svg {
  width: 28px;
  height: 28px;
}

.knowledge-drawer-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  background: #FFF5E6;
}

.knowledge-drawer-trigger:active {
  transform: translateY(0);
}

/* 抽屉容器 */
.knowledge-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
}

.knowledge-drawer.open {
  pointer-events: all;
}

/* 背景遮罩 - 带模糊效果 */
.drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.knowledge-drawer.open .drawer-backdrop {
  opacity: 1;
}

/* 抽屉面板 - 超大圆角 + 彩色边框 */
.drawer-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 100%;
  max-width: 450px;
  background: white;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.2), 0 0 0 4px white, 0 0 0 8px rgba(135, 206, 235, 0.2);
  transform: translateX(120%);
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  flex-direction: column;
  border-radius: 3rem;
  overflow: hidden;
}

.knowledge-drawer.open .drawer-panel {
  transform: translateX(0);
}

/* 抽屉头部 - 柔和黄色背景 */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  background: linear-gradient(135deg, var(--kid-yellow) 0%, #FFE4B5 100%);
  flex-shrink: 0;
}

.drawer-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #5a5a5a;
  letter-spacing: 0.5px;
}

.drawer-header h2 svg {
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  padding: 10px;
  box-sizing: content-box;
  color: #FF9A3C;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.drawer-close {
  background: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.drawer-close svg {
  width: 20px;
  height: 20px;
}

.drawer-close:hover {
  background: #FFE5E5;
  color: #FF6B6B;
  transform: rotate(90deg);
}

/* ========== 搜索容器 ========== */
.drawer-search-container {
  position: relative;
  padding: 16px;
  background: white;
  flex-shrink: 0;
  border-bottom: 1px solid #f0f0f0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* 搜索图标 - 左侧 */
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  pointer-events: none;
  z-index: 1;
}

/* 搜索输入框 - 儿童友好样式 */
.search-input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 48px;
  background: #f5f5f5;
  border: 2px solid transparent;
  border-radius: 1.5rem;
  font-size: 15px;
  color: #4a4a4a;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  outline: none;
}

.search-input::placeholder {
  color: #bbb;
}

.search-input:focus {
  background: white;
  border-color: var(--kid-blue);
  box-shadow: 0 0 0 4px rgba(135, 206, 235, 0.15);
}

/* 清空按钮 - 圆形设计 */
.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: #e0e0e0;
  border: none;
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 1;
}

.search-clear-btn:hover {
  background: #FFE5E5;
  color: #FF6B6B;
  transform: translateY(-50%) rotate(90deg);
}

.search-clear-btn:active {
  transform: translateY(-50%) scale(0.9);
}

/* 搜索历史下拉 - 卡通风格 */
.search-history-dropdown {
  position: absolute;
  top: 72px;
  left: 16px;
  right: 16px;
  background: white;
  border: 2px solid #f0f0f0;
  border-radius: 1.5rem;
  box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.15);
  z-index: 100;
  overflow: hidden;
  animation: dropdownSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 历史下拉头部 - 黄色渐变背景 */
.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--kid-yellow) 0%, #FFE4B5 100%);
  border-bottom: 1px solid #f0f0f0;
}

.search-history-header span {
  font-size: 13px;
  font-weight: 700;
  color: #666;
  letter-spacing: 0.5px;
}

/* 清空历史按钮 */
.clear-history-btn {
  background: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.clear-history-btn:hover {
  background: #FFE5E5;
  color: #FF6B6B;
  transform: rotate(15deg);
}

/* 历史列表 */
.search-history-list {
  list-style: none;
  padding: 8px;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
}

/* 历史列表项 */
.search-history-item {
  padding: 10px 12px;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #666;
}

.search-history-item:hover {
  background: var(--kid-blue);
  color: white;
  transform: translateX(4px);
}

.search-history-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* 空历史提示 */
.search-history-empty {
  padding: 24px;
  text-align: center;
  color: #ccc;
  font-size: 13px;
}

/* 分类导航包装器 */
.drawer-categories-wrapper {
  position: relative;
  flex-shrink: 0;
}

/* 分类导航 - 优化样式 */
.drawer-categories {
  display: flex;
  gap: 8px;
  padding: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.drawer-categories::-webkit-scrollbar {
  display: none;
}

/* 滚动渐变提示 - 独立div */
.drawer-categories-gradient {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 64px;
  background: linear-gradient(to left, white 0%, rgba(255, 255, 255, 0.8) 50%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

.category-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  background: #f5f5f5;
  border: 2px solid transparent;
  border-radius: 1.5rem;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #999;
}

.category-btn svg {
  width: 18px;
  height: 18px;
}

.category-btn:hover {
  background: #e9ecef;
  color: #666;
}

.category-btn.active {
  background: var(--kid-yellow);
  border-color: white;
  color: #666;
  transform: scale(1.05);
  box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.15);
}

/* 为不同类型分类按钮设置不同激活颜色 */
.category-btn[data-category="TEXT"].active {
  background: var(--kid-purple);
}

.category-btn[data-category="IMAGE_TEXT"].active {
  background: var(--kid-green);
}

.category-btn[data-category="AUDIO"].active {
  background: var(--kid-pink);
}

.category-btn[data-category="VIDEO"].active {
  background: var(--kid-blue);
}

/* 内容区域 */
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  position: relative;
  scrollbar-width: none;
}

.drawer-content::-webkit-scrollbar {
  display: none;
}

/* 加载状态 */
.items-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #f0f0f0;
  border-top: 5px solid var(--kid-blue);
  border-radius: 50%;
  animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 空状态 */
.items-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #ccc;
  animation: emptyFadeIn 0.4s ease;
}

@keyframes emptyFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.items-empty .empty-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.items-empty i {
  font-size: 64px;
  margin-bottom: 16px;
}

.items-empty p {
  font-size: 16px;
  color: #999;
  margin: 0;
}

.items-empty .empty-hint {
  font-size: 14px;
  color: #bbb;
  margin-top: 8px;
}

/* 项目网格 */
.items-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
}

/* 知识库项目卡片 - 儿童友好设计 */
.knowledge-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: white;
  border: 2px solid #f0f0f0;
  border-radius: 1.5rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.knowledge-item:hover {
  border-color: var(--kid-blue);
  box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.knowledge-item:active {
  transform: translateY(0);
  box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.15);
}

/* 项目图标 - 更大,柔和配色 */
.item-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.item-icon svg {
  width: 28px;
  height: 28px;
}

.knowledge-item:hover .item-icon {
  transform: scale(1.1) rotate(6deg);
}

/* 柔和的儿童色调 */
.icon-red {
  background: #FFE5E5;
  color: #FF6B6B;
}

.icon-green {
  background: #E5FFE5;
  color: #51CF66;
}

.icon-blue {
  background: #E0F7FF;
  color: #339AF0;
}

.icon-purple {
  background: #F3E5FF;
  color: #CC5DE8;
}

.icon-pink {
  background: #FFE5F0;
  color: #FF6B9D;
}

.icon-gray {
  background: #F5F5F5;
  color: #999;
}

/* 项目内容 */
.item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.item-title {
  font-size: 17px;
  font-weight: 700;
  color: #4a4a4a;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.item-meta {
  display: flex;
  align-items: center;
  margin: 0;
}

/* 类型徽章 - 柔和配色 */
.item-type-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

.item-type-badge.badge-text {
  background: var(--kid-purple);
  color: #7B2CBF;
}

.item-type-badge.badge-image-text {
  background: var(--kid-green);
  color: #2D6A4F;
}

.item-type-badge.badge-audio {
  background: var(--kid-pink);
  color: #C9184A;
}

.item-type-badge.badge-video {
  background: var(--kid-blue);
  color: #0077B6;
}

/* 项目操作图标 */
.item-action {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  transition: all 0.3s;
}

.item-action svg {
  width: 18px;
  height: 18px;
}

.knowledge-item:hover .item-action {
  background: var(--kid-blue);
  color: white;
}

/* 分页 - 底部固定 */
.drawer-pagination {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid #f0f0f0;
  border-radius: 0 0 2.7rem 2.7rem;
  flex-shrink: 0;
}

.pagination-prev,
.pagination-next {
  width: 48px;
  height: 48px;
  border: none;
  background: #f5f5f5;
  border-radius: 50%;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pagination-prev:not(:disabled):hover,
.pagination-next:not(:disabled):hover {
  background: var(--kid-blue);
  color: white;
  transform: scale(1.1);
}

.pagination-prev:disabled,
.pagination-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 14px;
  font-weight: 700;
  color: #666;
  background: #f5f5f5;
  padding: 8px 16px;
  border-radius: 24px;
}

/* 响应式 */
@media (max-width: 768px) {
  .drawer-panel {
    top: 0;
    right: 0;
    bottom: 0;
    max-width: 100%;
    border-radius: 0;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.2);
  }

  .knowledge-drawer-trigger {
    top: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
    font-size: 24px;
  }

  .item-icon {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .item-title {
    font-size: 16px;
  }
}

/* 滚动条隐藏 */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}
