// lib/services/ad_config.dart
import 'dart:io' show Platform;

import 'package:flutter/foundation.dart';

/// Ad-unit and app IDs. Dev/test builds use Google's official sample IDs,
/// which serve real test ads and never trigger an AdMob policy strike. The
/// owner replaces the `_real*` constants (and the two native manifests'
/// APPLICATION_ID) with the AdMob console values for release.
///
/// `--dart-define=USE_TEST_ADS=true` forces test IDs even in a release build,
/// for store-review smoke tests on real devices.
class AdConfig {
  static const _forceTest =
      bool.fromEnvironment('USE_TEST_ADS', defaultValue: false);

  static bool get useTestIds => kDebugMode || _forceTest;

  // --- Google official test ad units ---
  static const _testInterstitialAndroid =
      'ca-app-pub-3940256099942544/1033173712';
  static const _testInterstitialIos =
      'ca-app-pub-3940256099942544/4411468910';
  static const _testRewardedAndroid =
      'ca-app-pub-3940256099942544/5224354917';
  static const _testRewardedIos = 'ca-app-pub-3940256099942544/1712485313';
  static const _testBannerAndroid = 'ca-app-pub-3940256099942544/6300978111';
  static const _testBannerIos = 'ca-app-pub-3940256099942544/2934735716';

  // --- Real AdMob console unit IDs (publisher pub-5605900229781491) ---
  static const _realInterstitialAndroid =
      'ca-app-pub-5605900229781491/8489470891';
  static const _realInterstitialIos =
      'ca-app-pub-5605900229781491/2953197478';
  static const _realRewardedAndroid = 'ca-app-pub-5605900229781491/4478032132';
  static const _realRewardedIos = 'ca-app-pub-5605900229781491/7011566835';
  static const _realBannerAndroid = 'ca-app-pub-5605900229781491/5072970060';
  static const _realBannerIos = 'ca-app-pub-5605900229781491/3620287592';

  static String _pick(String testA, String testI, String realA, String realI) {
    final android = useTestIds ? testA : realA;
    final ios = useTestIds ? testI : realI;
    return Platform.isAndroid ? android : ios;
  }

  static String get interstitial => _pick(_testInterstitialAndroid,
      _testInterstitialIos, _realInterstitialAndroid, _realInterstitialIos);

  static String get rewarded => _pick(_testRewardedAndroid, _testRewardedIos,
      _realRewardedAndroid, _realRewardedIos);

  static String get banner => _pick(
      _testBannerAndroid, _testBannerIos, _realBannerAndroid, _realBannerIos);

  /// Non-consumable product id for the "remove ads" purchase. Must match the
  /// product created in App Store Connect and Google Play Console.
  static const removeAdsProductId = 'remove_ads';
}
