-- ============================================
-- DeeCraft Interior - Database Schema & Seed
-- ============================================



-- ----------------------------
-- Table: admins
-- ----------------------------
CREATE TABLE IF NOT EXISTS `admins` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `username` VARCHAR(100) NOT NULL UNIQUE,
  `email` VARCHAR(150) NOT NULL UNIQUE,
  `password` VARCHAR(255) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Default admin: admin / Admin@1234
INSERT INTO `admins` (`username`, `email`, `password`) VALUES
('admin', 'admin@deecraftinterio.com', '$2y$10$38Wul.d3Zdle3zWZ2jmA0Og.HjEgGrXKmTyr48M6oYR8xKEzeUCl.')
ON DUPLICATE KEY UPDATE
  `email` = VALUES(`email`),
  `password` = VALUES(`password`);

-- ----------------------------
-- Table: categories
-- ----------------------------
CREATE TABLE IF NOT EXISTS `categories` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100) NOT NULL,
  `slug` VARCHAR(120) NOT NULL UNIQUE,
  `description` TEXT,
  `image` VARCHAR(255),
  `sort_order` INT DEFAULT 0,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT IGNORE INTO `categories` (`name`, `slug`, `description`, `sort_order`) VALUES
('Living Room', 'living-room', 'Elegant sofas, armchairs and coffee tables for sophisticated living spaces.', 1),
('Bedroom', 'bedroom', 'Luxury beds, wardrobes and dressers crafted for restful retreat.', 2),
('Dining Room', 'dining-room', 'Statement dining tables and chairs for refined entertaining.', 3),
('Office', 'office', 'Executive desks and ergonomic seating for productive spaces.', 4),
('Outdoor', 'outdoor', 'Premium outdoor furniture built for beauty and durability.', 5),
('Lighting', 'lighting', 'Artisan lighting fixtures that define ambiance.', 6);

-- ----------------------------
-- Table: products
-- ----------------------------
CREATE TABLE IF NOT EXISTS `products` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `category_id` INT UNSIGNED NOT NULL,
  `name` VARCHAR(200) NOT NULL,
  `slug` VARCHAR(220) NOT NULL UNIQUE,
  `short_description` TEXT,
  `description` TEXT,
  `material` VARCHAR(255),
  `dimensions` VARCHAR(255),
  `is_featured` TINYINT(1) DEFAULT 0,
  `is_hot` TINYINT(1) DEFAULT 0,
  `status` ENUM('active','inactive') DEFAULT 'active',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT IGNORE INTO `products` (`category_id`, `name`, `slug`, `short_description`, `description`, `material`, `dimensions`, `is_featured`, `is_hot`) VALUES
