// Глобальные интерфейсы для PocketBase записей

// Интерфейс для базовой записи из PocketBase
export interface BaseRecord {
    id: string;
    collectionId: string;
    collectionName: string;
    created: string;
    updated: string;
}

// Интерфейсы для автомобилей
export interface Car extends BaseRecord {
    src: string; // image URL from PocketBase
    alt: string; // alt_text from PocketBase
    make: string; // brand from PocketBase
    model: string;
    year: number;
    price: string;
    seats: string[]; // seats_count from PocketBase (преобразуется в массив)
    doors: string; // doors_count from PocketBase
    trunk: string; // trunk_capacity from PocketBase
    horsepower: string;
    description: string;
    order: number;
    is_active: boolean;
    max_passengers: number;
}

// Интерфейсы для пользователей
export interface User extends BaseRecord {
    username: string;
    email: string;
    name: string;
    avatar?: string;
    phone?: string;
    is_verified: boolean;
    emailVisibility?: boolean;
}

// Интерфейсы для бронирований
export interface Booking extends BaseRecord {
    customer_name: string;
    customer_email: string;
    customer_phone: string;
    pickup_location: string;
    dropoff_location: string;
    pickup_date: string;
    pickup_time: string;
    dropoff_date?: string;
    dropoff_time?: string;
    passengers: number;
    vehicle_id?: string;
    vehicle_name?: string;
    message?: string;
    status: 'pending' | 'confirmed' | 'cancelled' | 'completed';
    total_price?: string;
    created: string;
}

export interface SliderCar extends BaseRecord {
    brand: string;
    model: string;
    year: number;
    horsepower: string;
    price: string;
    seats_count: string;
    doors_count: string;
    trunk_capacity: string;
    description: string;
    alt_text: string;
    order: number;
    is_active: boolean;
    max_passengers: number;
    image: string;
}

export interface SliderCarsResponse {
    page: number;
    perPage: number;
    totalItems: number;
    totalPages: number;
    items: SliderCar[];
}

// Интерфейсы для FAQ
export interface FaqItem extends BaseRecord {
    question: string;
    answer: string;
    show_on_homepage: boolean;
    order: number;
    is_active: boolean;
    category: string;
}

export interface FaqHomepageProps {
    faqItems: FaqItem[];
}

export interface FaqProps {
    faqItems: FaqItem[];
}

// Интерфейсы для компонента CarsSlider
export interface CarsSliderProps {
    cars: Car[];
}

export interface CarsSliderText {
    mainTitle: string;
    subtitle: string;
    previousButtonAlt: string;
    nextButtonAlt: string;
    selectButton: string;
    goToSlide: string;
}

// Интерфейсы для Hero секции
export interface HeroData extends BaseRecord {
    title: string;
    subtitle: string;
    image: string;
    alt_text: string;
}

// Интерфейсы для услуг/цен
export interface PriceService extends BaseRecord {
    title: string;
    description: string;
    icon: string;
    features: string[];
    order: number;
    is_active: boolean;
}

export interface ServicesSectionProps {
    services: PriceService[];
    title?: string;
}

// Интерфейсы для цены/слайдера
export interface PriceProps {
    cars: Car[];
    title?: string;
    subtitle?: string;
}

// Интерфейсы для CTA
export interface CtaSectionProps {
    title?: string;
    subtitle?: string;
    buttonText?: string;
    href?: string;
}

// Интерфейсы для отзывов
export interface Review extends BaseRecord {
    title: string;
    content: string;
    rating: number;
    author: string;
    avatarUrl?: string;
    createdAt: string;
}

// Интерфейсы для постов блога
export interface BlogPost extends BaseRecord {
    title: string;
    slug: string;
    excerpt: string;
    content: string;
    content_html?: string;
    image: string;
    alt_text?: string;
    author: string;
    author_name?: string;
    author_avatar?: string;
    published: boolean;
    publish_date: string;
    views: number;
    tags: string[];
    category?: string;
    featured: boolean;
}

export type Post = BlogPost;

// Интерфейсы для комментариев блога
export interface Comment extends BaseRecord {
    post_id: string;
    author_name: string;
    author_email: string;
    author_avatar?: string;
    content: string;
    parent_id?: string;
    reply_to?: string;
    is_verified: boolean;
    is_spam: boolean;
    is_published: boolean;
    created: string;
}

// Интерфейс для отзыва в LatestReviews
export interface LatestReview {
    id: string;
    author: string;
    initials: string;
    rating: number;
    title: string;
    content: string;
    avatarUrl?: string;
    created: string;
}

// Интерфейсы для страниц
export interface PageData extends BaseRecord {
    slug: string;
    title: string;
    meta_description: string;
    canonical_url?: string;
    services_title?: string;
    hero_title?: string;
    hero_subtitle?: string;
    cta_title?: string;
    cta_subtitle?: string;
    cta_button_text?: string;
    cta_href?: string;
}

// Интерфейсы для настроек сайта
export interface SiteSettings extends BaseRecord {
    site_name: string;
    site_url: string;
}

// Интерфейсы для компонента HowItWorks
export interface Step {
    icon: string;
    title: string;
    description: string;
}

export interface HowItWorksContent {
    title: string;
    subtitle: string;
    steps: Step[];
}

