CREATE TABLE IF NOT EXISTS settings (
    id SERIAL PRIMARY KEY,
    site_name VARCHAR(255),
    site_description TEXT,
    office_address TEXT,
    contact_email VARCHAR(255),
    contact_phone VARCHAR(50),
    instagram_url VARCHAR(255),
    twitter_url VARCHAR(255),
    linkedin_url VARCHAR(255),
    status_badge_text VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS services (
    id SERIAL PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    description TEXT,
    icon_name VARCHAR(100),
    display_order INTEGER DEFAULT 0,
    is_featured BOOLEAN DEFAULT false,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS projects (
    id SERIAL PRIMARY KEY,
    slug VARCHAR(255) UNIQUE NOT NULL,
    title VARCHAR(255) NOT NULL,
    subtitle TEXT,
    category VARCHAR(100),
    year VARCHAR(50),
    hero_image VARCHAR(255),
    client VARCHAR(255),
    role VARCHAR(255),
    location VARCHAR(255),
    narrative_title VARCHAR(255),
    narrative_desc TEXT,
    tech_stack JSONB DEFAULT '[]'::jsonb,
    gallery JSONB DEFAULT '[]'::jsonb,
    is_featured BOOLEAN DEFAULT false,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS leads (
    id SERIAL PRIMARY KEY,
    full_name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL,
    service_type VARCHAR(255),
    message TEXT,
    status VARCHAR(50) DEFAULT 'new',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Insert default settings row if not exists
INSERT INTO settings (id, site_name, site_description, office_address, contact_email, contact_phone, status_badge_text) 
VALUES (1, 'Muğla Dijital Medya Ajansı', 'Sosyal medya yönetimi, reklam yönetimi, SEO, web tasarım ve dijital pazarlama çözümleriyle markanızı öne çıkarıyoruz.', 'Muğla / Marmaris', 'hello@mugladijital.com', '+90 555 000 0000', '2025 Proje Başvuruları Açık')
ON CONFLICT (id) DO NOTHING;
