import dotenv from "dotenv";
import { resolve } from "node:path";
import tailwindcss from "@tailwindcss/vite";

dotenv.config({ path: resolve(__dirname, ".env") });
dotenv.config({ path: resolve(__dirname, "../.env"), override: false });

const isDev = process.env.NODE_ENV !== "production";
const defaultPublicApiBase = isDev ? "http://localhost:4000" : "https://api.antigol.ru";

export default defineNuxtConfig({
  compatibilityDate: "2026-03-18",
  ssr: false,
  devtools: { enabled: true },
  css: ["primeicons/primeicons.css", "~/assets/css/main.css"],
  vite: {
    plugins: [tailwindcss()]
  },
  runtimeConfig: {
    apiBaseInternal: process.env.NUXT_API_BASE_INTERNAL || "http://backend:4000",
    public: {
      apiBase: process.env.NUXT_PUBLIC_API_BASE || defaultPublicApiBase,
      chatApiBase: process.env.NUXT_PUBLIC_CHAT_API_BASE || (isDev ? "http://localhost:4050" : "https://chat.antigol.ru")
    }
  },
  app: {
    head: {
      htmlAttrs: {
        lang: "ru"
      },
      title: "Антигол",
      meta: [
        { name: "viewport", content: "width=device-width, initial-scale=1" },
        { name: "theme-color", content: "#0f172a" },
        { name: "mobile-web-app-capable", content: "yes" },
        { name: "apple-mobile-web-app-capable", content: "yes" },
        { name: "apple-mobile-web-app-status-bar-style", content: "black-translucent" },
        { name: "apple-mobile-web-app-title", content: "Антигол" }
      ],
      link: [
        { rel: "manifest", href: "/manifest.webmanifest" },
        { rel: "icon", href: "/icons/favicon-32.png", type: "image/png", sizes: "32x32" },
        { rel: "icon", href: "/icons/favicon-16.png", type: "image/png", sizes: "16x16" },
        { rel: "apple-touch-icon", href: "/icons/apple-touch-icon.png", sizes: "180x180" }
      ]
    }
  }
});
