<template>
  <div class="min-h-screen bg-gray-900">
    <div class="w-full h-[55px] sm:h-[72px]"></div>
    <ErrorBoundary :error="error">
      <div v-if="isLoading" class="flex justify-center py-16">
        <div class="animate-spin h-8 w-8 border-2 border-blue-400 border-t-transparent rounded-full"></div>
      </div>

      <div v-else>
        <!-- 面包屑导航 -->
        <div class="bg-gray-800 border-b border-gray-700">
          <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
            <nav class="flex items-center space-x-2 text-sm text-gray-400">
              <nuxt-link
                :to="`${homepagePath}/`"
                class="hover:text-blue-400 transition-colors duration-200"
              >
                {{ t("common.home") }}
              </nuxt-link>
              <svg class="w-4 h-4 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
              </svg>
              <span class="text-gray-200 font-medium">{{ t("support.title") }}</span>
            </nav>
          </div>
        </div>

        <!-- 页面头部 -->
        <div class="bg-gray-800">
          <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
            <div class="text-center">
              <h1 class="text-4xl font-bold text-white mb-4">
                {{ t("support.title") }}
              </h1>
              <p class="text-xl text-gray-300 max-w-3xl mx-auto">
                {{ t("support.subtitle") }}
              </p>
            </div>
          </div>
        </div>

        <!-- 主要服务区域 -->
        <div class="bg-gray-900">
          <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
            <!-- 主要服务 -->
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mb-16">
              <!-- FAQ卡片 -->
              <nuxt-link 
                :to="`${homepagePath}/support/faq`"
                class="group bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-8 hover:shadow-xl hover:border-blue-500/50 transition-all duration-200"
              >
                <div class="flex items-start">
                  <div class="flex-shrink-0">
                    <div class="w-12 h-12 bg-blue-500/20 text-blue-400 rounded-lg flex items-center justify-center">
                      <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                      </svg>
                    </div>
                  </div>
                  <div class="ml-6 flex-1">
                    <h3 class="text-xl font-semibold text-white mb-3 group-hover:text-blue-400 transition-colors">
                      {{ t("support.faq.title") }}
                    </h3>
                    <p class="text-gray-400 mb-4 leading-relaxed">
                      {{ t("support.faq.description") }}
                    </p>
                    <div class="flex items-center text-blue-400 font-medium text-sm">
                      {{ t("support.viewMore") }}
                      <svg class="w-4 h-4 ml-2 group-hover:translate-x-1 transition-transform duration-200" fill="none" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
                      </svg>
                    </div>
                  </div>
                </div>
              </nuxt-link>

              <!-- 联系我们卡片 -->
              <nuxt-link 
                :to="`${homepagePath}/contact`"
                class="group bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-8 hover:shadow-xl hover:border-green-500/50 transition-all duration-200"
              >
                <div class="flex items-start">
                  <div class="flex-shrink-0">
                    <div class="w-12 h-12 bg-green-500/20 text-green-400 rounded-lg flex items-center justify-center">
                      <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
                      </svg>
                    </div>
                  </div>
                  <div class="ml-6 flex-1">
                    <h3 class="text-xl font-semibold text-white mb-3 group-hover:text-green-400 transition-colors">
                      {{ t("support.contact.title") }}
                    </h3>
                    <p class="text-gray-400 mb-4 leading-relaxed">
                      {{ t("support.contact.description") }}
                    </p>
                    <div class="flex items-center text-green-400 font-medium text-sm">
                      {{ t("support.contactUs") }}
                      <svg class="w-4 h-4 ml-2 group-hover:translate-x-1 transition-transform duration-200" fill="none" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
                      </svg>
                    </div>
                  </div>
                </div>
              </nuxt-link>
            </div>

            <!-- 其他服务 -->
            <div class="border-t border-gray-700 pt-16">
              <h2 class="text-2xl font-bold text-white text-center mb-12">其他支持服务</h2>
              <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                <!-- 技术文档 -->
                <div 
                  class="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-6 text-center cursor-pointer hover:shadow-xl hover:border-purple-500/50 transition-all duration-200"
                  @click="showDocsModal = true"
                >
                  <div class="w-12 h-12 bg-purple-500/20 text-purple-400 rounded-lg flex items-center justify-center mx-auto mb-4">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.246 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"></path>
                    </svg>
                  </div>
                  <h3 class="text-lg font-semibold text-white mb-2">
                    {{ t("support.docs.title") }}
                  </h3>
                  <p class="text-gray-400 text-sm mb-4">
                    {{ t("support.docs.description") }}
                  </p>
                  <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-700 text-gray-300">
                    {{ t("support.comingSoon") }}
                  </span>
                </div>

                <!-- 产品手册 -->
                <div 
                  class="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-6 text-center cursor-pointer hover:shadow-xl hover:border-orange-500/50 transition-all duration-200"
                  @click="showManualsModal = true"
                >
                  <div class="w-12 h-12 bg-orange-500/20 text-orange-400 rounded-lg flex items-center justify-center mx-auto mb-4">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                    </svg>
                  </div>
                  <h3 class="text-lg font-semibold text-white mb-2">
                    {{ t("support.manuals.title") }}
                  </h3>
                  <p class="text-gray-400 text-sm mb-4">
                    {{ t("support.manuals.description") }}
                  </p>
                  <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-700 text-gray-300">
                    {{ t("support.comingSoon") }}
                  </span>
                </div>

                <!-- 驱动下载 -->
                <div 
                  class="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-6 text-center cursor-pointer hover:shadow-xl hover:border-cyan-500/50 transition-all duration-200"
                  @click="showDriversModal = true"
                >
                  <div class="w-12 h-12 bg-cyan-500/20 text-cyan-400 rounded-lg flex items-center justify-center mx-auto mb-4">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"></path>
                    </svg>
                  </div>
                  <h3 class="text-lg font-semibold text-white mb-2">
                    {{ t("support.drivers.title") }}
                  </h3>
                  <p class="text-gray-400 text-sm mb-4">
                    {{ t("support.drivers.description") }}
                  </p>
                  <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-700 text-gray-300">
                    {{ t("support.comingSoon") }}
                  </span>
                </div>

                <!-- 在线客服 -->
                <div 
                  class="bg-gray-800 rounded-lg shadow-lg border border-gray-700 p-6 text-center cursor-pointer hover:shadow-xl hover:border-red-500/50 transition-all duration-200"
                  @click="showChatModal = true"
                >
                  <div class="w-12 h-12 bg-red-500/20 text-red-400 rounded-lg flex items-center justify-center mx-auto mb-4">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path>
                    </svg>
                  </div>
                  <h3 class="text-lg font-semibold text-white mb-2">
                    {{ t("support.chat.title") }}
                  </h3>
                  <p class="text-gray-400 text-sm mb-4">
                    {{ t("support.chat.description") }}
                  </p>
                  <span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-gray-700 text-gray-300">
                    {{ t("support.comingSoon") }}
                  </span>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 联系信息区域 -->
        <div class="bg-gray-800 border-t border-gray-700">
          <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
            <div class="text-center">
              <h2 class="text-2xl font-bold text-white mb-4">需要进一步帮助？</h2>
              <p class="text-gray-300 mb-8 max-w-2xl mx-auto">
                我们的专业技术支持团队随时为您提供帮助，确保您获得最佳的产品体验。
              </p>
              <div class="flex flex-col sm:flex-row gap-4 justify-center">
                <nuxt-link
                  :to="`${homepagePath}/contact`"
                  class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 transition-colors duration-200"
                >
                  <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
                  </svg>
                  联系技术支持
                </nuxt-link>
                <nuxt-link
                  :to="`${homepagePath}/support/faq`"
                  class="inline-flex items-center px-6 py-3 border border-gray-600 text-base font-medium rounded-md text-gray-300 bg-gray-700 hover:bg-gray-600 transition-colors duration-200"
                >
                  <svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                  </svg>
                  浏览常见问题
                </nuxt-link>
              </div>
            </div>
          </div>
        </div>

        <!-- 模态框 -->
        <div 
          v-if="showDocsModal" 
          class="fixed inset-0 bg-black bg-opacity-75 z-50 flex items-center justify-center p-4"
          @click="showDocsModal = false"
        >
          <div 
            class="bg-gray-800 rounded-lg max-w-md w-full shadow-2xl border border-gray-700"
            @click.stop
          >
            <div class="flex items-center justify-between p-6 border-b border-gray-700">
              <h2 class="text-xl font-semibold text-white">{{ t("support.docs.title") }}</h2>
              <button 
                @click="showDocsModal = false"
                class="text-gray-400 hover:text-gray-200 transition-colors"
              >
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                </svg>
              </button>
            </div>
            <div class="p-6 text-center">
              <div class="w-16 h-16 bg-purple-500/20 text-purple-400 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                </svg>
              </div>
              <h3 class="text-lg font-semibold text-white mb-2">{{ t("support.comingSoon") }}</h3>
              <p class="text-gray-400 text-sm">我们正在为您准备详细的技术文档，敬请期待</p>
            </div>
          </div>
        </div>

        <div 
          v-if="showManualsModal" 
          class="fixed inset-0 bg-black bg-opacity-75 z-50 flex items-center justify-center p-4"
          @click="showManualsModal = false"
        >
          <div 
            class="bg-gray-800 rounded-lg max-w-md w-full shadow-2xl border border-gray-700"
            @click.stop
          >
            <div class="flex items-center justify-between p-6 border-b border-gray-700">
              <h2 class="text-xl font-semibold text-white">{{ t("support.manuals.title") }}</h2>
              <button 
                @click="showManualsModal = false"
                class="text-gray-400 hover:text-gray-200 transition-colors"
              >
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                </svg>
              </button>
            </div>
            <div class="p-6 text-center">
              <div class="w-16 h-16 bg-orange-500/20 text-orange-400 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                </svg>
              </div>
              <h3 class="text-lg font-semibold text-white mb-2">{{ t("support.comingSoon") }}</h3>
              <p class="text-gray-400 text-sm">产品手册下载功能即将上线，敬请期待</p>
            </div>
          </div>
        </div>

        <div 
          v-if="showDriversModal" 
          class="fixed inset-0 bg-black bg-opacity-75 z-50 flex items-center justify-center p-4"
          @click="showDriversModal = false"
        >
          <div 
            class="bg-gray-800 rounded-lg max-w-md w-full shadow-2xl border border-gray-700"
            @click.stop
          >
            <div class="flex items-center justify-between p-6 border-b border-gray-700">
              <h2 class="text-xl font-semibold text-white">{{ t("support.drivers.title") }}</h2>
              <button 
                @click="showDriversModal = false"
                class="text-gray-400 hover:text-gray-200 transition-colors"
              >
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                </svg>
              </button>
            </div>
            <div class="p-6 text-center">
              <div class="w-16 h-16 bg-cyan-500/20 text-cyan-400 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                </svg>
              </div>
              <h3 class="text-lg font-semibold text-white mb-2">{{ t("support.comingSoon") }}</h3>
              <p class="text-gray-400 text-sm">驱动程序下载区域正在准备中，敬请期待</p>
            </div>
          </div>
        </div>

        <div 
          v-if="showChatModal" 
          class="fixed inset-0 bg-black bg-opacity-75 z-50 flex items-center justify-center p-4"
          @click="showChatModal = false"
        >
          <div 
            class="bg-gray-800 rounded-lg max-w-md w-full shadow-2xl border border-gray-700"
            @click.stop
          >
            <div class="flex items-center justify-between p-6 border-b border-gray-700">
              <h2 class="text-xl font-semibold text-white">{{ t("support.chat.title") }}</h2>
              <button 
                @click="showChatModal = false"
                class="text-gray-400 hover:text-gray-200 transition-colors"
              >
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                </svg>
              </button>
            </div>
            <div class="p-6 text-center">
              <div class="w-16 h-16 bg-red-500/20 text-red-400 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                </svg>
              </div>
              <h3 class="text-lg font-semibold text-white mb-2">{{ t("support.comingSoon") }}</h3>
              <p class="text-gray-400 text-sm">在线客服功能即将为您开通，敬请期待</p>
            </div>
          </div>
        </div>
      </div>
    </ErrorBoundary>
  </div>
