import SwiftUI

/// The web app's "Zenith Silver" palette (see `tailwind.config.ts`'s `zenith`
/// color group and `DESIGN (1).md` in the main repo root), ported 1:1 as hex
/// values — this is a single fixed light palette, not a light/dark pair: the
/// web app itself has no dark mode, and "Architectural Minimalist" is
/// deliberately monochromatic, so inventing a dark variant here would not be
/// matching the web app's design, it would be a different one. If dark mode
/// is wanted later, that's a deliberate follow-up design decision, not a gap
/// in this port.
extension Color {
    init(zenithHex hex: UInt32) {
        self.init(
            .sRGB,
            red: Double((hex >> 16) & 0xFF) / 255,
            green: Double((hex >> 8) & 0xFF) / 255,
            blue: Double(hex & 0xFF) / 255,
            opacity: 1
        )
    }

    // MARK: - Base surfaces

    /// Page background — "Zenith Silver" itself.
    static let zenithBg = Color(zenithHex: 0xF6F9FF)
    /// Card/container fill — Level 1 in the system's elevation model.
    static let zenithSurface = Color(zenithHex: 0xFFFFFF)
    static let zenithDim = Color(zenithHex: 0xD4DBE2)
    static let zenithLow = Color(zenithHex: 0xEEF4FC)
    static let zenithContainer = Color(zenithHex: 0xE8EEF6)
    static let zenithHigh = Color(zenithHex: 0xE3E9F1)
    static let zenithHighest = Color(zenithHex: 0xDDE3EB)

    // MARK: - Structure

    /// The one border color used everywhere at 1px (2px on an active/focused
    /// control — see `ZenithTextField`).
    static let zenithBorder = Color(zenithHex: 0xE2E8F0)
    static let zenithBorderDark = Color(zenithHex: 0xC4C7C9)

    // MARK: - Type

    static let zenithText = Color(zenithHex: 0x161C22)
    static let zenithMuted = Color(zenithHex: 0x444749)
    static let zenithSubtle = Color(zenithHex: 0x747779)

    // MARK: - Ink & accent

    /// Pure black — primary buttons, headline type, structural strokes.
    static let zenithBlack = Color(zenithHex: 0x000000)
    /// Slate blue-grey — secondary actions, metadata, the color a primary
    /// button's fill shifts to on a pressed/hover state instead of "lifting".
    static let zenithSlate = Color(zenithHex: 0x475569)
    static let zenithAccent = Color(zenithHex: 0x1E293B)
    static let zenithError = Color(zenithHex: 0xBA1A1A)

    // MARK: - Status tiers
    //
    // Ported directly from `src/components/dashboard/StatusBadge.tsx`
    // (`getStatusTierMeta`) — these are standard Tailwind emerald/amber/blue
    // shades, NOT part of the Zenith Silver monochrome palette itself. The
    // web app deliberately allows exactly these three status colors as the
    // one place the otherwise-monochrome system admits color, so this app
    // should use them only for the same purpose (receipt status), not as a
    // general accent.

    static let zenithScannedBg = Color(zenithHex: 0xECFDF5)
    static let zenithScannedText = Color(zenithHex: 0x065F46)
    static let zenithScannedBorder = Color(zenithHex: 0xA7F3D0)
    static let zenithScannedDot = Color(zenithHex: 0x10B981)

    static let zenithPendingBg = Color(zenithHex: 0xFFFBEB)
    static let zenithPendingText = Color(zenithHex: 0x92400E)
    static let zenithPendingBorder = Color(zenithHex: 0xFDE68A)
    static let zenithPendingDot = Color(zenithHex: 0xF59E0B)

    static let zenithConfirmedBg = Color(zenithHex: 0xEFF6FF)
    static let zenithConfirmedText = Color(zenithHex: 0x1D4ED8)
    static let zenithConfirmedBorder = Color(zenithHex: 0xBFDBFE)
    static let zenithConfirmedDot = Color(zenithHex: 0x2563EB)
}
