CREATE TABLE IF NOT EXISTS commandes (
    id INT AUTO_INCREMENT PRIMARY KEY,
    client_nom VARCHAR(100) NOT NULL,
    client_telephone VARCHAR(20) NOT NULL,
    plat_nom VARCHAR(150) NOT NULL,
    quantite INT NOT NULL DEFAULT 1,
    mode_consommation ENUM('livraison', 'sur_place') NOT NULL,
    total INT NOT NULL,
    statut VARCHAR(30) DEFAULT 'en_attente',
    date_creation DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS commande_options (
    id INT AUTO_INCREMENT PRIMARY KEY,
    commande_id INT NOT NULL,
    option_nom VARCHAR(100) NOT NULL,
    prix_supplementaire INT DEFAULT 0,
    FOREIGN KEY (commande_id) REFERENCES commandes(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS restaurants (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nom VARCHAR(150) NOT NULL,
    image VARCHAR(255) NOT NULL,
    categorie VARCHAR(100) NOT NULL,
    note DECIMAL(2,1) DEFAULT 4.5,
    temps_livraison VARCHAR(30) DEFAULT '20-30 min',
    frais_livraison INT DEFAULT 500,
    is_featured TINYINT(1) DEFAULT 0,
    statut ENUM('ouvert', 'ferme') DEFAULT 'ouvert',
    date_creation DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;