-- ============================================================================
-- CT NAILS — Seed Data (Phase 1)
-- Run AFTER database/schema.sql:
--   mysql -u <user> -p <database> < database/seed.sql
--
-- SECURITY — ADMIN LOGIN
--   Email:    admin@ctnails.lk
--   Password: admin123
--   The hash below is password_hash('admin123', PASSWORD_DEFAULT), generated
--   with PHP 8.3. CHANGE THIS PASSWORD immediately after first login
--   (Admin Profile in Phase 5) and delete this comment from production.
--   Never share the password in chat or commit a real password to git.
-- ============================================================================

SET NAMES utf8mb4;

-- ----------------------------------------------------------------------------
-- Membership tiers — Silver 5% / Gold 10% / Platinum 15% (per brief)
-- ----------------------------------------------------------------------------
INSERT INTO `memberships` (`tier`, `name`, `discount_percent`, `price`, `points_multiplier`, `benefits`) VALUES
('silver',   'Silver',   5.00, 0.00, 1.00, JSON_ARRAY('5% discount on all services', 'Birthday special offer', 'Loyalty points on every visit')),
('gold',     'Gold',    10.00, 0.00, 1.50, JSON_ARRAY('10% discount on all services', 'Birthday gift', 'Selected nail art at special prices', 'Loyalty rewards')),
('platinum', 'Platinum', 15.00, 0.00, 2.00, JSON_ARRAY('15% discount on all services', 'Birthday gift', 'Priority booking', 'Exclusive designs', 'Special rewards'))
ON DUPLICATE KEY UPDATE
  `name` = VALUES(`name`),
  `discount_percent` = VALUES(`discount_percent`),
  `benefits` = VALUES(`benefits`);

-- ----------------------------------------------------------------------------
-- Admin account (see security note at top of this file)
-- ----------------------------------------------------------------------------
INSERT INTO `admins` (`name`, `email`, `password_hash`, `role`, `status`) VALUES
('CT NAILS Admin', 'admin@ctnails.lk', '$2y$10$cgckqAOsWN4NmiDLeDScfurwhog7jXjpENKJ7XvdccWaNrT/gooly', 'super_admin', 'active')
ON DUPLICATE KEY UPDATE `name` = VALUES(`name`);

-- ----------------------------------------------------------------------------
-- Service categories — the 5 categories from the brief
-- ----------------------------------------------------------------------------
INSERT INTO `service_categories` (`name`, `slug`, `description`, `sort_order`, `is_active`) VALUES
('Gel Nails',          'gel-nails',          'Long-lasting, glossy gel manicures and extensions.', 1, 1),
('Acrylic Nails',      'acrylic-nails',      'Strong, sculpted acrylic sets in any length and shape.', 2, 1),
('Nail Art',           'nail-art',           'Hand-painted art, chrome, ombre, French and 3D designs.', 3, 1),
('Press-on Nails',     'press-on-nails',     'Beautiful ready-to-wear press-on sets, applied in salon.', 4, 1),
('Custom Nail Designs','custom-nail-designs','Your design, our artists — fully custom one-off sets.', 5, 1)
ON DUPLICATE KEY UPDATE `description` = VALUES(`description`);

-- ----------------------------------------------------------------------------
-- Services — 12 realistic services with LKR prices and durations
-- Category IDs follow the insert order above: 1=Gel, 2=Acrylic, 3=Nail Art,
-- 4=Press-on, 5=Custom. (IDs are stable only on a fresh import.)
-- ----------------------------------------------------------------------------
INSERT INTO `services` (`category_id`, `name`, `slug`, `description`, `price`, `duration_minutes`, `is_featured`, `is_active`, `sort_order`) VALUES
(1, 'Classic Gel Manicure', 'classic-gel-manicure', 'Gel polish manicure with cuticle care and a flawless glossy finish.', 3500.00, 60, 1, 1, 1),
(1, 'Gel Extensions', 'gel-extensions', 'Natural-looking gel extensions in your preferred length and shape.', 6500.00, 120, 1, 1, 2),
(1, 'Gel Pedicure', 'gel-pedicure', 'Relaxing gel pedicure with soak, scrub and polish.', 4000.00, 75, 0, 1, 3),
(2, 'Full Acrylic Set', 'full-acrylic-set', 'Full acrylic set with shaping, filing and polish of your choice.', 7000.00, 120, 1, 1, 1),
(2, 'Acrylic Refill', 'acrylic-refill', 'Acrylic refill and rebalance to keep your set looking new.', 4500.00, 90, 0, 1, 2),
(3, 'Signature Nail Art', 'signature-nail-art', 'Hand-painted nail art — florals, minimal, chrome or ombre, per set.', 2500.00, 60, 1, 1, 1),
(3, 'French Manicure', 'french-manicure', 'Classic elegant French tips, gel or regular polish.', 3800.00, 60, 0, 1, 2),
(3, '3D Nail Art', '3d-nail-art', 'Statement 3D charms, stones and sculpted art.', 5000.00, 90, 0, 1, 3),
(4, 'Press-on Application', 'press-on-application', 'Professional application of a press-on set with prep and finishing.', 2000.00, 45, 0, 1, 1),
(4, 'Custom Press-on Set', 'custom-press-on-set', 'A made-to-measure press-on set, designed for you and fitted in salon.', 5500.00, 90, 1, 1, 2),
(5, 'Bridal Nail Design', 'bridal-nail-design', 'Luxury bridal set with trial, art and finishing — your day, your nails.', 12000.00, 150, 1, 1, 1),
(5, 'Custom Design Consultation', 'custom-design-consultation', 'One-to-one design consultation and a fully custom set.', 8000.00, 120, 0, 1, 2)
ON DUPLICATE KEY UPDATE
  `price` = VALUES(`price`),
  `duration_minutes` = VALUES(`duration_minutes`),
  `description` = VALUES(`description`);

