"use client";

import Link from "next/link";
import { getTopicConfig } from "../config";

type TopicFooterProps = {
  topicId: string;
};

export function TopicFooter({ topicId }: TopicFooterProps) {
  const config = getTopicConfig(topicId);

  return (
    <footer className="border-t border-[var(--border)] py-6 sm:py-8">
      <div className="mx-auto max-w-6xl px-4 sm:px-6">
        <div className="mb-4 flex flex-wrap items-center justify-center gap-4">
          <Link href="/" className="text-sm text-[var(--muted-foreground)] hover:text-[var(--foreground)]">
            返回首页
          </Link>
          <Link
            href="/#topics"
            className="text-sm text-[var(--muted-foreground)] hover:text-[var(--foreground)]"
          >
            模块列表
          </Link>
          <a
            href="https://chatwoot.hackrobot.cn/livechat?user_id=hackrobot"
            target="_blank"
            rel="noopener noreferrer"
            className="inline-flex items-center gap-1.5 rounded-full bg-[var(--accent)]/15 px-4 py-2 text-sm font-medium text-[var(--accent)] transition hover:bg-[var(--accent)]/25"
          >
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
              <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
            </svg>
            即时问答
          </a>
        </div>
        <div className="text-center text-sm text-[var(--muted-foreground)]">
          {config ? `${config.icon} ${config.title} · 异度星球` : "异度星球 · 数字游民社群"}
        </div>
      </div>
    </footer>
  );
}