// Интерфейсы для HeroContent
export interface HeroContent {
    title: string;
    description: string;
    bookByEmail: string;
    contactWhatsApp: string;
    emailModalTitle: string;
    whatsappModalTitle: string;
    whatsappDirectMessage: string;

    // Заголовки секций формы
    pickupDetailsTitle: string;
    dropoffDetailsTitle: string;

    // Поля формы
    pickup: string;
    pickupPlaceholder: string;
    dropoff: string;
    dropoffPlaceholder: string;
    date: string;
    time: string;
    passengers: string;
    phone: string;
    name: string;
    message: string;
    messagePlaceholder?: string;
    additionalInfo: string;
    additionalInfoPlaceholder: string;
    multipleVans: string;
    checkAvailability: string;
    sendMessage: string;
    applyDiscountLabel: string;

    // Строки для валидации
    fieldRequired: string;
    dateMustBeFuture: string;
    dropoffDateBeforePickup: string;
    invalidPhone: string;
    bookingSubmitted: string;
    selectOption: string;
    addressCannotBeOnlyNumbers: string;
    addressMustContainLetters: string;
    invalidName: string;

    // Общая ошибка отправки
    somethingWentWrong: string;

    // Сообщение об успехе для WhatsApp
    messageSentSuccess: string;

    // Новое поле — ошибка отправки (для валидации длины сообщения)
    messageTooLong: string;

    // Статистика
    stats: readonly { value: string; label: string }[];
}

// Интерфейсы для компонента Slider
export interface SliderSlide extends BaseRecord {
    title: string;
    description: string;
    image: string;
    order: number;
    is_active: boolean;
}

export interface SliderProps {
    slides: SliderSlide[];
}

// Интерфейсы для компонента FeaturesSection
export interface PremiumFeature extends BaseRecord {
    title: string;
    description: string;
    order: number;
    is_active: boolean;
    icon_path?: string;
}

// Интерфейсы для компонента FleetShowcase
export interface PremiumVehicle extends BaseRecord {
    name: string;
    tagline: string;
    description: string;
    capacity: string;
    image: string;
    features: string[];
    brand: string;
    model: string;
    year: number | string;
    price: string;
    seats_count: string;
    doors_count?: number;
    horsepower?: string;
    trunk_capacity?: string;
}

// Интерфейсы для компонента VehicleCard
export interface VehicleCardProps {
    vehicle: {
        id: string;
        name: string;
        tagline: string;
        description: string;
        capacity: string;
        imageUrl: string;
        features: string[];
        brand: string;
        model: string;
        year: number | string;
        price: string;
        seats: string[];
        doors_count?: number;
        horsepower?: string;
        trunk_capacity?: string;
    };
}

// Интерфейсы для компонентов VIP-услуг
export interface VipService extends BaseRecord {
    title: string;
    description: string;
    icon: string;
    features: string[];
    order: number;
    is_active: boolean;
}

export interface VipHeroSection extends BaseRecord {
    title: string;
    subtitle: string;
    description: string;
    image: string;
    order: number;
    is_active: boolean;
}

export interface VipCoreFeature extends BaseRecord {
    feature_id: string;
    icon: string;
    title: string;
    description: string;
    image: string;
    order: number;
    is_active: boolean;
}

export interface CoreFeatureDisplay {
    id: string;
    icon: string;
    title: string;
    description: string;
    imageUrl: string;
}

export interface ServiceCardProps {
    service: {
        title: string;
        description: string;
        icon: string;
        features: string[];
    };
}

export interface PersonalizedCtaSectionProps {
    sectionData?: {
        title: string;
        description: string;
        buttonText: string;
        buttonLink: string;
        image: string;
        collectionId: string;
        id: string;
    };
    href?: string;
    size?: 'sm' | 'md' | 'lg';
    className?: string;
}

// Интерфейсы для блоков страницы "О нас"
export interface ImageData {
    url: string;
    alt: string;
}

export interface ValueItem {
    id: string;
    icon: string;
    title: string;
    description: string;
}

export interface FleetVehicle {
    id: string;
    image: ImageData;
    title: string;
    capacity: string;
    models: string;
}

export interface ButtonData {
    text: string;
    link: string;
}

export interface BaseBlock {
    blockType: string;
}

export interface HeroBlock extends BaseBlock {
    blockType: 'hero';
    title: string;
    subtitle: string;
}

export interface StoryBlock extends BaseBlock {
    blockType: 'story';
    title: string;
    content: string;
    image: ImageData;
}

export interface ValuesBlock extends BaseBlock {
    blockType: 'values';
    title: string;
    values: ValueItem[];
}

export interface FleetBlock extends BaseBlock {
    blockType: 'fleet';
    title: string;
    vehicles: FleetVehicle[];
}

export interface CtaBlock extends BaseBlock {
    blockType: 'cta';
    title: string;
    subtitle: string;
    button: ButtonData;
}

export type AboutPageBlock = HeroBlock | StoryBlock | ValuesBlock | FleetBlock | CtaBlock;

// Типы для AuthService
export type AuthClient = import('pocketbase').default;

// Интерфейсы для AuthService
export interface AuthService {
    createClient(): AuthClient;
    createClientFromRequest(request: Request): AuthClient;
    isAuthenticated(pb: AuthClient): Promise<boolean>;
    validateAndRefreshSession(pb: AuthClient): Promise<any>;
    createAuthHeaders(pb: AuthClient): Record<string, string>;
}