(1, 'Maison Velvet Sofa', 'maison-velvet-sofa', 'A three-seater masterpiece upholstered in premium velvet with solid walnut legs.', 'The Maison Velvet Sofa redefines contemporary luxury. Crafted with solid walnut legs and premium grade velvet upholstery, this sofa combines exceptional comfort with timeless elegance. Each piece is handcrafted by skilled artisans ensuring unmatched quality and durability for generations to come.', 'Premium Velvet, Solid Walnut Wood, High-Density Foam', 'W: 220cm × D: 95cm × H: 85cm', 1, 1),
(1, 'Empire Chesterfield Armchair', 'empire-chesterfield-armchair', 'A classic button-tufted armchair with brushed brass legs and genuine leather.', 'The Empire Chesterfield Armchair embodies old-world craftsmanship with modern refinement. Button-tufted genuine leather, brushed brass accent legs and hand-rolled arms make this a centrepiece for any distinguished living space.', 'Genuine Italian Leather, Brushed Brass, Kiln-Dried Hardwood', 'W: 88cm × D: 82cm × H: 92cm', 1, 0),
(1, 'Sonata Coffee Table', 'sonata-coffee-table', 'A sculptural marble-top coffee table with brushed gold base.', 'The Sonata Coffee Table features a hand-finished Carrara marble surface supported by a precision-engineered brushed gold steel base. It blends artistry and function into a single breathtaking piece.', 'Carrara Marble, Brushed Gold Steel', 'W: 120cm × D: 65cm × H: 42cm', 0, 1),
(2, 'Palazzo King Bed', 'palazzo-king-bed', 'An upholstered king bed with a grand headboard and solid oak frame.', 'The Palazzo King Bed commands attention with its floor-to-ceiling upholstered headboard and robust solid oak frame. Built for regal comfort, this bed transforms any bedroom into a sanctuary of luxury.', 'Premium Linen, Solid Oak, Memory Foam Support', 'W: 200cm × D: 230cm × H: 155cm', 1, 1),
(2, 'Lumiere Bedside Table', 'lumiere-bedside-table', 'A minimalist bedside table with brass hardware and lacquered finish.', 'The Lumiere Bedside Table offers clean lines and sophisticated functionality. Featuring soft-close drawers with brushed brass hardware, it pairs beautifully with any bed in our collection.', 'Lacquered MDF, Brushed Brass Hardware, Tempered Glass', 'W: 55cm × D: 42cm × H: 58cm', 0, 0),
(3, 'Vesper Dining Table', 'vesper-dining-table', 'A 6-seater smoked oak dining table with waterfall edge design.', 'The Vesper Dining Table is a statement piece for the modern dining room. Cut from solid smoked oak, its distinctive waterfall edge celebrates the natural beauty of the material while delivering structural integrity.', 'Solid Smoked Oak, Matte Black Steel Base', 'W: 200cm × D: 100cm × H: 76cm', 1, 1),
(3, 'Aria Dining Chair', 'aria-dining-chair', 'A sculpted boucle dining chair with tapered solid oak legs.', 'The Aria Dining Chair blends comfort and style with its contoured boucle seat and tapered solid oak legs. Sold individually or as a set, it complements the Vesper Dining Table perfectly.', 'Boucle Fabric, Solid Oak', 'W: 52cm × D: 58cm × H: 88cm', 0, 1),
(4, 'Atlas Executive Desk', 'atlas-executive-desk', 'A wide executive desk in walnut veneer with integrated cable management.', 'The Atlas Executive Desk offers commanding workspace aesthetics. The rich walnut veneer surface is complemented by discreet cable management channels and solid steel legs for a clean, focused environment.', 'American Walnut Veneer, Powder-Coated Steel', 'W: 180cm × D: 80cm × H: 76cm', 1, 0),
(6, 'Soleil Pendant Light', 'soleil-pendant-light', 'A large-format brass pendant light with hand-blown smoked glass shade.', 'The Soleil Pendant Light is a sculptural lighting statement. Hand-blown smoked glass diffuses warm light beautifully while the solid brass housing adds an artisanal quality rarely seen in contemporary lighting.', 'Solid Brass, Hand-Blown Smoked Glass', 'Diameter: 45cm × H: 38cm (adjustable cable)', 0, 1),
(5, 'Riviera Outdoor Lounge Set', 'riviera-outdoor-lounge-set', 'A three-piece powder-coated aluminum outdoor lounge set with sunbrella cushions.', 'The Riviera Outdoor Lounge Set brings resort-style living to your terrace or garden. Made with powder-coated aluminum frames and Sunbrella fabric cushions, it is built for beauty and all-weather durability.', 'Powder-Coated Aluminium, Sunbrella Fabric', 'Sofa: W: 200cm, Chairs: W: 80cm each', 1, 0);

-- ----------------------------
-- Table: product_images
-- ----------------------------
CREATE TABLE IF NOT EXISTS `product_images` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `product_id` INT UNSIGNED NOT NULL,
  `image_path` VARCHAR(255) NOT NULL,
  `is_primary` TINYINT(1) DEFAULT 0,
  `sort_order` INT DEFAULT 0,
  FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `product_images` (`product_id`, `image_path`, `is_primary`, `sort_order`) VALUES
(1, 'https://images.unsplash.com/photo-1555041469-a586c61ea9bc?auto=format&fit=crop&w=900&q=80', 1, 1),
(2, 'https://images.unsplash.com/photo-1598300042247-d088f8ab3a91?auto=format&fit=crop&w=900&q=80', 1, 1),
(3, 'https://images.unsplash.com/photo-1532372320572-cda25653a26d?auto=format&fit=crop&w=900&q=80', 1, 1),
(4, 'https://images.unsplash.com/photo-1616594039964-ae9021a400a0?auto=format&fit=crop&w=900&q=80', 1, 1),
(5, 'https://images.unsplash.com/photo-1616486029423-aaa4789e8c9a?auto=format&fit=crop&w=900&q=80', 1, 1),
(6, 'https://images.unsplash.com/photo-1617104678098-de229db51175?auto=format&fit=crop&w=900&q=80', 1, 1),
(7, 'https://images.unsplash.com/photo-1567538096630-e0c55bd6374c?auto=format&fit=crop&w=900&q=80', 1, 1),
(8, 'https://images.unsplash.com/photo-1593476550610-87baa860004a?auto=format&fit=crop&w=900&q=80', 1, 1),
(9, 'https://images.unsplash.com/photo-1513506003901-1e6a229e2d15?auto=format&fit=crop&w=900&q=80', 1, 1),
(10, 'https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?auto=format&fit=crop&w=900&q=80', 1, 1);

