// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2025-01-29',

  devtools: {
    enabled: ['true', '1'].includes(process.env.NUXT_DEVTOOLS_ENABLED || ''),
  },

  // App configuration
  app: {
    head: {
      // Roboto font is now loaded locally from /public/fonts/roboto/
      // See @font-face declarations in assets/css/tailwind.css
      link: [
        {
          rel: 'preload',
          as: 'font',
          type: 'font/woff2',
          href: '/fonts/roboto/Roboto-VariableFont-latin.woff2',
          crossorigin: 'anonymous',
        },
      ],
    },
  },

  // Modules
  modules: ['nuxt-auth-utils', '@nuxtjs/tailwindcss', 'shadcn-nuxt', '@nuxt/eslint'],

  // i18n configuration (temporarily disabled for debugging)
  // i18n: {
  //   locales: [
  //     { code: 'de', language: 'de-DE', file: 'de-DE.json', name: 'Deutsch' },
  //     { code: 'en', language: 'en-US', file: 'en-US.json', name: 'English' },
  //   ],
  //   defaultLocale: 'de',
  //   lazy: true,
  //   langDir: 'locales',
  //   strategy: 'prefix_except_default',
  //   vueI18n: './i18n.config.ts',
  // },

  // shadcn-nuxt configuration
  shadcn: {
    prefix: '',
    componentDir: './app/components/ui',
  },

  // Runtime configuration
  runtimeConfig: {
    // Server-only config
    databaseUrl: process.env.DATABASE_URL,
    redisHost: process.env.REDIS_HOST || 'localhost',
    redisPort: process.env.REDIS_PORT || '6379',
    internalAuthEnabled: ['true', '1'].includes(process.env.INTERNAL_AUTH_ENABLED || '') || false,
    internalAuthUsername: process.env.INTERNAL_AUTH_USERNAME || '',
    internalAuthPassword: process.env.INTERNAL_AUTH_PASSWORD || '',

    // Cidaas OAuth2 Configuration
    cidaas: {
      clientId: process.env.CIDAAS_CLIENT_ID,
      clientSecret: process.env.CIDAAS_CLIENT_SECRET,
      issuer: process.env.CIDAAS_ISSUER,
      authorizeUrl: process.env.CIDAAS_AUTHORIZE_URL,
      tokenUrl: process.env.CIDAAS_TOKEN_URL,
      userinfoUrl: process.env.CIDAAS_USERINFO_URL,
      jwksUrl: process.env.CIDAAS_JWKS_URL,
      redirectUri: process.env.CIDAAS_REDIRECT_URI,
    },

    // Session configuration
    session: {
      maxAge: 60 * 60 * 24 * 30, // 30 days in seconds
      name: 'experimenta-session',
      password: process.env.NUXT_SESSION_SECRET || '',
    },

    // Public (exposed to client)
    public: {
      appUrl: process.env.APP_URL || 'http://localhost:3000',
    },
  },

  // TypeScript configuration
  typescript: {
    strict: true,
    typeCheck: false, // Disabled for now, will enable in later phases with vue-tsc
  },

  // Security headers for auth routes
  nitro: {
    routeRules: {
      '/api/auth/**': {
        headers: {
          'X-Frame-Options': 'DENY',
          'X-Content-Type-Options': 'nosniff',
          'Referrer-Policy': 'strict-origin-when-cross-origin',
        },
      },
    },
  },
})
