plugins {
    id 'com.android.application'
}

android {
    namespace 'com.vpnpanel'
    compileSdk 34

    defaultConfig {
        applicationId "com.vpnpanel"
        minSdk 24
        targetSdk 34
        versionCode 1
        versionName "1.0.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        
        // امنیت: جلوگیری از Backup
        manifestPlaceholders = [
            allowBackup: "false"
        ]
    }

    signingConfigs {
        release {
            // TODO: مسیر فایل Keystore خود را وارد کنید
            storeFile file("release-keystore.jks")
            storePassword System.getenv("KEYSTORE_PASSWORD") ?: "your-keystore-password"
            keyAlias System.getenv("KEY_ALIAS") ?: "your-key-alias"
            keyPassword System.getenv("KEY_PASSWORD") ?: "your-key-password"
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            
            // غیرفعال کردن Debuggable
            debuggable false
            
            // Build Config Fields
            buildConfigField "String", "API_BASE_URL", "\"https://your-api-domain.com/api/\""
            buildConfigField "boolean", "ENABLE_LOGGING", "false"
        }
        
        debug {
            minifyEnabled false
            debuggable true
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            
            buildConfigField "String", "API_BASE_URL", "\"http://10.0.2.2:8000/api/\""
            buildConfigField "boolean", "ENABLE_LOGGING", "true"
        }
    }
    
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    
    buildFeatures {
        viewBinding true
        buildConfig true
    }
}

dependencies {
    // AndroidX
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.recyclerview:recyclerview:1.3.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    
    // Material Design
    implementation 'com.google.android.material:material:1.11.0'
    
    // Networking - Retrofit & OkHttp
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:okhttp:4.12.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
    
    // Security - Encrypted SharedPreferences
    implementation 'androidx.security:security-crypto:1.1.0-alpha06'
    
    // Google Play Services - SafetyNet (optional but recommended)
    implementation 'com.google.android.gms:play-services-safetynet:18.0.1'
    
    // VPN Libraries
    // TODO: اضافه کردن کتابخانه VPN مورد نظر (مثل V2Ray, OpenVPN)
    // implementation 'com.v2ray:v2ray-core:x.x.x'
    
    // Testing
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