-- ----------------------------------------------------------------------------
-- Staff — 3 nail artists
-- ----------------------------------------------------------------------------
INSERT INTO `staff` (`name`, `email`, `phone`, `position`, `bio`, `specialties`, `status`, `sort_order`) VALUES
('Chamari T.', 'chamari@ctnails.lk', '+94 77 000 0001', 'Founder & Senior Nail Artist', 'Founder of CT NAILS with 8+ years of experience in gel and bridal nail design.', 'Gel, Bridal, Nail Art', 'active', 1),
('Nethmi P.', 'nethmi@ctnails.lk', '+94 77 000 0002', 'Nail Artist', 'Specialist in acrylic sets and detailed hand-painted nail art.', 'Acrylic, Nail Art', 'active', 2),
('Sanduni K.', 'sanduni@ctnails.lk', '+94 77 000 0003', 'Nail Technician', 'Expert in press-on sets, pedicures and natural nail care.', 'Press-on, Pedicure, Gel', 'active', 3)
ON DUPLICATE KEY UPDATE `position` = VALUES(`position`);

-- ----------------------------------------------------------------------------
-- Salon-wide opening hours — Mon-Sat 09:00-19:00, Sunday closed
-- availability.day_of_week: 0=Sunday .. 6=Saturday. staff_id NULL = salon-wide.
-- ----------------------------------------------------------------------------
-- NOTE: staff_id is NULL here, and MySQL treats NULLs as distinct in a
-- UNIQUE key, so ON DUPLICATE KEY UPDATE would NOT catch a re-run.
-- Delete the salon-wide rows first so re-running this seed is safe.
DELETE FROM `availability` WHERE `staff_id` IS NULL;
INSERT INTO `availability` (`staff_id`, `day_of_week`, `start_time`, `end_time`, `is_available`) VALUES
(NULL, 0, '09:00:00', '19:00:00', 0), -- Sunday: closed
(NULL, 1, '09:00:00', '19:00:00', 1), -- Monday
(NULL, 2, '09:00:00', '19:00:00', 1), -- Tuesday
(NULL, 3, '09:00:00', '19:00:00', 1), -- Wednesday
(NULL, 4, '09:00:00', '19:00:00', 1), -- Thursday
(NULL, 5, '09:00:00', '19:00:00', 1), -- Friday
(NULL, 6, '09:00:00', '19:00:00', 1); -- Saturday

-- ----------------------------------------------------------------------------
-- Settings — salon identity, contact and hours (edit in Admin, Phase 5)
-- Fill in the real phone / WhatsApp / Instagram / address before launch.
-- ----------------------------------------------------------------------------
INSERT INTO `settings` (`setting_key`, `setting_value`, `description`) VALUES
('salon_name',       'CT NAILS', 'Salon / brand name'),
('salon_slogan',     'Look Good • Feel Beautiful • Be You', 'Brand slogan'),
('salon_phone',      '+94 77 000 0000', 'Salon phone — UPDATE with the real number'),
('salon_whatsapp',   '+94 77 000 0000', 'WhatsApp number — UPDATE with the real number'),
('salon_instagram',  'https://instagram.com/ctnails', 'Instagram profile URL — UPDATE with the real handle'),
('salon_email',      'hello@ctnails.lk', 'Salon contact email — UPDATE with the real address'),
('salon_address',    'Colombo, Sri Lanka', 'Studio address — UPDATE with the real address'),
('salon_map_url',    '', 'Google Maps embed URL — add in Admin settings'),
('opening_hours',    'Monday – Saturday: 9.00 AM – 7.00 PM | Sunday: Closed', 'Opening hours text shown on the website'),
('currency',         'LKR', 'Currency code'),
('booking_deposit_percent', '20', 'Deposit percentage of the booking total, if deposits are enabled'),
('points_per_rupee', '1', 'Loyalty points earned per LKR 100 spent (tune in Phase 7)')
ON DUPLICATE KEY UPDATE `setting_value` = VALUES(`setting_value`);

-- ----------------------------------------------------------------------------
-- Gallery categories — placeholder rows so the gallery has structure.
-- Real images/videos are uploaded by Admin in Phase 5; no fake images here.
-- ----------------------------------------------------------------------------
-- Gallery has no UNIQUE key (titles may repeat), so delete the placeholder
-- row first to keep re-runs of this seed safe.
DELETE FROM `gallery` WHERE `title` = 'Welcome to CT NAILS' AND `is_active` = 0;
INSERT INTO `gallery` (`title`, `description`, `media_type`, `file_path`, `category`, `is_featured`, `sort_order`, `is_active`) VALUES
('Welcome to CT NAILS', 'Gallery placeholder — replace with a real studio photo in Admin > Gallery.', 'image', 'uploads/gallery/placeholder.jpg', 'New Designs', 0, 1, 0);

-- ----------------------------------------------------------------------------
-- Sample coupon (inactive until Admin enables it)
-- ----------------------------------------------------------------------------
INSERT INTO `coupons` (`code`, `discount_type`, `discount_value`, `min_amount`, `is_active`) VALUES
('WELCOME10', 'percent', 10.00, 3000.00, 0)
ON DUPLICATE KEY UPDATE `discount_value` = VALUES(`discount_value`);

-- ============================================================================
-- Seed complete. Verify with:
--   SELECT COUNT(*) FROM services;          -- expect 12
--   SELECT COUNT(*) FROM service_categories; -- expect 5
--   SELECT COUNT(*) FROM memberships;        -- expect 3
--   SELECT COUNT(*) FROM staff;              -- expect 3
-- ============================================================================
