# ============================================
# SOCIAL MEDIA MANAGER - PRODUCTION CONFIG
# Version: 2.0 - Production Environment
# ============================================

spring:
  application:
    name: social-media-manager-prod
    
  # ============================================
  # PRODUCTION DATABASE CONFIGURATION
  # ============================================
  datasource:
    url: ${DATABASE_URL:jdbc:postgresql://postgres:5432/social_media_manager_prod}
    username: ${DATABASE_USERNAME:leadertecnologia}
    password: ${DATABASE_PASSWORD:Leader@2025!Strong#Pass}
    driver-class-name: org.postgresql.Driver
    hikari:
      maximum-pool-size: ${DB_POOL_SIZE:50}
      minimum-idle: ${DB_POOL_MIN_IDLE:10}
      idle-timeout: 300000
      connection-timeout: 30000
      max-lifetime: 1800000
      leak-detection-threshold: 60000
      auto-commit: false
      connection-test-query: SELECT 1
      validation-timeout: 5000
      initialization-fail-timeout: 60000
      
  jpa:
    hibernate:
      ddl-auto: ${DDL_AUTO:validate}
      naming:
        physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
        implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
    show-sql: ${SHOW_SQL:false}
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        default_schema: core_business
        format_sql: false
        use_sql_comments: false
        jdbc:
          batch_size: 50
          batch_versioned_data: true
          fetch_size: 100
          lob:
            non_contextual_creation: true
        order_inserts: true
        order_updates: true
        generate_statistics: true

  # ============================================
  # PRODUCTION REDIS CONFIGURATION
  # ============================================
  data:
    redis:
      host: ${REDIS_HOST:redis}
      port: ${REDIS_PORT:6379}
      password: ${REDIS_PASSWORD:Leader@2025!Strong#Pass}
      database: ${REDIS_DATABASE:0}
      timeout: 5000ms
      lettuce:
        pool:
          max-active: 50
          max-idle: 20
          min-idle: 10
          max-wait: 3000ms
        shutdown-timeout: 3000ms

  # ============================================
  # PRODUCTION SECURITY
  # ============================================
  security:
    oauth2:
      client:
        registration:
          instagram:
            client-id: ${INSTAGRAM_CLIENT_ID:}
            client-secret: ${INSTAGRAM_CLIENT_SECRET:}
            authorization-grant-type: authorization_code
            redirect-uri: "http://162.240.175.216:8000/login/oauth2/code/{registrationId}"
            scope: user_profile,user_media
          facebook:
            client-id: ${FACEBOOK_CLIENT_ID:}
            client-secret: ${FACEBOOK_CLIENT_SECRET:}
            authorization-grant-type: authorization_code
            redirect-uri: "http://162.240.175.216:8000/login/oauth2/code/{registrationId}"
            scope: pages_manage_posts,pages_read_engagement
          linkedin:
            client-id: ${LINKEDIN_CLIENT_ID:}
            client-secret: ${LINKEDIN_CLIENT_SECRET:}
            authorization-grant-type: authorization_code
            redirect-uri: "http://162.240.175.216:8000/login/oauth2/code/{registrationId}"
            scope: r_liteprofile,w_member_social

# ============================================
# PRODUCTION SERVER CONFIGURATION
# ============================================
server:
  port: ${SERVER_PORT:8000}
  servlet:
    encoding:
      charset: UTF-8
      enabled: true
      force: true
  compression:
    enabled: true
    mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
    min-response-size: 1024
  http2:
    enabled: true
  error:
    include-message: never
    include-binding-errors: never
    include-stacktrace: never
    include-exception: false

# ============================================
# PRODUCTION SECURITY CONFIGURATION
# ============================================
security:
  jwt:
    secret: ${JWT_SECRET:Leader@2025!Strong#Pass#JWT#Secret#Key#SuperSecure#Production}
    issuer: social-media-manager-prod
    audience: social-media-manager-users-prod
    expiration: ${JWT_EXPIRATION:86400000}
    refresh-expiration: ${JWT_REFRESH_EXPIRATION:604800000}
    
  cors:
    allowed-origins: ${CORS_ALLOWED_ORIGINS:http://162.240.175.216:4000}
    allowed-methods: GET,POST,PUT,DELETE,PATCH,OPTIONS
    allowed-headers: "*"
    allow-credentials: true
    max-age: 3600
    
  rate-limiting:
    enabled: ${RATE_LIMITING_ENABLED:true}
    global:
      capacity: 5000
      refill-period: 1h
    per-user:
      capacity: 500
      refill-period: 1h
    per-api:
      capacity: 100
      refill-period: 1m

# ============================================
# PRODUCTION ACTUATOR & MONITORING
# ============================================
management:
  endpoints:
    web:
      exposure:
        include: health,metrics,prometheus,info
      base-path: /actuator
  endpoint:
    health:
      show-details: when-authorized
      show-components: when-authorized
      probes:
        enabled: true
    metrics:
      enabled: true
    prometheus:
      enabled: true
    shutdown:
      enabled: false
  metrics:
    distribution:
      percentiles-histogram:
        http.server.requests: true
      percentiles:
        http.server.requests: 0.5, 0.9, 0.95, 0.99
    tags:
      application: ${spring.application.name}
      environment: production
  health:
    circuitbreakers:
      enabled: true
    ratelimiters:
      enabled: true
    diskspace:
      enabled: true
      threshold: 5GB
    redis:
      enabled: true
    db:
      enabled: true

# ============================================
# PRODUCTION LOGGING
# ============================================
logging:
  level:
    com.social.media: ${LOG_LEVEL:INFO}
    org.springframework.security: WARN
    org.springframework.data.jpa: WARN
    org.hibernate.SQL: ERROR
    org.hibernate.orm.jdbc.bind: ERROR
    io.github.resilience4j: INFO
    org.springframework.amqp: WARN
    org.springframework.kafka: WARN
    org.springframework.cache: WARN
    io.micrometer: WARN
    root: WARN
  pattern:
    console: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n"
    file: "%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } --- [%t] %-40.40logger{39} : %m%n"
  file:
    name: ${LOG_FILE_PATH:/app/logs/social-media-manager.log}
    max-size: 100MB
    max-history: 30

# ============================================
# PRODUCTION APPLICATION CONFIG
# ============================================
app:
  business:
    max-users-per-company: ${MAX_USERS_PER_COMPANY:100}
    max-social-accounts-per-user: ${MAX_SOCIAL_ACCOUNTS_PER_USER:20}
    max-posts-per-day: ${MAX_POSTS_PER_DAY:500}
    max-campaigns-per-company: ${MAX_CAMPAIGNS_PER_COMPANY:50}
    max-bots-per-company: ${MAX_BOTS_PER_COMPANY:25}
    
  external-apis:
    timeout-seconds: ${API_TIMEOUT:15}
    max-retries: ${API_MAX_RETRIES:3}
    connection-pool-size: ${API_CONNECTION_POOL_SIZE:50}
    
  file-upload:
    max-file-size: 100MB
    max-request-size: 200MB
    allowed-extensions: jpg,jpeg,png,gif,mp4,mov,avi,pdf,doc,docx
    storage-path: ${UPLOAD_STORAGE_PATH:/app/uploads}
    
  features:
    ai-content-generation: ${FEATURE_AI_CONTENT:true}
    advanced-analytics: ${FEATURE_ADVANCED_ANALYTICS:true}
    multi-tenancy: ${FEATURE_MULTI_TENANCY:true}
    api-versioning: ${FEATURE_API_VERSIONING:true}
    event-sourcing: ${FEATURE_EVENT_SOURCING:true}

# ============================================
# PRODUCTION SPRINGDOC
# ============================================
springdoc:
  api-docs:
    enabled: false
  swagger-ui:
    enabled: false
