/* ===== 历史主题抽屉 / 侧边栏样式 ===== */
.drawer-panel {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-title {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-new-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg-soft);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-main);
  transition: all 0.15s;
}

.drawer-new-btn:hover {
  background: var(--accent);
  color: #fff;
}

.drawer-close-btn {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.drawer-close-btn:hover {
  color: var(--text-main);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--card-bg-soft);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topic-item:hover,
.topic-item.active {
  background: #eff6ff;
  border-color: #93c5fd;
}

.topic-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.topic-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.topic-delete-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 3px 5px;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.topic-item:hover .topic-delete-btn {
  opacity: 0.8;
}

.topic-delete-btn:hover {
  opacity: 1 !important;
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

.topic-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-model-badge {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

.topics-loading,
.topics-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

/* 电脑端 (>= 769px)：在聊天区左侧作为侧边栏并排展示，右侧聊天区完全可编辑操作 */
@media (min-width: 769px) {
  .drawer-backdrop {
    display: none !important;
  }

  .drawer-panel {
    width: 290px;
    flex-shrink: 0;
    height: 100%;
    position: relative;
    transform: none;
    z-index: 10;
    animation: fadeInSlideLeft 0.18s ease-out;
  }

  .drawer-panel.hidden {
    display: none !important;
  }

  @keyframes fadeInSlideLeft {
    from {
      opacity: 0;
      transform: translateX(-12px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

/* 手机端 (<= 768px)：弹出历史聊天抽屉、隐藏 AI Chat 标题文字、用户名只显示前两个字母 */
@media (max-width: 768px) {
  .brand-text {
    display: none !important;
  }

  .uname-full {
    display: none !important;
  }

  .uname-short {
    display: inline !important;
  }

  .user-name-text {
    max-width: none;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 99990;
    transition: opacity 0.25s ease;
  }

  .drawer-backdrop.hidden {
    display: none !important;
  }

  .drawer-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    z-index: 99995;
    transform: translateX(0);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .drawer-panel.hidden {
    transform: translateX(-100%);
    display: none !important;
  }
}
