// Translations shared between public site and admin panel.
export const translations = {
    de: {
        navCars: "Fahrzeuge",
        navWhy: "Warum wir",
        navReviews: "Stimmen",
        navBook: "Buchen",
        bookNow: "Jetzt buchen",
        viewFleet: "Flotte ansehen",

        heroEyebrow: "MC Cars · Sportwagenvermietung",
        heroTitle: "Fahren auf hoechstem Niveau.",
        heroLead: "Premium-Sportwagen und Luxusklasse in der Steiermark. Faire Kaution, transparent, sofort startklar.",

        statDeposit: "Faire Kaution",
        statSupport: "Support",
        statCars: "Fahrzeuge",

        fleetEyebrow: "Unsere Flotte",
        fleetTitle: "Handverlesen. Gepflegt. Startklar.",
        fleetSub: "Filtern Sie nach Marke und Preis. Klicken Sie fuer Details oder buchen Sie direkt.",
        filterBrand: "Marke",
        filterSort: "Sortierung",
        filterPrice: "Max. Preis / Tag",
        all: "Alle",
        sortPriceAsc: "Preis aufsteigend",
        sortPriceDesc: "Preis absteigend",
        sortPowerDesc: "Leistung absteigend",
        details: "Details",
        book: "Buchen",
        perDay: "pro Tag",
        hp: "PS",
        kmh: "km/h",
        accel: "0-100",
        seats: "Sitze",
        from: "ab",
        noMatches: "Keine Fahrzeuge gefunden.",

        whyEyebrow: "Warum MC Cars",
        whyTitle: "Keine Kompromisse zwischen Sicherheit und Fahrspass.",
        whyInsurance: "Versicherungsschutz",
        whyInsuranceText: "Vollkasko mit klarem Selbstbehalt. Transparente Kosten auf jedem Kilometer.",
        whyFleet: "Premium Flotte",
        whyFleetText: "Handverlesene Performance-Modelle, professionell gewartet und sofort startklar.",
        whyDeposit: "Faire Kaution",
        whyDepositText: "Kein Ueberziehen. Transparente, faire Kaution ohne unnoetige Belastung.",

        reviewsEyebrow: "Kundenmeinungen",
        reviewsTitle: "Erlebnisse, die bleiben.",
        review: "Kundenmeinung",

        bookingEyebrow: "Jetzt buchen",
        bookingTitle: "Traumwagen unverbindlich anfragen.",
        fieldName: "Name",
        fieldEmail: "E-Mail",
        fieldPhone: "Telefon",
        fieldCar: "Fahrzeug",
        fieldFrom: "Von",
        fieldTo: "Bis",
        fieldMessage: "Nachricht",
        messagePlaceholder: "Wuensche, Uhrzeit, Anlass...",
        sendRequest: "Anfrage senden",
        invalidDates: "Bitte ein gueltiges Datum waehlen (Bis > Von).",
        weekendSaturdayOnly: "Im Wochenendmodus bitte einen Samstag waehlen.",
        bookingSuccess: "Danke! Wir melden uns in Kuerze per E-Mail.",
        bookingFailed: "Anfrage konnte nicht gesendet werden. Bitte erneut versuchen.",

        // BPF Wizard
        bpfTitle: "Jetzt buchen",
        bpfSubtitle: "Waehle dein Wunschfahrzeug, den Zeitraum und konfiguriere deine Buchung nach Wunsch.",
        stepVehicleTime: "Fahrzeug & Zeitraum",
        stepContact: "Kontaktdaten",
        stepVerification: "ID-Verifizierung",
        bpfRentalDuration: "Mietdauer",
        bpfVehicle: "Fahrzeug",
        bpfSelectVehicle: "Fahrzeug waehlen",
        bpfDuration: "Mietdauer",
        bpfPresetDay: "1 Tag",
        bpfPresetWeekend: "Wochenende",
        bpfPresetCustom: "Individuell",
        bpfPickDate: "Datum waehlen",
        bpfPickWeekend: "Wochenende waehlen (Samstag)",
        bpfStartDate: "Startdatum",
        bpfEndDate: "Enddatum",
        bpfSelectDate: "Datum waehlen",
        bpfNext: "Weiter",
        bpfBack: "Zurueck",
        bpfDailyRate: "Tagesmiete",
        bpfWeekendRate: "Wochenendmiete",
        bpfWeekendDef: "Wochenende: Samstag 9:00 – Sonntag 20:00",
        bpfMaxKm: "Max. km/Tag",
        bpfExtraKm: "Extra km",
        bpfPriceOverview: "Preisuebersicht",
        bpfSelectForPrice: "Waehle Fahrzeug und Datum fuer eine Preisuebersicht",
        bpfSubtotal: "Zwischensumme",
        bpfVat: "MwSt. (20%)",
        bpfTotal: "Gesamtbetrag",
        bpfDeposit: "Kaution",
        bpfIncludedKm: "Inkludierte Kilometer",
        bpfIdUpload: "Ausweis / Fuehrerschein",
        bpfIncomeUpload: "Lohnzettel / Gehaltsnachweis",
        bpfUploadHint: "PDF, JPG, PNG (max. 10 MB)",
        bpfClickUpload: "Klicken zum Hochladen",
        bpfIdNotice: "Ihre Dokumente werden vertraulich behandelt und dienen ausschliesslich der Identitaetsverifizierung.",
        bpfSubmit: "Anfrage absenden",
        bpfPerKm: "/km",
        bpfDays: "Tage",
        bpfWeekendDays: "Wochenendtage",
        bpfWeekdays: "Wochentage",

        // Weekend pricing on cards
        perWeekend: "Wochenende",
        weekendDef: "Sa 9:00 – So 20:00",

        footerTagline: "Sportwagenvermietung in Oesterreich. Standort: Steiermark (TBD).",
        footerLegal: "Rechtliches",
        footerContact: "Kontakt",
        footerNav: "Navigation",
        imprint: "Impressum",
        privacy: "Datenschutz",
        footerTerms: "Mietbedingungen",
        copyright: "Alle Rechte vorbehalten.",

        close: "Schliessen",
        editVehicle: "Fahrzeug bearbeiten",

        adminNavWebsite: "Website",
        adminChangePw: "Passwort aendern",
        adminLogout: "Logout",
        adminLeads: "Leads",
        adminCustomers: "Kunden",
        adminVehicles: "Fahrzeuge",
        adminNewVehicle: "Neues Fahrzeug",
        adminAllVehicles: "Alle Fahrzeuge",
        adminPhotoUpload: "Foto hochladen (JPG/PNG/WebP, max 50 MB)",
        adminPhotoUrl: "Foto-URL (wird automatisch gesetzt nach Upload)",
        adminBrand: "Marke",
        adminModel: "Modell",
        adminPower: "PS",
        adminSpeed: "Top-Speed km/h",
        adminAccel: "0-100",
        adminSeats: "Sitze",
        adminPrice: "Preis / Tag (€)",
        adminSort: "Reihenfolge",
        adminLocation: "Standort",
        adminDescDe: "Beschreibung (Deutsch)",
        adminDescEn: "Description (English)",
        adminActiveVisible: "Aktiv / auf Website sichtbar",
        adminSave: "Speichern",
        adminReset: "Neu",
        adminPhoto: "Foto",
        adminBrandTable: "Marke / Modell",
        adminPriceTable: "€ / Tag",
        adminActive: "Aktiv",
        adminDel: "Löschen",
        adminQualify: "Qualifizieren",
        adminReject: "Ablehnen",
        adminReopen: "Wieder öffnen",
        adminDetails: "Details",
        adminSetInactive: "Inaktiv setzen",
        adminSetActive: "Aktiv setzen",
        adminActiveLeads: "Aktive Leads",
        adminClosedLeads: "Abgeschlossen",
        adminSourceLead: "Quelle (Lead)",
        adminFirstContact: "Erster Kontakt",
        adminNameEmail: "Name / E-Mail",
        adminPhone: "Telefon",
        adminStatus: "Status",
        adminReceived: "Eingang",
        adminVehicleTab: "Fahrzeug",
        adminPeriod: "Zeitraum",
    },
    en: {
        navCars: "Fleet",
        navWhy: "Why us",
        navReviews: "Reviews",
        navBook: "Book",
        bookNow: "Book now",
        viewFleet: "View fleet",

        heroEyebrow: "MC Cars · Sports car rental",
        heroTitle: "Drive at the highest level.",
        heroLead: "Premium sports and luxury cars in Styria. Fair deposit, full transparency, ready to launch.",

        statDeposit: "Fair Deposit",
        statSupport: "Support",
        statCars: "Vehicles",

        fleetEyebrow: "Our Fleet",
        fleetTitle: "Hand-picked. Maintained. Ready.",
        fleetSub: "Filter by brand or price. Click for details or book directly.",
        filterBrand: "Brand",
        filterSort: "Sort",
        filterPrice: "Max price / day",
        all: "All",
        sortPriceAsc: "Price ascending",
        sortPriceDesc: "Price descending",
        sortPowerDesc: "Power descending",
        details: "Details",
        book: "Book",
        perDay: "per day",
        hp: "HP",
        kmh: "km/h",
        accel: "0-62",
        seats: "Seats",
        from: "from",
        noMatches: "No vehicles match the filters.",

        whyEyebrow: "Why MC Cars",
        whyTitle: "No compromises between safety and driving joy.",
        whyInsurance: "Insurance",
        whyInsuranceText: "Comprehensive cover with a clear deductible. Transparent costs on every kilometer.",
        whyFleet: "Premium fleet",
        whyFleetText: "Hand-picked performance models, professionally maintained and ready to go.",
        whyDeposit: "Fair Deposit",
        whyDepositText: "No overcharge. A transparent, fair deposit with no unnecessary burden.",

        reviewsEyebrow: "Testimonials",
        reviewsTitle: "Experiences that last.",
        review: "Review",

        bookingEyebrow: "Book now",
        bookingTitle: "Request your dream car without obligation.",
        fieldName: "Name",
        fieldEmail: "Email",
        fieldPhone: "Phone",
        fieldCar: "Vehicle",
        fieldFrom: "From",
        fieldTo: "To",
        fieldMessage: "Message",
        messagePlaceholder: "Wishes, timing, occasion...",
        sendRequest: "Send request",
        invalidDates: "Please pick valid dates (To > From).",
        weekendSaturdayOnly: "In weekend mode, please select a Saturday.",
        bookingSuccess: "Thank you! We'll get back to you shortly.",
        bookingFailed: "Request could not be sent. Please try again.",

        // BPF Wizard
        bpfTitle: "Book now",
        bpfSubtitle: "Choose your dream car, the time period, and configure your booking.",
        stepVehicleTime: "Vehicle & Period",
        stepContact: "Contact details",
        stepVerification: "ID Verification",
        bpfRentalDuration: "Rental duration",
        bpfVehicle: "Vehicle",
        bpfSelectVehicle: "Select vehicle",
        bpfDuration: "Rental duration",
        bpfPresetDay: "1 Day",
        bpfPresetWeekend: "Weekend",
        bpfPresetCustom: "Custom",
        bpfPickDate: "Pick date",
        bpfPickWeekend: "Pick weekend (Saturday)",
        bpfStartDate: "Start date",
        bpfEndDate: "End date",
        bpfSelectDate: "Select date",
        bpfNext: "Next",
        bpfBack: "Back",
        bpfDailyRate: "Daily rate",
        bpfWeekendRate: "Weekend rate",
        bpfWeekendDef: "Weekend: Saturday 9 AM – Sunday 8 PM",
        bpfMaxKm: "Max. km/day",
        bpfExtraKm: "Extra km",
        bpfPriceOverview: "Price overview",
        bpfSelectForPrice: "Select vehicle and date for a price overview",
        bpfSubtotal: "Subtotal",
        bpfVat: "VAT (20%)",
        bpfTotal: "Total",
        bpfDeposit: "Deposit",
        bpfIncludedKm: "Included kilometers",
        bpfIdUpload: "ID / Driving license",
        bpfIncomeUpload: "Pay slip / Income proof",
        bpfUploadHint: "PDF, JPG, PNG (max. 10 MB)",
        bpfClickUpload: "Click to upload",
        bpfIdNotice: "Your documents are treated confidentially and are used exclusively for identity verification.",
        bpfSubmit: "Submit request",
        bpfPerKm: "/km",
        bpfDays: "Days",
        bpfWeekendDays: "Weekend days",
        bpfWeekdays: "Weekdays",

        // Weekend pricing on cards
        perWeekend: "Weekend",
        weekendDef: "Sat 9 AM – Sun 8 PM",

        footerTagline: "Sports car rental in Austria. Location: Styria (TBD).",
        footerLegal: "Legal",
        footerContact: "Contact",
        footerNav: "Navigation",
        imprint: "Imprint",
        privacy: "Privacy",
        footerTerms: "Rental conditions",
        copyright: "All rights reserved.",

        close: "Close",
        editVehicle: "Edit vehicle",

        adminNavWebsite: "Website",
        adminChangePw: "Change password",
        adminLogout: "Logout",
        adminLeads: "Leads",
        adminCustomers: "Customers",
        adminVehicles: "Vehicles",
        adminNewVehicle: "New vehicle",
        adminAllVehicles: "All vehicles",
        adminPhotoUpload: "Upload photo (JPG/PNG/WebP, max 50 MB)",
        adminPhotoUrl: "Photo URL (auto-set after upload)",
        adminBrand: "Brand",
        adminModel: "Model",
        adminPower: "HP",
        adminSpeed: "Top speed km/h",
        adminAccel: "0-62",
        adminSeats: "Seats",
        adminPrice: "Price / day (€)",
        adminSort: "Sort order",
        adminLocation: "Location",
        adminDescDe: "Description (German)",
        adminDescEn: "Description (English)",
        adminActiveVisible: "Active / visible on website",
        adminSave: "Save",
        adminReset: "New",
        adminPhoto: "Photo",
        adminBrandTable: "Brand / Model",
        adminPriceTable: "€ / day",
        adminActive: "Active",
        adminDel: "Delete",
        adminQualify: "Qualify",
        adminReject: "Reject",
        adminReopen: "Reopen",
        adminDetails: "Details",
        adminSetInactive: "Set inactive",
        adminSetActive: "Set active",
        adminActiveLeads: "Active leads",
        adminClosedLeads: "Closed",
        adminSourceLead: "Source (Lead)",
        adminFirstContact: "First contact",
        adminNameEmail: "Name / Email",
        adminPhone: "Phone",
        adminStatus: "Status",
        adminReceived: "Received",
        adminVehicleTab: "Vehicle",
        adminPeriod: "Period",
    },
};