</template>

<script setup lang="ts">
/**
 * 技术支持页面
 * 提供专业的技术支持服务入口
 */
import { useErrorHandler } from "~/composables/useErrorHandler";

const { error, isLoading } = useErrorHandler();
const { t, locale } = useI18n();

// 计算首页路径
const homepagePath = computed(() => {
  return locale.value === "zh" ? "" : `/${locale.value}`;
});

// 模态框控制
const showDocsModal = ref(false);
const showManualsModal = ref(false);
const showDriversModal = ref(false);
const showChatModal = ref(false);

// SEO优化
useHead({
  title: t("support.title") + " - Hanye",
  meta: [
    {
      name: "description",
      content: t("support.description"),
    },
    {
      name: "keywords",
      content: t("support.keywords"),
    },
  ],
});
</script>

<style scoped>
/* 简洁的悬停效果 */
.group:hover {
  transform: translateY(-2px);
}

/* 按钮悬停效果 */
.hover\:bg-blue-700:hover {
  background-color: #1d4ed8;
}

.hover\:bg-gray-600:hover {
  background-color: #4b5563;
}

/* 过渡效果 */
.transition-all {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-colors {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-transform {
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.duration-200 {
  transition-duration: 200ms;
}

/* 专业的阴影效果 */
.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.shadow-xl {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.shadow-2xl {
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* 响应式优化 */
@media (max-width: 768px) {
  .group:hover {
    transform: none;
  }
}
</style> 