'use client'

import Link from 'next/link'
import { useAdminI18n } from '@/components/I18nProvider'

const languageMeta = {
  en: { flag: '🇺🇸', shortLabel: 'EN' },
  fr: { flag: '🇫🇷', shortLabel: 'FR' },
  ar: { flag: '🇲🇦', shortLabel: 'AR' },
} as const

export default function PublicHeader() {
  const { language } = useAdminI18n()
  const currentLanguage = languageMeta[language]
  const dict = {
    en: {
      admin: 'Admin Console',
      signIn: 'Sign in',
    },
    fr: {
      admin: 'Console admin',
      signIn: 'Connexion',
    },
    ar: {
      admin: 'لوحة الإدارة',
      signIn: 'تسجيل الدخول',
    },
  }[language]

  return (
    <header className="sticky top-0 z-30 border-b border-zinc-800 bg-zinc-950/90 backdrop-blur-md transition-colors">
      <div className="mx-auto flex max-w-6xl items-center justify-between gap-4 px-4 py-4">
        <Link href="/" className="flex items-center gap-3">
          <span className="text-xs font-semibold uppercase tracking-[0.24em] text-emerald-400">RentalDriveGo</span>
          <span className="hidden text-sm font-semibold text-zinc-400 sm:inline">{dict.admin}</span>
        </Link>
        <nav className="flex items-center gap-2">
          <span className="inline-flex min-w-[3.5rem] items-center justify-center gap-1 rounded-full border border-zinc-700 bg-zinc-900 px-2.5 py-2 text-xs font-semibold text-zinc-200">
            <span aria-hidden="true">{currentLanguage.flag}</span>
            <span>{currentLanguage.shortLabel}</span>
          </span>
          <Link href="/login" className="rounded-full bg-zinc-100 px-4 py-2 text-sm font-semibold text-zinc-950 transition hover:bg-zinc-300">
            {dict.signIn}
          </Link>
        </nav>
      </div>
    </header>
  )
}
