use serde::{Deserialize, Serialize};
use uuid::Uuid;
use chrono::{DateTime, Utc};
use crate::types::chat::MessageType;

/// WebSocket message types
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum WebSocketMessage {
    /// Text message
    Message {
        conversation_id: Uuid,
        content: String,
        message_type: MessageType,
        reply_to: Option<Uuid>,
    },
    /// Typing indicator
    Typing {
        conversation_id: Uuid,
        is_typing: bool,
    },
    /// Read receipt
    ReadReceipt {
        conversation_id: Uuid,
        message_id: Uuid,
    },
    /// User presence
    Presence {
        status: PresenceStatus,
        last_seen: DateTime<Utc>,
    },
    /// Call invitation
    CallInvite {
        conversation_id: Uuid,
        call_type: CallType,
    },
    /// Call response
    CallResponse {
        conversation_id: Uuid,
        accepted: bool,
    },
    /// Call end
    CallEnd {
        conversation_id: Uuid,
        duration: u32,
    },
    /// Error message
    Error {
        code: String,
        message: String,
    },
    /// Ping/Pong for keepalive
    Ping,
    Pong,
}

/// Presence status
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PresenceStatus {
    Online,
    Away,
    Busy,
    Offline,
}

/// Call types
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CallType {
    Audio,
    Video,
    ScreenShare,
}
