-- ==========================================
-- SecureShieldX Database Schema
-- ==========================================

CREATE DATABASE IF NOT EXISTS secureshieldx CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE secureshieldx;

SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS products;
DROP TABLE IF EXISTS categories;
SET FOREIGN_KEY_CHECKS = 1;

-- Categories Table
CREATE TABLE categories (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    slug VARCHAR(100) NOT NULL UNIQUE,
    description TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Products Table
CREATE TABLE products (
    id INT AUTO_INCREMENT PRIMARY KEY,
    sku VARCHAR(50) NOT NULL UNIQUE,
    name VARCHAR(255) NOT NULL,
    slug VARCHAR(255) NOT NULL UNIQUE,
    category_id INT NOT NULL,
    price DECIMAL(10,2) NOT NULL,
    original_price DECIMAL(10,2) DEFAULT NULL,
    devices VARCHAR(50) DEFAULT '1',
    years VARCHAR(50) DEFAULT '1 Year',
    short_desc TEXT,
    content LONGTEXT,
    image VARCHAR(255) DEFAULT NULL,
    is_featured TINYINT(1) DEFAULT 0,
    status TINYINT(1) DEFAULT 1,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE
);

-- ==========================================
-- Seed Categories
-- ==========================================
INSERT INTO categories (id, name, slug, description) VALUES
(1, 'Internet Security', 'internet-security', 'Advanced internet security solutions to protect your online activities'),
(2, 'Antivirus', 'antivirus', 'Powerful antivirus software to detect and remove malware threats'),
(3, 'Complete Protection', 'complete-protection', 'All-in-one complete digital protection for all your devices'),
(4, 'Cyber Security', 'cyber-security', 'Enterprise-grade cybersecurity solutions for advanced threat protection');

-- ==========================================
-- Seed Products (Single Product from Design)
-- ==========================================
INSERT INTO products (id, sku, name, slug, category_id, price, original_price, devices, years, short_desc, content, image, is_featured, status) VALUES
(1, 'SSX-IS-MAX', 'SecureShieldX Internet Security Max', 'secureshieldx-internet-security-max', 1, 69.99, 79.00, '5 Devices', '2 Years',
'Parental controls + anti-phishing. Complete internet security suite for 5 devices, 2 years continuous protection.',
'<h3>SecureShieldX Internet Security Max — Maximum Protection for Complete Online Security</h3>
<h4>Maximum Protection For Your Digital World</h4>
<p>SecureShieldX Internet Security Max is a premium internet security solution designed to deliver maximum protection against modern online threats. Built for families, professionals, remote workers, and small businesses, this advanced security package protects up to 5 devices for 2 years, providing long-term digital safety and peace of mind.</p>

<p>As cyber threats continue to evolve, internet users face increasing risks from malware, ransomware, phishing attacks, identity theft, and online fraud. SecureShieldX Internet Security Max combines advanced security technologies, intelligent threat detection, and privacy protection to keep your devices, personal information, and online activities secure.</p>

<p>Whether you work remotely, shop online, stream entertainment, or manage important financial transactions, SecureShieldX Internet Security Max provides comprehensive protection for your connected lifestyle.</p>

<h4>Protect Up To 5 Devices</h4>
<p>SecureShieldX Internet Security Max offers protection for up to five devices under a single license. Users can secure multiple computers, laptops, and personal devices without the need for separate subscriptions.</p>
<p>This flexible coverage makes the software ideal for families, home offices, professionals, and small businesses that require dependable security across several devices.</p>

<h4>Advanced Real-Time Protection</h4>
<p>The powerful real-time protection engine continuously monitors your devices for suspicious activities and cyber threats. Files, applications, downloads, and system processes are scanned instantly to identify and block malicious behavior.</p>
<p>Real-time protection helps prevent infections before they can damage your system, ensuring continuous security throughout your daily activities.</p>

<h4>Powerful Malware Detection</h4>
<p>SecureShieldX Internet Security Max protects against a wide range of digital threats, including:</p>
<ul>
<li>Viruses</li>
<li>Trojans</li>
<li>Spyware</li>
<li>Worms</li>
<li>Rootkits</li>
<li>Adware</li>
<li>Malicious software</li>
</ul>
<p>The intelligent detection engine quickly identifies threats and removes harmful files to keep your system secure and stable.</p>

<h4>Advanced Ransomware Protection</h4>
<p>Ransomware attacks have become one of the most serious cybersecurity threats. SecureShieldX Internet Security Max includes advanced ransomware protection that monitors suspicious activities and blocks unauthorized file encryption.</p>
<p>Important documents, business files, photos, and financial records remain protected against ransomware attacks and data loss.</p>

<h4>Safe Browsing Technology</h4>
<p>The internet contains countless malicious websites and dangerous downloads. SecureShieldX Internet Security Max provides safe browsing protection that identifies harmful websites and prevents access to suspicious online content.</p>
<p>Users can browse, search, download, and stream with greater confidence knowing that online threats are actively blocked.</p>

<h4>Anti-Phishing Security</h4>
<p>Cybercriminals frequently use fake websites and fraudulent emails to steal sensitive information. SecureShieldX Internet Security Max includes advanced anti-phishing technology that detects suspicious websites and warns users before personal information is entered.</p>
<p>This protection helps secure passwords, banking information, online accounts, and financial data.</p>

<h4>Secure Online Banking and Shopping</h4>
<p>Online banking and digital payments require enhanced protection. SecureShieldX Internet Security Max provides additional security for financial transactions, helping protect users against fraud and unauthorized access.</p>
<p>The software creates a safer environment for online shopping, digital payments, and banking activities.</p>

<h4>Firewall and Network Protection</h4>
<p>The integrated firewall continuously monitors incoming and outgoing network traffic. It blocks unauthorized access attempts and helps prevent hackers from gaining access to your devices.</p>
<p>Whether connected to home Wi-Fi, office networks, or public internet connections, firewall protection adds an additional layer of security.</p>

<h4>Privacy Protection</h4>
<p>Protecting personal information is essential in today\'s digital world. SecureShieldX Internet Security Max includes privacy tools that help secure sensitive files, personal documents, passwords, and confidential information.</p>
<p>Privacy protection features help users maintain control over their digital identity and reduce the risk of data theft.</p>

<h4>Automatic Security Updates</h4>
<p>Cyber threats change constantly, making regular updates essential for effective protection. SecureShieldX Internet Security Max automatically downloads the latest virus definitions, threat intelligence, and security improvements.</p>
<p>Automatic updates ensure your devices remain protected against newly emerging threats without requiring manual maintenance.</p>

<h4>Optimized Performance</h4>
<p>Strong security should not affect system performance. SecureShieldX Internet Security Max is designed to operate efficiently while using minimal system resources.</p>
<p>Users can work, browse, stream, study, and play games without experiencing significant slowdowns or interruptions.</p>

<h4>Two Years of Continuous Security</h4>
<p>The included 2-year license provides long-term protection and excellent value. Users can enjoy continuous security coverage without worrying about annual renewals.</p>
<p>Protecting five devices under one subscription makes the solution convenient and cost-effective.</p>

<h4>Key Features</h4>
<ul>
<li>Protects up to 5 devices.</li>
<li>2 years of security coverage.</li>
<li>Advanced real-time protection.</li>
<li>Malware and virus detection.</li>
<li>Ransomware protection.</li>
<li>Safe browsing technology.</li>
<li>Anti-phishing security.</li>
<li>Secure online banking protection.</li>
<li>Firewall and network security.</li>
<li>Privacy protection tools.</li>
<li>Automatic updates.</li>
<li>Lightweight system performance.</li>
</ul>

<h4>Ideal For</h4>
<p>SecureShieldX Internet Security Max is ideal for:</p>
<ul>
<li>Families.</li>
<li>Home users.</li>
<li>Professionals.</li>
<li>Remote workers.</li>
<li>Online shoppers.</li>
<li>Internet banking users.</li>
<li>Small businesses.</li>
<li>Multi-device households.</li>
</ul>

<h4>Why Choose SecureShieldX Internet Security Max?</h4>
<p>SecureShieldX Internet Security Max combines advanced protection technologies, intelligent threat detection, and privacy tools to deliver maximum online security. It provides reliable protection against modern cyber threats while maintaining excellent device performance.</p>
<p>With support for five devices, two years of continuous coverage, and premium security features, SecureShieldX Internet Security Max offers outstanding value and dependable protection for today\'s connected world.</p>

<p><strong>SecureShieldX Internet Security Max — Maximum Protection for 5 Devices, 2 Years of Reliable Security, and Complete Confidence for Your Digital Life.</strong></p>',
'Internet Security Max.png', 1, 1);

-- ==========================================
-- Orders & Order Items Tables
-- ==========================================
CREATE TABLE IF NOT EXISTS orders (
    id INT AUTO_INCREMENT PRIMARY KEY,
    order_number VARCHAR(50) NOT NULL UNIQUE,
    email VARCHAR(255) NOT NULL,
    first_name VARCHAR(100) NOT NULL,
    last_name VARCHAR(100) NOT NULL,
    country VARCHAR(100) NOT NULL,
    address TEXT NOT NULL,
    apartment VARCHAR(255) DEFAULT NULL,
    city VARCHAR(100) NOT NULL,
    state VARCHAR(100) NOT NULL,
    pin_code VARCHAR(50) NOT NULL,
    phone VARCHAR(50) DEFAULT NULL,
    order_note TEXT DEFAULT NULL,
    newsletter_optin TINYINT(1) DEFAULT 0,
    subtotal DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    discount DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    coupon_code VARCHAR(50) DEFAULT NULL,
    total DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    items_json LONGTEXT NOT NULL,
    license_key VARCHAR(100) NOT NULL,
    payment_status VARCHAR(50) DEFAULT 'Paid',
    order_status VARCHAR(50) DEFAULT 'Completed',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS order_items (
    id INT AUTO_INCREMENT PRIMARY KEY,
    order_id INT NOT NULL,
    product_id INT DEFAULT NULL,
    product_name VARCHAR(255) NOT NULL,
    price DECIMAL(10,2) NOT NULL,
    quantity INT NOT NULL DEFAULT 1,
    devices VARCHAR(50) DEFAULT NULL,
    years VARCHAR(50) DEFAULT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE
);

-- ==========================================
-- Users / Customers Table
-- ==========================================
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    username VARCHAR(100) NOT NULL UNIQUE,
    email VARCHAR(255) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    phone VARCHAR(50) DEFAULT NULL,
    status TINYINT(1) DEFAULT 1,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);