export const REVIEWS = {
    de: [
        { quote: "Top Service und perfekt vorbereitete Fahrzeuge. Unser Wochenendtrip war ein Highlight.", author: "Laura K." },
        { quote: "Die Buchung war klar und schnell. Der GT3 war in einem herausragenden Zustand.", author: "Martin P." },
        { quote: "Sehr professionelles Team und ehrliche Kommunikation zu allen Konditionen.", author: "Sina T." },
    ],
    en: [
        { quote: "Excellent service and flawlessly prepared cars. Our weekend trip was unforgettable.", author: "Laura K." },
        { quote: "Booking was clear and fast. The GT3 arrived in outstanding condition.", author: "Martin P." },
        { quote: "Very professional team and transparent communication on all terms.", author: "Sina T." },
    ],
};

export function getLang() {
    return localStorage.getItem("mccars.lang") || "de";
}

export function setLang(lang) {
    localStorage.setItem("mccars.lang", lang);
}

export function t(key) {
    const lang = getLang();
    return (translations[lang] && translations[lang][key]) || key;
}

export function applyI18n(root = document) {
    const lang = getLang();
    document.documentElement.lang = lang;

    root.querySelectorAll("[data-i18n]").forEach((el) => {
        const key = el.dataset.i18n;
        if (translations[lang][key]) el.textContent = translations[lang][key];
    });

    root.querySelectorAll("[data-i18n-placeholder]").forEach((el) => {
        const key = el.dataset.i18nPlaceholder;
        if (translations[lang][key]) el.placeholder = translations[lang][key];
    });
}
