//
//  PasswordRecommendations.swift
//  AlloVoisinsSwiftUI
//
//  Created by Victor on 22/10/2025.
//

import SwiftUI

struct PasswordRecommendations: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 2) {
            ForEach(PasswordRequirements.allCases, id: \.self) { requirement in
                if requirement == .minChar {
                    requirementView(for: requirement)

                    SQText("Au moins 3 des 4 catégories suivantes :")
                        .padding(.top, 8)
                        .sqSize(12)
                } else {
                    requirementView(for: requirement)
                }

            }
        }
        .padding(8)
        .frame(maxWidth: .infinity, alignment: .leading)
        .background(Color(red: 0.95, green: 0.97, blue: 1))
        .cornerRadius(8)
    }

    func requirementView(for requirement: PasswordRequirements, isValid: Bool = false) -> some View {
            HStack(spacing: 4) {
                SQIcon(.check, size: .xs, color: isValid ? .sqSemanticPositive : .sqNeutral(50))
                SQText(requirement.rawValue)
                    .sqSize(12)
                    .sqColor(isValid ? .sqNeutral(80) : .sqNeutral(50))
            }
        }

    enum PasswordRequirements: String, CaseIterable {
        case minChar = "8 caractères minimum"
        case oneMaj = "Une lettre majuscule"
        case oneMin = "Une lettre minuscule"
        case oneNum = "Un chiffre"
        case oneSpe = "Un caractère spécial"
    }
}

#Preview {
    PasswordRecommendations()
        .padding(16)
}