-- ----------------------------
-- Table: gallery
-- ----------------------------
CREATE TABLE IF NOT EXISTS `gallery` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(200),
  `description` TEXT,
  `image_path` VARCHAR(255) NOT NULL,
  `category` VARCHAR(100) DEFAULT 'Interior',
  `sort_order` INT DEFAULT 0,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `gallery` (`title`, `description`, `image_path`, `category`, `sort_order`) VALUES
('Minimalist Living Room', 'A serene, minimalist living space designed for modern families.', 'https://images.unsplash.com/photo-1618221195710-dd6b41faaea6?auto=format&fit=crop&w=900&q=80', 'Living Room', 1),
('Golden Hour Bedroom', 'Warm tones and luxurious textures in a master bedroom retreat.', 'https://images.unsplash.com/photo-1616594039964-ae9021a400a0?auto=format&fit=crop&w=900&q=80', 'Bedroom', 2),
('Executive Home Office', 'A refined home office setup for the discerning professional.', 'https://images.unsplash.com/photo-1593476550610-87baa860004a?auto=format&fit=crop&w=900&q=80', 'Office', 3),
('Marble Dining Experience', 'An opulent dining space centered around the Vesper Table.', 'https://images.unsplash.com/photo-1617104678098-de229db51175?auto=format&fit=crop&w=900&q=80', 'Dining Room', 4),
('Open Plan Living', 'A seamlessly connected living and dining area with natural light.', 'https://images.unsplash.com/photo-1618220179428-22790b461013?auto=format&fit=crop&w=900&q=80', 'Living Room', 5),
('Terrace Garden Retreat', 'Outdoor living redefined with the Riviera collection.', 'https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?auto=format&fit=crop&w=900&q=80', 'Outdoor', 6);

-- ----------------------------
-- Table: bookings
-- ----------------------------
CREATE TABLE IF NOT EXISTS `bookings` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `product_id` INT UNSIGNED,
  `product_name` VARCHAR(200),
  `customer_name` VARCHAR(200),
  `customer_phone` VARCHAR(30),
  `customer_message` TEXT,
  `status` ENUM('pending','contacted','completed','cancelled') DEFAULT 'pending',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table: settings
-- ----------------------------
CREATE TABLE IF NOT EXISTS `settings` (
  `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `setting_key` VARCHAR(100) NOT NULL UNIQUE,
  `setting_value` TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `settings` (`setting_key`, `setting_value`) VALUES
('site_name', 'DeeCraft Interior'),
('site_tagline', 'Luxury Furniture, Crafted for Life'),
('site_description', 'Premium luxury furniture showroom. Handcrafted pieces for discerning interiors.'),
('whatsapp_number', '+2348012345678'),
('whatsapp_message', 'Hello, I am interested in booking a product from DeeCraft Interior.'),
('email', 'hello@deecraftinterio.com'),
('phone', '+234 801 234 5678'),
('address', '15 Marina Boulevard, Victoria Island, Lagos, Nigeria'),
('instagram', 'https://instagram.com/deecraftinterio'),
('facebook', 'https://facebook.com/deecraftinterio'),
('hero_title_1', 'Crafted for the'),
('hero_subtitle_1', 'Modern Connoisseur'),
('hero_text_1', 'Discover furniture that speaks the language of luxury and refinement.'),
('hero_title_2', 'Where Elegance'),
('hero_subtitle_2', 'Meets Function'),
('hero_text_2', 'Each piece in our collection is a testament to artisan craftsmanship.'),
('hero_title_3', 'Define Your'),
('hero_subtitle_3', 'Living Space'),
('hero_text_3', 'Transform your interiors with timeless furniture from DeeCraft Interior.')
ON DUPLICATE KEY UPDATE `setting_value` = VALUES(`setting_value`);
