use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Public server status (for status page display)
#[derive(Debug, Clone, Serialize)]
pub struct PublicServerStatus {
    pub server_name: String,
    pub subdomain: String,
    pub status: String, // "online", "offline", "degraded"
    pub player_count: i32,
    pub max_players: i32,
    pub uptime_24h_percent: f64,
    pub uptime_7d_percent: f64,
    pub uptime_30d_percent: f64,
    pub map_name: Option<String>,
    pub wipe_schedule: Option<String>,
    pub next_wipe: Option<DateTime<Utc>>,
    pub description: Option<String>,
}

/// Platform-wide health metrics
#[derive(Debug, Clone, Serialize)]
pub struct PlatformHealth {
    pub total_servers: i64,
    pub online_servers: i64,
    pub total_players: i64,
    pub uptime_percent: f64,
}

/// Full status page response
#[derive(Debug, Clone, Serialize)]
pub struct StatusPageResponse {
    pub servers: Vec<PublicServerStatus>,
    pub platform_health: PlatformHealth,
}

/// Public site configuration
#[derive(Debug, Clone, sqlx::FromRow, Serialize, Deserialize)]
pub struct PublicSiteConfig {
    pub id: Uuid,
    pub license_id: Uuid,
    pub site_enabled: bool,
    pub show_on_status_page: bool,
    pub steam_connect_url: Option<String>,
    pub motd: Option<String>,
    pub public_mods: Option<Vec<String>>,
    pub header_image_url: Option<String>,
    pub theme_color: Option<String>,
    pub custom_css: Option<String>,
    pub discord_invite_url: Option<String>,
    pub show_player_count: bool,
    pub show_wipe_schedule: bool,
    pub show_wipe_countdown: bool,
    pub show_mod_list: bool,
    pub status_page_description: Option<String>,
    pub created_at: DateTime<Utc>,
}

/// Update request for public site settings
#[derive(Debug, Clone, Deserialize)]
pub struct UpdatePublicSiteRequest {
    pub site_enabled: Option<bool>,
    pub show_on_status_page: Option<bool>,
    pub status_page_description: Option<String>,
    pub steam_connect_url: Option<String>,
    pub motd: Option<String>,
    pub header_image_url: Option<String>,
    pub theme_color: Option<String>,
    pub discord_invite_url: Option<String>,
    pub show_player_count: Option<bool>,
    pub show_wipe_schedule: Option<bool>,
    pub show_wipe_countdown: Option<bool>,
    pub show_mod_list: Option<bool>,
}
