// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  app: {
    head: {
      title: "RSSA",
      titleTemplate: "%s - Admin Dashboard",
      meta: [
        { charset: "utf-8" },
        { name: "viewport", content: "width=device-width, initial-scale=1" },
        { name: "format-detection", content: "telephone=no" }
      ],
      link: [
        { rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
        {
          rel: "stylesheet",
          href: "https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap"
        }
      ]
    }
  },
  // css: [
  //   "vuetify/lib/styles/main.sass", // Core Vuetify styles
  //   "@mdi/font/css/materialdesignicons.min.css", // Material Design Icons
  //   "~/scss/style.scss", // Custom application styles
  // ],
  /**
   * Modules dan plugins
   * Integrasi dengan ecosystem Nuxt.js
   */
  modules: [
    "@pinia/nuxt", // State management dengan Pinia
    [
      "@sidebase/nuxt-auth",
      {
        // Add auth module options here as per Sidebase auth guide
        auth: {
          isEnabled: true,
          baseURL:
            process.env.AUTH_ORIGIN || "http://meninjar.dev.rssa.id:3005",
          provider: {
            type: "authjs"
            // Additional provider options can be added here
          },
          globalAppMiddleware: {
            isEnabled: true
          }
        }
      }
    ]
  ],

  plugins: [
    "~/plugins/vuetify.ts" // Setup Vuetify dengan konfigurasi custom
  ],
  ssr: false,

  typescript: {
    shim: false
  },

  build: {
    transpile: ["vuetify"]
  },

  vite: {
    define: {
      "process.env.DEBUG": false
    },
    server: {
      allowedHosts: ["meninjar.dev.rssa.id"]
    }
    // css: {
    //   preprocessorOptions: {
    //     scss: {
    //       // Global SCSS variables yang dapat diakses di semua komponen
    //       additionalData: `@import "~/scss/variables.scss";`,
    //     },
    //   },
    // },
  },

  nitro: {
    serveStatic: true,
    compressPublicAssets: true, // Kompresi asset untuk faster loading,

    /**
     * Prerender routes untuk static generation
     * Halaman yang akan di-generate saat build time
     */
    prerender: {
      // routes: [
      //     '/', // Landing page
      //     '/auth/login', // Halaman login
      //     '/auth/register' // Halaman register
      // ]
    }

    /**
     * Route protection untuk production
     * Middleware untuk security dan rate limiting
     */
    // routeRules: {
    //     '/admin/**': {
    //         headers: { 'X-Robots-Tag': 'noindex' }
    //         // index: false // ❌ Property ini tidak valid - sudah dihapus
    //     }
    // }
  },
  runtimeConfig: {
    authSecret: process.env.AUTH_SECRET,
    keycloakClientSecret: process.env.KEYCLOAK_CLIENT_SECRET,
    keycloakClientId: process.env.KEYCLOAK_CLIENT_ID,
    // Move keycloakIssuer to public to expose on client side
    public: {
      authUrl: process.env.AUTH_ORIGIN || "http://meninjar.dev.rssa.id:3000",
      keycloakIssuer:
        process.env.KEYCLOAK_ISSUER || "https://auth.rssa.top/realms/sandbox"
    }
  },
  // auth: {
  //   isEnabled: true,
  //   baseURL: process.env.AUTH_ORIGIN,
  //   provider: {
  //     type: "authjs",
  //   },
  //   globalAppMiddleware: {
  //     isEnabled: true,
  //   },
  // },
  devServerHandlers: [],

  hooks: {},
  /**
   * Development tools configuration
   * Tools untuk meningkatkan developer experience
   */
  devtools: {
    enabled: true, // Enable Nuxt DevTools untuk debugging
    timeline: {
      enabled: true // Enable timeline untuk performance monitoring
    }
  },

  compatibilityDate: "2025-07-25"
});
