namespace Meezi.API.Models.Auth;

public record SendOtpRequest(string Phone);

/// <summary>Username + password login (alternative to OTP). Optional cafeId to scope to a specific café.</summary>
public record LoginWithPasswordRequest(string Username, string Password, string? CafeId = null);

public record VerifyOtpRequest(string Phone, string Code, string? CafeId = null);

public record RefreshTokenRequest(string RefreshToken);

public record SwitchCafeRequest(string CafeId);

/// <summary>Switch the active branch within the current café. Null = café-wide (Owner only).</summary>
public record SwitchBranchRequest(string? BranchId);

/// <summary>Step 1 of self-registration: send OTP to a new phone number.</summary>
/// <param name="Slug">Optional custom Koja slug (e.g. "lamiz-enghelab"). Auto-derived from CafeName if omitted.</param>
public record RegisterRequest(string Phone, string CafeName, string? Slug = null);

/// <summary>Step 2 of self-registration: verify OTP and create the cafe account.</summary>
public record VerifyRegisterRequest(string Phone, string Code);

/// <summary>One café membership entry returned when user belongs to multiple cafés.</summary>
public record CafeMembershipDto(string CafeId, string CafeName, string Role, string PlanTier);

/// <summary>A branch the signed-in employee may operate as, with their role there.</summary>
public record BranchMembershipDto(string BranchId, string BranchName, string Role);

public record AuthTokenResponse(
    string AccessToken,
    string RefreshToken,
    DateTime ExpiresAt,
    string UserId,
    string CafeId,
    string Role,
    string PlanTier,
    string Language,
    string Actor = Meezi.Core.Constants.MeeziActorKinds.Merchant,
    string? BranchId = null,
    List<CafeMembershipDto>? Memberships = null,
    string? BranchName = null,
    bool IsCafeWide = false,
    List<BranchMembershipDto>? Branches = null,
    /// <summary>Effective capabilities for the active role — drives client-side page/action gating.</summary>
    List<string>? Permissions = null);

public record SendOtpResponse(bool Sent, int ExpiresInSeconds);

/// <summary>Returned when a phone number belongs to multiple cafés and no CafeId was specified.</summary>
public record CafeChoicesResponse(List<CafeMembershipDto> Cafes);
